2 * media_player.c - libvlc smoke test
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. *
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. *
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 **********************************************************************/
26 static void test_media_player_set_media(const char** argv, int argc)
28 const char * file = test_default_sample;
30 log ("Testing set_media\n");
32 libvlc_instance_t *vlc = libvlc_new (argc, argv);
35 libvlc_media_t *md = libvlc_media_new_path (vlc, file);
38 libvlc_media_player_t *mp = libvlc_media_player_new (vlc);
41 libvlc_media_player_set_media (mp, md);
43 libvlc_media_release (md);
45 libvlc_media_player_play (mp);
47 /* Wait a correct state */
50 state = libvlc_media_player_get_state (mp);
51 } while(state != libvlc_Playing &&
52 state != libvlc_Error &&
53 state != libvlc_Ended );
55 assert(state == libvlc_Playing || state == libvlc_Ended);
57 libvlc_media_player_stop (mp);
58 libvlc_media_player_release (mp);
62 static void test_media_player_play_stop(const char** argv, int argc)
64 libvlc_instance_t *vlc;
66 libvlc_media_player_t *mi;
67 const char * file = test_default_sample;
69 log ("Testing play and pause of %s\n", file);
71 vlc = libvlc_new (argc, argv);
74 md = libvlc_media_new_path (vlc, file);
77 mi = libvlc_media_player_new_from_media (md);
80 libvlc_media_release (md);
82 libvlc_media_player_play (mi);
84 /* Wait a correct state */
87 state = libvlc_media_player_get_state (mi);
88 } while( state != libvlc_Playing &&
89 state != libvlc_Error &&
90 state != libvlc_Ended );
92 assert( state == libvlc_Playing || state == libvlc_Ended );
94 libvlc_media_player_stop (mi);
95 libvlc_media_player_release (mi);
99 static void test_media_player_pause_stop(const char** argv, int argc)
101 libvlc_instance_t *vlc;
103 libvlc_media_player_t *mi;
104 const char * file = test_default_sample;
106 log ("Testing pause and stop of %s\n", file);
108 vlc = libvlc_new (argc, argv);
109 assert (vlc != NULL);
111 md = libvlc_media_new_path (vlc, file);
114 mi = libvlc_media_player_new_from_media (md);
117 libvlc_media_release (md);
119 libvlc_media_player_play (mi);
121 log ("Waiting for playing\n");
123 /* Wait a correct state */
124 libvlc_state_t state;
126 state = libvlc_media_player_get_state (mi);
127 } while( state != libvlc_Playing &&
128 state != libvlc_Error &&
129 state != libvlc_Ended );
131 assert( state == libvlc_Playing || state == libvlc_Ended );
134 /* This can't work because under some condition (short file, this is the case) this will be
135 * equivalent to a play() */
136 libvlc_media_player_pause (mi);
138 log ("Waiting for pause\n");
140 /* Wait a correct state */
142 state = libvlc_media_player_get_state (mi);
143 } while( state != libvlc_Paused &&
144 state != libvlc_Error &&
145 state != libvlc_Ended );
147 assert( state == libvlc_Paused || state == libvlc_Ended );
150 libvlc_media_player_stop (mi);
151 libvlc_media_player_release (mi);
152 libvlc_release (vlc);
160 test_media_player_set_media (test_defaults_args, test_defaults_nargs);
161 test_media_player_play_stop (test_defaults_args, test_defaults_nargs);
162 test_media_player_pause_stop (test_defaults_args, test_defaults_nargs);