private void playSound(){
Log.d(TAG,"Play SOund");
new Thread(new Runnable() {
public void run() {
MediaPlayer mPlayer = MediaPlayer.create(mainActivity, R.raw.button_6);
Log.d(TAG,"DURATION ::-->>"+ mPlayer.getDuration());
mPlayer.start();
}
}).start();
Log.d(TAG,"END OF Play SOund");
}
When I use a small mp3 file inside raw folder my applications gives me a small sound. Some ting like a noise of 0.3 seconds. But if i use a large mp3 then i get the following exception
02-01 10:06:53.298: ERROR/AndroidRuntime(10754): FATAL EXCEPTION: Thread-11
02-01 10:06:53.298: ERROR/AndroidRuntime(10754): android.content.res.Resources$NotFoundException: Resource ID #0x7f040001
Can any one suggest what am i doing wrong here ??
It seems the system needs to wait until the player finishers playing. Else the next line starts to execute and once the code is finished mp3 or the audios stops. So what i did was shown below. And it works 🙂