我已经实现了这个代码来播放res/drawable/testing123.mp3文件中可用的声音文件。 的代码是:为什么我无法在android中播放mp3文件?
public void playSound()
{
boolean mStartPlaying = true;
if (mStartPlaying==true)
{
// String word = wordValue.getText().toString();
String file = Environment.getExternalStorageDirectory().getAbsolutePath();
String sound = file+"/testing123.mp3";
//System.out.println("Before Allocation file is: "+file);
//rePlay.setText("Stop");
mPlayer = new MediaPlayer();
try
{
mPlayer.setDataSource(sound);
mPlayer.prepare();
mPlayer.start();
}
catch (IOException e)
{
Log.e(LOG_TAG, "prepare() failed");
}
}
else
{
// stopPlaying();
//rePlay.setText("Replay");
mPlayer.release();
mPlayer = null;
}
mStartPlaying = !mStartPlaying;
}
,但我不能够发挥它。 声音文件在res/drawable/testing123.mp3
那么请帮助我,为什么我无法播放该文件? 谢谢。
是否有任何错误或者您是否听不到任何声音? –
我没有听到任何声音。 。 。 –
听起来像一个权限问题.. – Gnufabio