Rafat
Rafat

Reputation: 23

In VLCJ, how can I find a media file's total playtime?

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

Answers (2)

user1540811
user1540811

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

Nguyen Huy Thuy
Nguyen Huy Thuy

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

Related Questions