从 Sdcard 播放音频文件 [英] Playing audio file from Sdcard
本文介绍了从 Sdcard 播放音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想播放 sdcard 中的音频文件.如何读取音频文件并播放?下面是我播放音频文件的代码:
I would like to play an audio file from the sdcard. How can I read the audio file and play it? Below is my code to play audio file:
int sound1;
sound1 = mSoundPool.load(this, R.raw.om, 1);
mSoundPool.play(sound1, 1, 1, 1, time - 1, 1);
在上面的代码中,我使用 soundpool 播放原始文件夹中的音频文件,但我需要使用 soundpool 播放 sdcard 中的音频文件.
Here in the above code i am using soundpool to play the audio file from raw folder but i need to play the audio file from sdcard using soundpool.
现在有兴趣播放 sdcard 中的音频.
Right now interested to play audio from sdcard.
如何实现?请帮助我尽快解决这个问题
How to acheive this? please help i need to fix this as soon as possible
推荐答案
使用下面的代码对我有用.
Use the code below it worked for me.
MediaPlayer mp = new MediaPlayer();
mp.setDataSource("/mnt/sdcard/yourdirectory/youraudiofile.wav");
mp.prepare();
mp.start();
这篇关于从 Sdcard 播放音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文