Reputation: 171
i want to make kind of karaoke app, to do so i need to make ui changes at a particular moment (millisecond timing)
MediaPlayer.getDuration
is not the same depending on the device.
MediaPlayer.getCurrentPosition
gives me millisecond but there is not precision (it will jump 200 millisecond one time 400 another and so on...)
so guys, how can i get the accuracy i want ? is there any audio player or audio player i can use in java ?
Thanks.
Upvotes: 2
Views: 465
Reputation: 5361
Theoretically accuracy depend on:
1) how frequently you ask for getCurrentPosition()
. In some cases I use 100 ms interval.
2) which media format do you use
3) and most critical depend on implementation. Part of HW and SW related to multimedia vary from device to device and depend on device manufacturer, HW chips and OS version.
I suggest you to try query current position more frequently. And probably different media files.
Possible solution:
You can use software implementation of media player (ex: FFMpeg can be compiled for Android). Negative side of this is CPU usage, battery drain and video decoding speed. Some devices cannot handle (too low fps) huge high quality video by without HW acceleration which is provided only by standard MediaPlayer API.
Upvotes: 1