Reputation: 23
I'm writing a media player in Java using VLCJ. I'd like to be able to seek a JSlider through to the end of a media file, but for that I'll need to know its total playtime.
How can I obtain the total playtime of a media file using VLCJ?
Upvotes: 0
Views: 2331
Reputation: 33
You should be able to simply use the getLength()
method in your MediaPlayer
to get total playtime for current playing file. This will returns total length of media in milliseconds.
Upvotes: 2
Reputation: 11
You can have a slider with Min = 0, Max = 100 (100%) then override positionChanged then implement as below:
@Override
public void positionChanged(MediaPlayer mp, float f) {
int iPos = (int)(f * 100.0);
slider.setValue(iPos);
}
Upvotes: 1