Commit 4c8f882 1 parent d76306d commit 4c8f882 Copy full SHA for 4c8f882
File tree 1 file changed +19
-7
lines changed
core/src/avm2/globals/flash/media
1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -264,14 +264,26 @@ pub fn load<'gc>(
264
264
/// `Sound.loadCompressedDataFromByteArray`
265
265
pub fn load_compressed_data_from_byte_array < ' gc > (
266
266
activation : & mut Activation < ' _ , ' gc > ,
267
- _this : Object < ' gc > ,
268
- _args : & [ Value < ' gc > ] ,
267
+ this : Object < ' gc > ,
268
+ args : & [ Value < ' gc > ] ,
269
269
) -> Result < Value < ' gc > , Error < ' gc > > {
270
- avm2_stub_method ! (
271
- activation,
272
- "flash.media.Sound" ,
273
- "loadCompressedDataFromByteArray"
274
- ) ;
270
+ let bytearray = args. get_object ( activation, 0 , "bytes" ) ?;
271
+ let bytes_length = args. get_u32 ( activation, 1 ) ?;
272
+ let bytearray = bytearray. as_bytearray ( ) . unwrap ( ) ;
273
+
274
+ // FIXME - determine the actual errors thrown by Flash Player
275
+ let bytes = bytearray. read_bytes ( bytes_length as usize ) . map_err ( |e| {
276
+ Error :: RustError ( format ! ( "Missing bytes from sound bytearray: {e:?}" ) . into ( ) )
277
+ } ) ?;
278
+
279
+ let handle = activation. context . audio . register_mp3 ( bytes) . map_err ( |e| {
280
+ Error :: RustError ( format ! ( "Failed to register sound from bytearray: {e:?}" ) . into ( ) )
281
+ } ) ?;
282
+
283
+ this. as_sound_object ( )
284
+ . unwrap ( )
285
+ . set_sound ( & mut activation. context , handle) ?;
286
+
275
287
Ok ( Value :: Undefined )
276
288
}
277
289
You can’t perform that action at this time.
0 commit comments