]> git.sesse.net Git - vlc/blob - test/libvlc_sample.c
Merge 0.8.5-api changes
[vlc] / test / libvlc_sample.c
1 #include <stdio.h>
2 #include <time.h>
3 #include <vlc/libvlc.h>
4
5 int main(int argc, char **argv)
6 {
7     libvlc_instance_t *p_instance1;
8     libvlc_exception_t exception;
9     libvlc_input_t    *p_input;
10     int b_started = 0;
11
12     libvlc_exception_init( &exception );
13     
14     p_instance1 = libvlc_new( argc,argv, &exception );
15
16     if( libvlc_exception_raised( &exception ) )
17     {
18         fprintf( stderr, "FATAL: %s\n",
19                         libvlc_exception_get_message( &exception ) );
20         return 0; 
21     }
22
23     libvlc_playlist_play( p_instance1, 0,NULL, NULL );
24
25     while( 1 )
26     {
27         sleep( 1 );
28         libvlc_exception_init( &exception );
29         p_input = libvlc_playlist_get_input( p_instance1, &exception );
30
31         if( libvlc_exception_raised( &exception ) )
32         {
33            if( b_started == 1 )
34                break;
35            else
36                continue;
37         }
38         else
39         {
40             b_started = 1;
41         }
42         
43         fprintf( stderr, "Length %lli - Time %lli\n", 
44                               libvlc_input_get_length( p_input, NULL ),
45                               libvlc_input_get_time( p_input, NULL ) );
46         libvlc_input_free( p_input );
47     }
48
49     libvlc_destroy( p_instance1 );
50        
51     return 0;
52 }