Page 1 of 1

How to get the duration of videos?

Posted: 18 Mar 2008 09:21
by emre
Hi;
I found vlc 1 week ago and I like vlc very very much :D and i decided to write my own vlc player for fun :) I made a simple panel, slider and play,stop, pause buttons. But i can not get the duration of videos. I looked the libvlc.h documentation for the length of media files, i found a function "int libvlc_vlm_get_media_length()". Although it says that this function is implemented under the libvlc.h file, in the source code libvlc.h file does not contain a function like that. Is there a way to get the duration(total time) of the videos? I'd appreciate all the help you can provide me with, and thank you for your time in advance.

/////
Pls i need help: There is a simple code below, but when i want to return the duration or time of the instances its always return -1.


player:: play video() {
......
// in is the libvlc_instance.
libvlc_playlist_add(in, file.c_str(), NULL,&e);

libvlc_media_descriptor_t* m= libvlc_media_descriptor_new(in, file2.c_str(), &e);

libvlc_media_instance_t* m2 =libvlc_media_instance_new_from_media_descriptor(m, &e);

cout<<libvlc_media_descriptor_get_duration(m, &e)<<endl;
cout<<libvlc_media_instance_get_time(m2, &e)<< endl;
....
}