Initial commit for EPG class for EPG Viewing
[vlc/solaris.git] / test / libvlc / media_player.c
blob8ebde89d2bed30061bc25af977ede7b4e7442a38
1 /*
2 * media_player.c - libvlc smoke test
4 * $Id$
5 */
7 /**********************************************************************
8 * Copyright (C) 2007 RĂ©mi Denis-Courmont. *
9 * This program is free software; you can redistribute and/or modify *
10 * it under the terms of the GNU General Public License as published *
11 * by the Free Software Foundation; version 2 of the license, or (at *
12 * your option) any later version. *
13 * *
14 * This program is distributed in the hope that it will be useful, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
17 * See the GNU General Public License for more details. *
18 * *
19 * You should have received a copy of the GNU General Public License *
20 * along with this program; if not, you can get it from: *
21 * http://www.gnu.org/copyleft/gpl.html *
22 **********************************************************************/
24 #include "test.h"
26 static void test_media_player_play_stop(const char** argv, int argc)
28 libvlc_instance_t *vlc;
29 libvlc_media_t *md;
30 libvlc_media_player_t *mi;
31 const char * file = test_default_sample;
33 log ("Testing play and pause of %s\n", file);
35 libvlc_exception_init (&ex);
36 vlc = libvlc_new (argc, argv, &ex);
37 catch ();
39 md = libvlc_media_new (vlc, file, &ex);
40 catch ();
42 mi = libvlc_media_player_new_from_media (md, &ex);
43 catch ();
45 libvlc_media_release (md);
47 libvlc_media_player_play (mi, &ex);
48 catch ();
50 /* Wait a correct state */
51 libvlc_state_t state;
52 do {
53 state = libvlc_media_player_get_state (mi);
54 } while( state != libvlc_Playing &&
55 state != libvlc_Error &&
56 state != libvlc_Ended );
58 assert( state == libvlc_Playing || state == libvlc_Ended );
60 libvlc_media_player_stop (mi);
61 libvlc_media_player_release (mi);
62 libvlc_release (vlc);
65 static void test_media_player_pause_stop(const char** argv, int argc)
67 libvlc_instance_t *vlc;
68 libvlc_media_t *md;
69 libvlc_media_player_t *mi;
70 const char * file = test_default_sample;
72 log ("Testing pause and stop of %s\n", file);
74 libvlc_exception_init (&ex);
75 vlc = libvlc_new (argc, argv, &ex);
76 catch ();
78 md = libvlc_media_new (vlc, file, &ex);
79 catch ();
81 mi = libvlc_media_player_new_from_media (md, &ex);
82 catch ();
84 libvlc_media_release (md);
86 libvlc_media_player_play (mi, &ex);
87 catch ();
89 log ("Waiting for playing\n");
91 /* Wait a correct state */
92 libvlc_state_t state;
93 do {
94 state = libvlc_media_player_get_state (mi);
95 catch ();
96 } while( state != libvlc_Playing &&
97 state != libvlc_Error &&
98 state != libvlc_Ended );
100 assert( state == libvlc_Playing || state == libvlc_Ended );
102 #if 0
103 /* This can't work because under some condition (short file, this is the case) this will be
104 * equivalent to a play() */
105 libvlc_media_player_pause (mi, &ex);
106 catch();
108 log ("Waiting for pause\n");
110 /* Wait a correct state */
111 do {
112 state = libvlc_media_player_get_state (mi);
113 } while( state != libvlc_Paused &&
114 state != libvlc_Error &&
115 state != libvlc_Ended );
117 assert( state == libvlc_Paused || state == libvlc_Ended );
118 #endif
120 libvlc_media_player_stop (mi);
121 libvlc_media_player_release (mi);
122 libvlc_release (vlc);
126 int main (void)
128 test_init();
130 test_media_player_play_stop (test_defaults_args, test_defaults_nargs);
131 test_media_player_pause_stop (test_defaults_args, test_defaults_nargs);
133 return 0;