Yuuup
Yuuup

Reputation: 21

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.

Upvotes: 0

Views: 1859

Answers (3)

Mustafa Jamal
Mustafa Jamal

Reputation: 3

this worked for me >> using Version 4.8.2

embeddedMediaPlayer.media().info().duration();

it returns -1 if it can't get the time and the long duration for the video length value.

Upvotes: 0

weilin wang
weilin wang

Reputation: 641

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

Upvotes: 2

caprica
caprica

Reputation: 4146

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 - i.e. if the media has not started playing yet.

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

Upvotes: 1

Related Questions