保存EN codeD MP3播放到applicationStorageDirectory Adob​​e AIR的的iOScodeD、EN、applicationStorageDirectory、iO

2023-09-08 11:32:58 作者:江山赏玩笑

我开发一个iOS的iPad应用程序瓦特/闪存CS5.5 AIR v.3.1

我用ShineMp3En codeR为en codea的WAV从MP3: https://github.com/kikko/Shine-MP3 -En codeR-ON-AS3-炼金术

基本上它转换为ByteArray(WAV)在code的ByteArray(MP3)或mp3en coder.mp3Data。

我没有问题使用(新的FileReference())保存此保存(mp3Data,文件名)。但由于这是被用在iOS的AIR应用程序,我想切换到使用File.applicationStorageDirectory,这样我可以把保存的MP3到它自己的文件夹,以保持组织。当我运行code它会完成所有步骤,转换WAV到MP3,然后说,它节省了,但没有错误,没有。声音存储在存储器中,因为它是能够被回放,直至该应用程序被关闭。我将与resolvePath更改为根文件夹,对myApp /,和/声音 - 没有它的工作。我从来没有尝试之前让我有点失去了为什么正在创建任何文件来做到这一点。任何人只要有任何建议将有很大的帮助。

 函数onEn codeD(五:事件):无效{
    myTI.text =MP3连接codeD并保存preSS玩。
    mp3en coder.mp3Data.position = 0;
    VAR指明MyDate:日期=新的日期();
    VAR theDate:字符串= myDate.monthUTC.toString()+ myDate.dayUTC.toString()
        + myDate.hoursUTC.toString()+ myDate.minutesUTC.toString()
        + myDate.secondsUTC.toString();

    var文件:文件= File.applicationStorageDirectory.resolvePath(对myApp /声音/ myVoice ++ theDate +MP3);
    VAR FILESTREAM:的FileStream =新的FileStream;
    fileStream.open(文件,FileMode.UPDATE的);
    fileStream.writeBytes(mp3en coder.mp3Data);
    fileStream.close();
}
 

解决方案

我知道我的答案是有点晚了,但也许这将是人谁就会发现这个帖子以后有用。

当你在Windows上开发的Adobe AIR和尝试保存的东西File.applicationStorageDirectory它不会保存在同一文件夹喜欢你的SWF或FLA文件。

这将保存在这里: C:\用户[WIN_LOGIN] \应用程序数据\漫游[APP_ID] \本地商店

您APP_ID,你会发现并设置发布设置了内部监督办公室。

I'm developing an iOS iPad app w/ Flash CS5.5 AIR v.3.1

I'm using ShineMp3Encoder to encode a Wav to a Mp3 from: https://github.com/kikko/Shine-MP3-Encoder-on-AS3-Alchemy

Basically it converts a byteArray (wav) to a byteArray (mp3) or "mp3encoder.mp3Data" in the code.

I have no trouble saving this using a (new FileReference()).save(mp3Data, filename); but because this is being used in a iOS AIR app I wanted to switch to using the File.applicationStorageDirectory so that I could put the saved mp3 into it's own folder to keep organized. When I run the code it goes through all the steps, converts the wav to mp3, and then says that it saves but doesn't with no errors. The sound IS stored in memory, as it is able to be played back until the app is closed. I've changed the resolvePath to the root folder, myApp/, and to /sounds - None of which work. I've never attempted to do this before so I'm a little lost why no file is being created. Anyone with any suggestions would help a lot.

function onEncoded(e:Event):void{
    myTI.text = "Mp3 encoded and saved. Press Play.";
    mp3encoder.mp3Data.position = 0;
    var myDate:Date = new Date();
    var theDate:String = myDate.monthUTC.toString() + myDate.dayUTC.toString() 
        + myDate.hoursUTC.toString() + myDate.minutesUTC.toString() 
        + myDate.secondsUTC.toString();

    var file:File = File.applicationStorageDirectory.resolvePath("myApp/sounds/myVoice+"+theDate+".mp3");
    var fileStream:FileStream = new FileStream;
    fileStream.open(file,FileMode.UPDATE);
    fileStream.writeBytes(mp3encoder.mp3Data);
    fileStream.close();
}

解决方案

I know my answer is little bit late, but maybe it will be useful for somebody who will find this post in future.

When you develop on Windows in Adobe AIR and try to save something in File.applicationStorageDirectory it will NOT saved in the same folder like your swf or fla file.

It will be saved here: C:\Users[WIN_LOGIN]\AppData\Roaming[APP_ID]\Local Store

Your APP_ID you will find and set in Publish Settings for IOS.