avm2: Improve the Sound::extract stub
This commit is contained in:
parent
d047ecb130
commit
b0576c2155
|
@ -198,9 +198,23 @@ pub fn play<'gc>(
|
||||||
pub fn extract<'gc>(
|
pub fn extract<'gc>(
|
||||||
activation: &mut Activation<'_, 'gc>,
|
activation: &mut Activation<'_, 'gc>,
|
||||||
_this: Option<Object<'gc>>,
|
_this: Option<Object<'gc>>,
|
||||||
_args: &[Value<'gc>],
|
args: &[Value<'gc>],
|
||||||
) -> Result<Value<'gc>, Error<'gc>> {
|
) -> Result<Value<'gc>, Error<'gc>> {
|
||||||
avm2_stub_method!(activation, "flash.media.Sound", "extract");
|
avm2_stub_method!(activation, "flash.media.Sound", "extract");
|
||||||
|
|
||||||
|
let bytearray = args
|
||||||
|
.get(0)
|
||||||
|
.unwrap_or(&Value::Undefined)
|
||||||
|
.coerce_to_object(activation)?;
|
||||||
|
let length = args
|
||||||
|
.get(1)
|
||||||
|
.unwrap_or(&Value::Number(0.0))
|
||||||
|
.coerce_to_number(activation)?;
|
||||||
|
|
||||||
|
if let Some(mut bytearray) = bytearray.as_bytearray_mut(activation.context.gc_context) {
|
||||||
|
bytearray.write_bytes(vec![0u8; length.ceil() as usize].as_slice())?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(Value::Undefined)
|
Ok(Value::Undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue