Jump to content
GreenSock

pouradam

Can I save downloaded Mp3 with mp3Loader (through ByteArray) ?

Recommended Posts

Good day and thanks a lot for your fantabioulous job! Wish you all the best really.

 

And my question...

 

I can load online Mp3 files and control them using mp3Loader class (Play/pause/....): 

var snd:MP3Loader = new MP3Loader(_sndURL, { name: "myMp3", autoPlay: true, onOpen: doOpen, onProgress: doProgress, onComplete: doComplete, onError: doError, onFail: doError} );

snd.load();

 

But how can I access to the binary Mp3 data that are loaded?

(to save them in ByteArray and then use fileStream to writeBytes on disk)

 

When I try something like this :

function doComplete(event:LoaderEvent):void {
  var ba:ByteArray = snd.content;
}

I get an Error that makes sense:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.media::Sound@61d3021 to flash.utils.ByteArray.

Also if I use dataLoader, then I can not have control over Mp3 playback (i.e autoPlay).

 

So What should I do?

-  to could download Mp3 files and play them with Mp3Loader class

-  and also have access to its binary data to could save it on Disk ??

 

Thanks a lot,

      Ali

Link to comment
Share on other sites

Thanks a lot for your reply,

 

 Actually I checked that Link, and it is all about "Sound" class, so do you mean I can use extract() method, to extract byteArray data (in-directly) from an instance of an mp3Loader class!? 

 

for instance, based on my above example, do you mean I can extract the loaded snd file with a function like this:

var snd:MP3Loader = new MP3Loader...
snd.load();

//onComplete
snd.extract(); // ??
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×