Difference between revisions of "LibVLC Tutorial 0.9"
Jump to navigation
Jump to search
Line 22: | Line 22: | ||
int main(int argc, char* argv[]) | int main(int argc, char* argv[]) | ||
{ | { | ||
− | char *vlc_args = {"-I", "dummy | + | const char * const vlc_args[] = {"-I", "dummy" }; |
libvlc_exception_t excp; | libvlc_exception_t excp; | ||
libvlc_instance_t * inst; | libvlc_instance_t * inst; | ||
Line 30: | Line 30: | ||
libvlc_exception_init( &excp ); | libvlc_exception_init( &excp ); | ||
/* init vlc modules, should be done only once */ | /* init vlc modules, should be done only once */ | ||
− | inst = libvlc_new( | + | inst = libvlc_new( sizeof(args) / sizeof(args[0]), arg, &excp ); |
quit_on_exception( &excp ); | quit_on_exception( &excp ); | ||
/* Create a new item */ | /* Create a new item */ | ||
− | md = libvlc_media_descriptor_new( | + | md = libvlc_media_descriptor_new( inst, "http://mycool.movie.com/test.mov", &excp ); |
quit_on_exception( &excp ); | quit_on_exception( &excp ); | ||
Line 40: | Line 40: | ||
/* Create a media instance playing environement */ | /* Create a media instance playing environement */ | ||
− | mi = libvlc_media_instance_new_from_media_descriptor( | + | mi = libvlc_media_instance_new_from_media_descriptor( md, &excp ); |
quit_on_exception( &excp ); | quit_on_exception( &excp ); | ||
Line 69: | Line 69: | ||
libvlc_media_instance_release( mi, &excp ); | libvlc_media_instance_release( mi, &excp ); | ||
− | + | libvlc_release( inst, &excp ); | |
+ | quit_on_exception( &excp ); | ||
return 0; | return 0; | ||
} | } |
Revision as of 23:51, 28 November 2007
LibVLC Tutorial
This may work with trunk version, does not work with 0.8.6c
Linking against LibVLC
cc example.c -lvlc-control -o example
Sample LibVLC Code
#include <stdio.h> #include <vlc/libvlc.h> static void quit_on_exception( libvlc_exception_t * excp ) { if( libvlc_exception_raised( &excp ); { fprintf(stderr, "error: %s\n", libvlc_exception_get_message(excp) ); exit(-1); } } int main(int argc, char* argv[]) { const char * const vlc_args[] = {"-I", "dummy" }; libvlc_exception_t excp; libvlc_instance_t * inst; libvlc_media_instance_t *mi; libvlc_media_descriptor_t *md; libvlc_exception_init( &excp ); /* init vlc modules, should be done only once */ inst = libvlc_new( sizeof(args) / sizeof(args[0]), arg, &excp ); quit_on_exception( &excp ); /* Create a new item */ md = libvlc_media_descriptor_new( inst, "http://mycool.movie.com/test.mov", &excp ); quit_on_exception( &excp ); /* XXX: demo art and meta information fetching */ /* Create a media instance playing environement */ mi = libvlc_media_instance_new_from_media_descriptor( md, &excp ); quit_on_exception( &excp ); /* No need to keep the media descriptor now */ libvlc_media_descriptor_release( md ); #if 0 /* This is a non working code that show how to hooks into a window, * if we have a window around */ libvlc_drawable_t drawable = xdrawable; /* or on windows */ libvlc_drawable_t drawable = hwnd; libvlc_media_instance_set_drawable( mi, drawable, &excp ); quit_on_exception( &excp ); #endif /* play the media_instance */ libvlc_media_instance_play( mi, &excp ); quit_on_exception( &excp ); sleep(10); /* Let it play a bit */ /* Stop playing */ libvlc_media_instance_stop( mi, &excp ); /* Free the media_instance */ libvlc_media_instance_release( mi, &excp ); libvlc_release( inst, &excp ); quit_on_exception( &excp ); return 0; }