Building a simple audio app in Android (Part 2/3)
Nazmul Idris (Naz)
3793

When I use a smaller refresh interval, the method getCurrentPosition() doesn't work consistently — sometimes it returns a value less than the previous one (e.g. it goes back in time…). For example, here's the output when the interval is set to 16 ms:

08–29 17:35:40.289 3533–3562/com.example.android.mediaplayersample D/MainActivity: setPlaybackPosition: setProgress(203)
08–29 17:35:40.304 3533–3562/com.example.android.mediaplayersample D/MainActivity: setPlaybackPosition: setProgress(218)
08–29 17:35:40.320 3533–3562/com.example.android.mediaplayersample D/MainActivity: setPlaybackPosition: setProgress(234)
08–29 17:35:40.338 3533–3562/com.example.android.mediaplayersample D/MainActivity: setPlaybackPosition: setProgress(251)
08–29 17:35:40.352 3533–3562/com.example.android.mediaplayersample D/MainActivity: setPlaybackPosition: setProgress(165)
08–29 17:35:40.368 3533–3562/com.example.android.mediaplayersample D/MainActivity: setPlaybackPosition: setProgress(181)
08–29 17:35:40.384 3533–3562/com.example.android.mediaplayersample D/MainActivity: setPlaybackPosition: setProgress(197)
08–29 17:35:40.401 3533–3562/com.example.android.mediaplayersample D/MainActivity: setPlaybackPosition: setProgress(214)
08–29 17:35:40.417 3533–3562/com.example.android.mediaplayersample D/MainActivity: setPlaybackPosition: setProgress(229)

Notice how it goes from 251 to 165, then it goes up again.

Is that an actual bug or am I doing something wrong?

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.