Android MediaPlayer - exception thrown from setdatasource native method
the following code i am using for playing
MediaPlayer mp3;
mp3=new MediaPlayer();
mp3.setDataSource("/beep.mp3");
mp3.start();
exception is thrown from setdatasou开发者_开发技巧rce native method
can anyone help me in this problem
Just put your file in asset folder n apply this code..
Media Player mp = new MediaPlayer();
AssetFileDescriptor descriptor = contex.getAssets().openFd(fileName);
mp.setDataSource( descriptor.getFileDescriptor(),
descriptor.getStartOffset(), descriptor.getLength() );
descriptor.close();
mp.prepare();
mp.start();
- check your file path, or use FileDescriptor
- dont forgot prepare before start
精彩评论