如何获得一定的保存路径和加载一个MP3(Android版AIR) [英] How to get a certain path for saving and loading an mp3 (AIR for Android)

查看:120
本文介绍了如何获得一定的保存路径和加载一个MP3(Android版AIR)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用闪耀MP3连接codeR 保存一个的 MP3 的文件。它有一个 saveFile的方法,可以节省一个mp3文件。当这个方法运行(只有一个参数名:字符串),它会自动触发弹出,并询问用户保存的MP3文件

I'm using shine mp3 encoder for saving an mp3 file. It has a saveFile method that can save an mp3 file. When that method runs (with only one argument name:String), it automatically triggers a pop up and asks the user where to save the mp3 file.

我怎样才能prevent这个弹出的AIR?

How can I prevent this pop up from AIR?

我需要保存声音的路径,我想加载和后来播放的声音。

I need a path for saving that sound and I want to load and play that sound later.

有人可以帮助我找到一种方法,prevent不必从用户获取路径,而使用一个固定的路径,我可以加载回来以后呢?

Can someone help me find a way to prevent having to get the path from the user and instead use a fixed path that I can load back in later?

推荐答案

下面是一个使用的文件和<一href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/FileStream.html"相对=nofollow>的FileStream AIR类 - 它可以让你同步(或异步)保存文件,而无需用户交互

Here is an example using the File and FileStream classes in AIR - Which lets you save a file synchronously (or asynchronously) without user interaction.

假设你的闪耀MP3的对象是一个名为VAR myMp3

Let's say your shine mp3 object is in a var called myMp3:

首先,获得一个引用您的文件(如果它还不存在与否并不重要),使用相同的文件进行保存和加载:

First, get a reference to your file (doesn't matter if it exists yet or not), use this same file for saving and loading:

var file:File = File.applicationStorageDirectory.resolvePath("MyMP3Name.mp3");
//applicationStorageDirectory is most appropriate place to save data for your app, and probably also the only place you'll have permission to do so

保存

var stream:FileStream = new FileStream();
sream.open(file, FileMode.WRITE);
stream.writeBytes(myMp3.mp3Data); //write the byte array to the file
stream.close();

要加载(使用上述同样的File对象)

To Load (using the same File object from above)

var stream:FileStream = new FileStream();
    stream.open(file, FileMode.READ);

var sound:Sound = new Sound();
var mp3Bytes:ByteArray;
stream.readBytes(mp3Bytes); //read the bytearray in the file into the mp3Bytes var
stream.close();

sound.loadCompressedDataFromByteArray(mp3Bytes); //load that byte array into the sound object

sound.play();

这篇关于如何获得一定的保存路径和加载一个MP3(Android版AIR)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆