将编码的.mp3保存到applicationStorageDirectory Adob​​e Air iOS

我正在开发一个带有Flash CS5.5 AIR v.3.1的iOS iPad应用程序

我使用ShineMp3Encoder来编码一个Wav到Mp3从: https : //github.com/kikko/Shine-MP3-Encoder-on-AS3-Alchemy

基本上,它在代码中将byteArray(wav)转换为byteArray(mp3)或“mp3encoder.mp3Data”。

我没有任何问题使用(新的FileReference())来保存。save(mp3Data,filename); 但是因为这是在一个iOS AIR应用程序中使用,我想切换到使用File.applicationStorageDirectory,以便我可以把保存的MP3放到它自己的文件夹保持组织。 当我运行代码时,它会经历所有的步骤,将wav转换为mp3,然后说它会保存,但不会有错误。 声音存储在内存中,因为它可以播放,直到应用程序closures。 我已将resolvePath更改为根文件夹myApp /,并将其更改为/ sounds – 其中没有一个可以工作。 我从来没有试图做到这一点,所以我有点迷路,为什么没有文件正在创build。 任何有任何build议的人都会帮助很多。

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

未经testing,但尝试这一点。 如果有效,请根据需要将文件名修改为dynamic。

 var myfilename:File = File.applicationStorageDirectory; myfilename = myfilename.resolvePath("myVoice.mp3"); var outputStream:FileStream = new FileStream(); outputStream.open(myfilename,FileMode.WRITE); outputStream.writeBytes(mp3encoder.mp3Data,0,mp3encoder.mp3Data.length); outputStream.close(); 

我知道我的答案有点晚了,但也许对将来会find这个职位的人有用。

在Adobe AIR的Windows上开发并尝试在File.applicationStorageDirectory中保存某些内容时,它不会像swf或fla文件那样保存在相同的文件夹中。

它将被保存在这里:C:\ Users [WIN_LOGIN] \ AppData \ Roaming [APP_ID] \ Local Store

您将在IOS的“发布设置”中find并设置您的APP_ID。