avm2: Impl `SoundChannel.stop()`
This commit is contained in:
parent
39305f6a38
commit
d73ba586d0
|
@ -98,6 +98,19 @@ pub fn set_sound_transform<'gc>(
|
||||||
Ok(Value::Undefined)
|
Ok(Value::Undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Impl `SoundChannel.stop`
|
||||||
|
pub fn stop<'gc>(
|
||||||
|
activation: &mut Activation<'_, 'gc, '_>,
|
||||||
|
this: Option<Object<'gc>>,
|
||||||
|
_args: &[Value<'gc>],
|
||||||
|
) -> Result<Value<'gc>, Error> {
|
||||||
|
if let Some(instance) = this.and_then(|this| this.as_sound_instance()) {
|
||||||
|
activation.context.stop_sound(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Value::Undefined)
|
||||||
|
}
|
||||||
|
|
||||||
/// Construct `SoundChannel`'s class.
|
/// Construct `SoundChannel`'s class.
|
||||||
pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> {
|
pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> {
|
||||||
let class = Class::new(
|
let class = Class::new(
|
||||||
|
@ -129,5 +142,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
];
|
];
|
||||||
write.define_public_builtin_instance_properties(mc, PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(mc, PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
|
const PUBLIC_INSTANCE_METHODS: &[(&str, NativeMethodImpl)] = &[("stop", stop)];
|
||||||
|
write.define_public_builtin_instance_methods(mc, PUBLIC_INSTANCE_METHODS);
|
||||||
|
|
||||||
class
|
class
|
||||||
}
|
}
|
||||||
|
|
|
@ -661,6 +661,7 @@ swf_tests! {
|
||||||
(as3_sound_play, "avm2/sound_play", 1),
|
(as3_sound_play, "avm2/sound_play", 1),
|
||||||
#[ignore] (as3_soundchannel_position, "avm2/soundchannel_position", 75),
|
#[ignore] (as3_soundchannel_position, "avm2/soundchannel_position", 75),
|
||||||
(as3_soundchannel_soundtransform, "avm2/soundchannel_soundtransform", 49),
|
(as3_soundchannel_soundtransform, "avm2/soundchannel_soundtransform", 49),
|
||||||
|
(as3_soundchannel_stop, "avm2/soundchannel_stop", 4),
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: These tests have some inaccuracies currently, so we use approx_eq to test that numeric values are close enough.
|
// TODO: These tests have some inaccuracies currently, so we use approx_eq to test that numeric values are close enough.
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,8 @@
|
||||||
|
///var silence = new Silence();
|
||||||
|
///var silence_channel = silence.play();
|
||||||
|
///silence_channel.stop()
|
||||||
|
undefined
|
||||||
|
///var noise = new Noise();
|
||||||
|
///var noise_channel = noise.play(0, 1);
|
||||||
|
///noise_channel.stop();
|
||||||
|
undefined
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue