I have looked at various different websites looking for a solution for this problem in my code. It is a basic audio player with 3 buttons: play, pause and stop. Play and pause w
The problem is once you've stopped it, you setDataSource
again. You have to then call prepare()
player.setDataSource(getAssets().openFd("raw/airbourne_runnin_wild.mp3").getFileDescriptor());
player.prepare();
Anytime you call setDataSource()
on it you will need to prepare()
it again. Think of it as loading the file, getting ready for playback.
By the way I notice you mix up calling MediaPlayer.create()
and also call setDataSource()
multiple times for the same file. There's no need to do this. Once the MediaPlayer is created and prepared (which calling .create()
does for you), you can just call .stop()
, .pause()
, .play()
on it, no need to reset it all the time.