Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Audio 将音频文件添加到我的android应用程序_Audio_Android - Fatal编程技术网

Audio 将音频文件添加到我的android应用程序

Audio 将音频文件添加到我的android应用程序,audio,android,Audio,Android,我正在尝试创建一个ar android应用程序。但我不能这么做。我尝试使用SoundPool,但音频文件从未播放过。有人能告诉我如何使用soundpool吗?我是一个完全的初学者。a设计用于播放小文件,通常不超过30秒。您可以这样构造一个声音池: SoundPool player = new SoundPool(int maxStreams, int streamType, 0); 加载声音文件的方式如下: int soundID = player.load(Context ctxt,int

我正在尝试创建一个ar android应用程序。但我不能这么做。我尝试使用SoundPool,但音频文件从未播放过。有人能告诉我如何使用soundpool吗?我是一个完全的初学者。

a设计用于播放小文件,通常不超过30秒。您可以这样构造一个声音池:

SoundPool player = new SoundPool(int maxStreams, int streamType, 0);
加载声音文件的方式如下:

int soundID = player.load(Context ctxt,int audioFile, int priority);
其中audioFile是
R.raw.somesound
(不包括文件扩展名)。请注意,您希望保留.load方法的返回值,否则将无法播放声音

您播放的声音如下:

int streamID = player.play(soundID, float leftVolume, float rightVolume ,int priority, int loop, float rate);
其中leftVolume和rightVolume是从0到1的浮动,不包括在内。您可能希望保留streamID,以便稍后暂停或停止声音。请注意,必须等待声音加载后才能播放(使用setOnLoadCompleteListener方法)

有关更多信息,请参阅