Difference between revisions of "LibVLC Tutorial 0.9"
Jump to navigation
Jump to search
Pdherbemont (talk | contribs) (→Sample LibVLC Code: As reported by ericchen.) |
Pdherbemont (talk | contribs) (→Sample LibVLC Code: Code factorization) |
||
Line 8: | Line 8: | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <vlc/libvlc.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[]) | int main(int argc, char* argv[]) | ||
{ | { | ||
Line 20: | Line 28: | ||
/* init vlc modules, should be done only once */ | /* init vlc modules, should be done only once */ | ||
inst = libvlc_new( args, 3, &excp ); | inst = libvlc_new( args, 3, &excp ); | ||
− | + | quit_on_exception( &excp ); | |
− | + | ||
− | |||
− | |||
− | |||
− | |||
/* Create a new item */ | /* Create a new item */ | ||
md = libvlc_media_descriptor_new( int, "http://mycool.movie.com/test.mov", &excp ); | md = libvlc_media_descriptor_new( int, "http://mycool.movie.com/test.mov", &excp ); | ||
− | + | quit_on_exception( &excp ); | |
− | |||
− | |||
− | |||
− | |||
/* XXX: demo art and meta information fetching */ | /* XXX: demo art and meta information fetching */ | ||
Line 38: | Line 38: | ||
/* Create a media instance playing environement */ | /* Create a media instance playing environement */ | ||
mi = libvlc_media_instance_new_from_media_descriptor( int, md, &excp ); | mi = libvlc_media_instance_new_from_media_descriptor( int, md, &excp ); | ||
− | + | quit_on_exception( &excp ); | |
− | |||
− | |||
− | |||
− | |||
/* No need to keep the media descriptor now */ | /* No need to keep the media descriptor now */ | ||
Line 51: | Line 47: | ||
/* play the media_instance */ | /* play the media_instance */ | ||
libvlc_media_instance_play( mi, &excp ); | libvlc_media_instance_play( mi, &excp ); | ||
− | + | quit_on_exception( &excp ); | |
− | |||
− | |||
− | |||
− | |||
sleep(10); /* Let it play a bit */ | sleep(10); /* Let it play a bit */ |
Revision as of 14:39, 13 August 2007
LibVLC Tutorial
Linging against LibVLC
todo
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[]) { char *vlc_args = {"-I", "dummy", "--module-path=/set/your/path/to/libvlc/module"}; 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( args, 3, &excp ); quit_on_exception( &excp );
/* Create a new item */ md = libvlc_media_descriptor_new( int, "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( int, md, &excp ); quit_on_exception( &excp ); /* No need to keep the media descriptor now */ libvlc_media_descriptor_release( md ); /* libvlc_media_instance_set_drawable() --not working yet */ /* 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_instance_destroy( inst ); return 0; }