0

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();
        }
4

1 に答える 1

0

基本的に答えは、URLStream と FileStream を使用することです。

たとえば、ここでは、Adobe AIRAS3 でファイルをダウンロードします: URLStream はファイルをデスクトップに保存しますか?

于 2012-06-15T19:14:14.480 に答える