Anyone know anything about how I might get mp3 data out of flash from an embedded wav file compressed in flash as a 16k mp3…? :insomniac:
I already have a little php setup on my locahost to catch the required application/octet-stream coming from flash through a navigatetourl call of a urlrequest, but the “Sound.extract” method has me sort of stumped. (and it’s late, but that’s no excuse).
I’m not sure if this is even possible to be honest, as I’m certain I’ve read somewhere that the Sound object will have it’s own encoding at its heart, but just wondered if anyone else has managed to rebuild their own mp3 files from information created in flash dynamically. Byte array DOES seem to pump out some information (about 16k) but it’s garbage…
I’ll post my test code anyway…
var bSnd:bboy = new bboy(); // base flash.media.Sound class...
var bytes:ByteArray = new ByteArray();
bSnd.extract(bytes, bSnd.length);
var mp3Stream:ByteArray = bytes;
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var mp3URLRequest:URLRequest = new URLRequest("filew.php");
mp3URLRequest.requestHeaders.push(header);
mp3URLRequest.method = URLRequestMethod.POST;
mp3URLRequest.data = mp3Stream;
navigateToURL(mp3URLRequest, "_blank");
also tried the urlrequestheader as “audio/mpeg” but no joy (as expected) since I suppose at this stage I’m simply posting a form of encoded data, not of mime type audio/mpeg…
Loving my CS4 though. only came in the office yesterday, and I swear I’ve never done so much work in flash with sound before, and not a graphic equaliser GUI in sight… :love: