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 found the problem here. Firstly, the emulator I was running on did not have audio turned on, so I needed to add the audio enabled boolean in the AVD manager in eclipse. Not having audio turned on is what was causing it to always return 261 milliseconds. There was also a second problem. See the 2 code snippets below. The first was my code and the second is the code from the tutorial. There is a subtle difference (number of brackets) which causes the first one to always evaluate to 0.
seekBarProgress.setProgress((int)((float) mediaPlayer.getCurrentPosition() / getMp3Duration()) * 100);
seekBarProgress.setProgress((int) (((float) mediaPlayer.getCurrentPosition() / getMp3Duration()) * 100));