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 wait_playing(libvlc_media_player_t *mp)
30 state = libvlc_media_player_get_state (mp);
31 } while(state != libvlc_Playing &&
32 state != libvlc_Error &&
33 state != libvlc_Ended );
35 state = libvlc_media_player_get_state (mp);
36 assert(state == libvlc_Playing || state == libvlc_Ended);
39 static void test_media_player_set_media(const char** argv, int argc)
41 const char * file = test_default_sample;
43 log ("Testing set_media\n");
45 libvlc_instance_t *vlc = libvlc_new (argc, argv);
48 libvlc_media_t *md = libvlc_media_new_path (vlc, file);
51 libvlc_media_player_t *mp = libvlc_media_player_new (vlc);
54 libvlc_media_player_set_media (mp, md);
56 libvlc_media_release (md);
58 libvlc_media_player_play (mp);
62 libvlc_media_player_stop (mp);
63 libvlc_media_player_release (mp);
67 static void test_media_player_play_stop(const char** argv, int argc)
69 libvlc_instance_t *vlc;
71 libvlc_media_player_t *mi;
72 const char * file = test_default_sample;
74 log ("Testing play and pause of %s\n", file);
76 vlc = libvlc_new (argc, argv);
79 md = libvlc_media_new_path (vlc, file);
82 mi = libvlc_media_player_new_from_media (md);
85 libvlc_media_release (md);
87 libvlc_media_player_play (mi);
91 libvlc_media_player_stop (mi);
92 libvlc_media_player_release (mi);
96 static void test_media_player_pause_stop(const char** argv, int argc)
98 libvlc_instance_t *vlc;
100 libvlc_media_player_t *mi;
101 const char * file = test_default_sample;
103 log ("Testing pause and stop of %s\n", file);
105 vlc = libvlc_new (argc, argv);
106 assert (vlc != NULL);
108 md = libvlc_media_new_path (vlc, file);
111 mi = libvlc_media_player_new_from_media (md);
114 libvlc_media_release (md);
116 libvlc_media_player_play (mi);
118 log ("Waiting for playing\n");
123 /* This can't work because under some condition (short file, this is the case) this will be
124 * equivalent to a play() */
125 libvlc_media_player_pause (mi);
127 log ("Waiting for pause\n");
132 libvlc_media_player_stop (mi);
133 libvlc_media_player_release (mi);
134 libvlc_release (vlc);
142 test_media_player_set_media (test_defaults_args, test_defaults_nargs);
143 test_media_player_play_stop (test_defaults_args, test_defaults_nargs);
144 test_media_player_pause_stop (test_defaults_args, test_defaults_nargs);