开发者

FileNotFound Exception MediaPlayer android

开发者 https://www.devze.com 2023-03-08 18:59 出处:网络
I have a1.ogg in the res/raw file try { mp = MediaPlayer.create(this, R.raw.a1); } catch (Exception e) { Log.e(\"msg\",e.getMessage());}

I have a1.ogg in the res/raw file

try {
    mp = MediaPlayer.create(this, R.raw.a1);      
} catch (Exception e)
{ Log.e("msg",e.getMessage());  }

Give me java.i开发者_StackOverflow社区o.FileNotFoundException

The same file in wav format work


Try this:

MediaPlayer mp = new MediaPlayer();

mp.setDataSource("/data/test.ogg"); // replace with correct location
mp.prepare();
mp.start();
0

精彩评论

暂无评论...
验证码 换一张
取 消