I have followed Igor Khrupin's tutorial on streaming mp3 files in Android using the MediaPlayer class: http://www.hrupin.com/2011/02/example-of-streaming-mp3-mediafile-with-android-mediaplayer-class
This is all working fine except that the primary progress of the seek bar is not updating correctly. It stops just after the beginning. On debugging this, I can see that the MediaPlayer.getCurrentPosition() method is always returning 261 (milliseconds) even though the mp3 song is playing fine.
Has anyone come across this issue before or got any ideas on how to fix it?
Many thanks
I also had the same problem. I solved the problem by determining the type of stream using the setAudioStreamType(int)
method:
Uri myUri = ....; // initialize Uri here
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(getApplicationContext(), myUri);
mediaPlayer.prepare();
mediaPlayer.start();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With