• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Playing an MP3 Sound using its ByteArray

Explorer ,
Feb 13, 2013 Feb 13, 2013

Copy link to clipboard

Copied

With AS3 we can do this to load an MP3 and play it:

var sound:Sound = new Sound( new URLRequest("sound.mp3") );

sound.play();

That is very easy, but what if I already have the entire ByteArray of that MP3 loaded and I want to simply play it?

Why cant AS3 have a simple method to simply pass the ByteArray working exactly like it works now passing a URLRequest?

In my case I need this because I am loading a ZIP file containing a bunch of MP3s and when I uncompress it I can read the bytearray of each MP3 but I can't play them.

Views

4.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Mar 02, 2013 Mar 02, 2013

Have you tried loadCompressedDataFromByteArray in the Sound class?


Assuming you have the ByteArray already instantiated, try:

var sound:Sound = new Sound();

sound.loadCompressedDataFromByteArray ( mp3Bytes, mp3Bytes.length );

sound.play();

Votes

Translate

Translate
Explorer ,
Mar 01, 2013 Mar 01, 2013

Copy link to clipboard

Copied

Anyone knows?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 02, 2013 Mar 02, 2013

Copy link to clipboard

Copied

Have you tried loadCompressedDataFromByteArray in the Sound class?


Assuming you have the ByteArray already instantiated, try:

var sound:Sound = new Sound();

sound.loadCompressedDataFromByteArray ( mp3Bytes, mp3Bytes.length );

sound.play();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

Awesome. thanks I was not aware of this new method.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 21, 2020 Jan 21, 2020

Copy link to clipboard

Copied

LATEST

Hi

 

If I have only partial ByteArray of data for that Mp3 file and I am dynamically fetching the data in chunks, how do I load it to loadCompressedDataFromByteArray? I was able to play the first chunk, but one I ahve the new data not sure how to add to Sound object to play continuously?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines