]> git.sesse.net Git - vlc/blob - test/libvlc_sample.c
Cosmetics.
[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     fprintf (stderr, "Playing\n");
24     libvlc_playlist_play( p_instance1, 0, 0,NULL, NULL );
25     fprintf (stderr, "Playback started\n");
26
27     while( 1 )
28     {
29         sleep( 1 );
30         libvlc_exception_init( &exception );
31         p_input = libvlc_playlist_get_input( p_instance1, &exception );
32
33         if( libvlc_exception_raised( &exception ) )
34         {
35            if( b_started == 1 )
36                break;
37            else
38                continue;
39         }
40         else
41         {
42             b_started = 1;
43         }
44
45         libvlc_toggle_fullscreen( p_input, &exception );
46         if( libvlc_exception_raised( &exception ) )
47         {
48             fprintf( stderr, "EX : %s\n", libvlc_exception_get_message( &exception ) );
49         }
50         fprintf( stderr, "Length %lli - Time %lli - Full screen %i\n", 
51                               libvlc_input_get_length( p_input, NULL ),
52                               libvlc_input_get_time( p_input, NULL ), 
53                               libvlc_get_fullscreen( p_input, NULL ) );
54         libvlc_input_free( p_input );
55     }
56
57     libvlc_destroy( p_instance1 );
58        
59     return 0;
60 }