With libvlc, how do I get libvlc_media_player_get_time() to return a more accurate result? With 60fps video the value it returns is only updated a few times per second at most. Is there any way to get frame accurate timing?
How do I get libvlc_media_player_get_time() to return a more accurate result?
Asked Answered
I'm having an issue with this now because the player I'm building is made for playing short videos (< 1 min in length) and the slow time updates make the position indicator look sluggish and choppy. It's depressing that there is no real solution for this. –
Triceps
This issue says that there is no way to get more accurate result from libvlc.
But you can interpolate it:
private long lastPlayTime = 0;
private long lastPlayTimeGlobal = 0;
/**
* Get current play time (interpolated)
* @see https://github.com/caprica/vlcj/issues/74
* @return
*/
public float getCurrentTime(){
long currentTime = directMediaPlayer.getTime();
if (lastPlayTime == currentTime && lastPlayTime != 0){
currentTime += System.currentTimeMillis() - lastPlayTimeGlobal;
} else {
lastPlayTime = currentTime;
lastPlayTimeGlobal = System.currentTimeMillis();
}
return currentTime * 0.001f; //to float
}
great, this is awesome solution –
Explosion
© 2022 - 2024 — McMap. All rights reserved.