(sorry for my bad english !)
I discovered libVLC yesterday and I tried it.
However I have a problem. I would get the duration of a media, but this code returns -1 two times. In the documentation, it is written that -1 means there is a problem. But I don't know where...
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <vlc/vlc.h>
#include <unistd.h>
int main(int argc, char* argv[])
{
libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;
/* Load the VLC engine */
inst = libvlc_new (0, NULL);
if(inst == NULL)
return 0;
/* Create a new item */
m = libvlc_media_new_path(inst, "C:\\Users\\Philippe\\Desktop\\Wildlife.wmv");
if(m == NULL)
return 0;
libvlc_time_t duration;
duration = libvlc_media_get_duration(m);
printf("%d", duration);
/* Create a media player playing environement */
mp = libvlc_media_player_new_from_media (m);
duration = libvlc_media_player_get_length(mp);
printf("\n%d", duration);
/* No need to keep the media now */
libvlc_media_release (m);
/* Free the media_player */
libvlc_media_player_release (mp);
libvlc_release (inst);
printf("\nOk");
return 0;
}