Page 1 of 1

Get Duration of media

Posted: 18 Nov 2010 11:33
by ronins
Hello again,us I see the mediaPlayer.getlength() has some problems.
If the file that i have choose isn't playing the getlength() gives me 0 length.When the file that i have choose starts playing the length of file is correct.
Any way to take the duration of the media file that i have choose before playing the file?
The mediaPlayer.prepareMedia() what stands for?with this command the mediaplayer() loads the file for playing and waits for play command???

Re: Get Duration of media

Posted: 18 Nov 2010 14:53
by sherington
Hello again,us I see the mediaPlayer.getlength() has some problems.
If the file that i have choose isn't playing the getlength() gives me 0 length.When the file that i have choose starts playing the length of file is correct.
Any way to take the duration of the media file that i have choose before playing the file?
You're talking about Java bindings, right?

mediaPlayer.getLength() simply calls the native libvlc_media_player_get_length() - the 'problem' you are describing is just how it works.

I don't think you can get the behaviour you are asking for. I think it's not so easy to know in advance how to get the length for all the various different types of video data.

Hopefully someone else knows better.
The mediaPlayer.prepareMedia() what stands for?with this command the mediaplayer() loads the file for playing and waits for play command???
Some users asked for a feature whereby they could 'prepare' the media for playing, without actually playing it. That's what this prepareMedia() is for, rather than playMedia(). That's the only difference.