I want to download mp3 file, on mobile device iOs or android, because i dont want to download every time from server. I write simple code, but not work correctly. File size is too big, because is not encode and after save I cant play it again.
Please help and sorry for bad English.
private var sound:Sound;
public function loadSound(tmpUrl:String):void
{
sound = new Sound();
sound.addEventListener(Event.COMPLETE,onLoadSuccessSound, false, 0, true);
sound.load(new URLRequest(tmpUrl));
}
protected function onLoadSuccessSound(event:Event):void
{
var fileData:ByteArray = new ByteArray();
sound.extract(fileData, sound.bytesTotal);
var file:File = new File(File.applicationStorageDirectory + "\\ppp.mp3");
var fs:FileStream = new FileStream();
fs.open(file, FileMode.WRITE);
fs.writeBytes(fileData,0,fileData.length);
fs.close();
}