简体   繁体   中英

VLCJ Get Video Time

I have the following code and i want to get the time of my Video but it returns -1. Anyone know why?

long video= ourMediaPlayer.getMediaPlayer().getLength();

I have tried with getTime() instead of getLength but it returns -1.

Thanks for your help.

get current video time

embeddedMediaPlayer.status().time();

get video duration

embeddedMediaPlayer.status().length();

get current video position

embeddedMediaPlayer.status().position()

note:my vlcj version is 4.4.4

The getLength() method returns -1 if the length is unknown. It depends on the type of media, but sometimes the length is not known until some time after the media starts playing.

Similarly, getTime() returns -1 for the time (number of milliseconds from the start of the media) if the time is not known - ie if the media has not started playing yet.

This is simply how the underlying native library works, and therefore how vlcj works also.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM