2 * media_list_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 media_list_add_file_path(libvlc_instance_t *vlc, libvlc_media_list_t *ml, const char * file_path)
28 libvlc_media_t *md = libvlc_media_new (vlc, file_path, &ex);
31 libvlc_media_list_add_media (ml, md, &ex);
34 libvlc_media_release (md);
37 static void test_media_list_player_next(const char** argv, int argc)
39 libvlc_instance_t *vlc;
41 libvlc_media_list_t *ml;
42 libvlc_media_list_player_t *mlp;
44 const char * file = test_default_sample;
46 log ("Testing media player next()\n");
48 libvlc_exception_init (&ex);
49 vlc = libvlc_new (argc, argv, &ex);
52 md = libvlc_media_new (vlc, file, &ex);
55 ml = libvlc_media_list_new (vlc, &ex);
58 mlp = libvlc_media_list_player_new (vlc, &ex);
61 libvlc_media_list_add_media (ml, md, &ex);
65 media_list_add_file_path (vlc, ml, file);
66 media_list_add_file_path (vlc, ml, file);
67 media_list_add_file_path (vlc, ml, file);
69 libvlc_media_list_player_set_media_list (mlp, ml, &ex);
71 libvlc_media_list_player_play_item (mlp, md, &ex);
74 libvlc_media_release (md);
78 libvlc_media_list_player_next (mlp, &ex);
81 libvlc_media_list_player_pause (mlp, &ex);
86 libvlc_media_list_player_next (mlp, &ex);
89 libvlc_media_list_player_stop (mlp, &ex);
94 libvlc_media_list_player_next (mlp, &ex);
97 libvlc_media_list_player_release (mlp);
100 libvlc_release (vlc);
104 static void test_media_list_player_pause_stop(const char** argv, int argc)
106 libvlc_instance_t *vlc;
108 libvlc_media_list_t *ml;
109 libvlc_media_list_player_t *mlp;
111 const char * file = test_default_sample;
113 log ("Testing play and pause of %s using the media list.\n", file);
115 libvlc_exception_init (&ex);
116 vlc = libvlc_new (argc, argv, &ex);
119 md = libvlc_media_new (vlc, file, &ex);
122 ml = libvlc_media_list_new (vlc, &ex);
125 mlp = libvlc_media_list_player_new (vlc, &ex);
127 libvlc_media_list_add_media( ml, md, &ex );
130 libvlc_media_list_player_set_media_list( mlp, ml, &ex );
132 libvlc_media_list_player_play_item( mlp, md, &ex );
135 libvlc_media_list_player_pause (mlp, &ex);
138 libvlc_media_list_player_stop (mlp, &ex);
141 libvlc_media_release (md);
143 libvlc_media_list_player_release (mlp);
146 libvlc_release (vlc);
150 static void test_media_list_player_play_item_at_index(const char** argv, int argc)
152 libvlc_instance_t *vlc;
154 libvlc_media_list_t *ml;
155 libvlc_media_list_player_t *mlp;
157 const char * file = test_default_sample;
159 log ("Testing play_item_at_index of %s using the media list.\n", file);
161 libvlc_exception_init (&ex);
162 vlc = libvlc_new (argc, argv, &ex);
165 md = libvlc_media_new (vlc, file, &ex);
168 ml = libvlc_media_list_new (vlc, &ex);
171 mlp = libvlc_media_list_player_new (vlc, &ex);
173 libvlc_media_list_add_media( ml, md, &ex );
176 libvlc_media_list_player_set_media_list( mlp, ml, &ex );
178 libvlc_media_list_player_play_item_at_index( mlp, 0, &ex );
181 libvlc_media_list_player_stop (mlp, &ex);
184 libvlc_media_release (md);
187 libvlc_media_list_player_release (mlp);
190 libvlc_release (vlc);
199 test_media_list_player_pause_stop (test_defaults_args, test_defaults_nargs);
200 test_media_list_player_play_item_at_index (test_defaults_args, test_defaults_nargs);
201 if(0) // Core hangs here, because it doesn't support callback removal from callbacks (variable)
202 test_media_list_player_next (test_defaults_args, test_defaults_nargs);