【问题标题】:AIR 3 Download mp3空气 3 下载 mp3
【发布时间】:2012-06-17 13:56:23
【问题描述】:

我想在移动设备 iO 或 android 上下载 mp3 文件,因为我不想每次都从服务器下载。 我编写了简单的代码,但无法正常工作。文件太大,因为没有编码,保存后无法再播放。

请帮助并为英语不好感到抱歉。

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

【问题讨论】:

  • 我认为你在哪里做 sound.extract 它将 mp3 解压缩为“原始”音频波数据,这意味着它是 mp3 的解压缩/解码版本。我的猜测是您只想使用 Loader 或类似的东西来自己获取 mp3。我假设您可以使用 Loader 下载文件,然后使用 Sound 类的实例来加载该本地文件并播放它。

标签: android ios actionscript-3 air


【解决方案1】:

基本上答案是使用 URLStream 和 FileStream。

问题非常广泛和涵盖,例如,Download a file with Adobe AIRAS3: URLStream saving files to desktop?

【讨论】:

    猜你喜欢
    • 2017-07-04
    • 2016-05-03
    • 2013-01-09
    • 2012-07-29
    • 2012-02-25
    • 2014-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多