Search code examples
androidmedia-player

MediaPlayer.getCurrentPosition() has system dependent offset


I'm using the android.media.MediaPlayer to play a song in my Android application. Some events in my app are triggered at certain parts of the song. To know where in the song I am right now I use MediaPlayer.getCurrentPosition().

A problem with this approach is that getCurrentPosition() returns the current position in the song, plus a small error. The error is constant, but different for all phones I tested. The error also changes when updating Android. The error ranges from -50 to 150 ms.

Is this a known problem? Any ideas on how to work around it? (Except creating a table over all known phones and android versions)


Solution

  • It is a known problem. See http://code.google.com/p/android/issues/detail?id=11590 And as of today, I have not seen any good solutions.