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 **********************************************************************/
27 #include <vlc_common.h>
28 #include <vlc_mtime.h>
30 static void media_list_add_file_path(libvlc_instance_t *vlc, libvlc_media_list_t *ml, const char * file_path)
32 libvlc_media_t *md = libvlc_media_new (vlc, file_path, &ex);
35 libvlc_media_list_add_media (ml, md, &ex);
38 libvlc_media_release (md);
41 static void test_media_list_player_next(const char** argv, int argc)
43 libvlc_instance_t *vlc;
45 libvlc_media_list_t *ml;
46 libvlc_media_list_player_t *mlp;
48 const char * file = test_default_sample;
50 log ("Testing media player next()\n");
52 libvlc_exception_init (&ex);
53 vlc = libvlc_new (argc, argv, &ex);
56 md = libvlc_media_new (vlc, file, &ex);
59 ml = libvlc_media_list_new (vlc, &ex);
62 mlp = libvlc_media_list_player_new (vlc, &ex);
65 libvlc_media_list_add_media (ml, md, &ex);
69 media_list_add_file_path (vlc, ml, file);
70 media_list_add_file_path (vlc, ml, file);
71 media_list_add_file_path (vlc, ml, file);
73 libvlc_media_list_player_set_media_list (mlp, ml, &ex);
75 libvlc_media_list_player_play_item (mlp, md, &ex);
78 libvlc_media_release (md);
82 libvlc_media_list_player_next (mlp, &ex);
85 libvlc_media_list_player_pause (mlp, &ex);
90 libvlc_media_list_player_next (mlp, &ex);
93 libvlc_media_list_player_stop (mlp, &ex);
98 libvlc_media_list_player_next (mlp, &ex);
101 libvlc_media_list_player_release (mlp);
104 libvlc_release (vlc);
108 static void test_media_list_player_pause_stop(const char** argv, int argc)
110 libvlc_instance_t *vlc;
112 libvlc_media_list_t *ml;
113 libvlc_media_list_player_t *mlp;
115 const char * file = test_default_sample;
117 log ("Testing play and pause of %s using the media list.\n", file);
119 libvlc_exception_init (&ex);
120 vlc = libvlc_new (argc, argv, &ex);
123 md = libvlc_media_new (vlc, file, &ex);
126 ml = libvlc_media_list_new (vlc, &ex);
129 mlp = libvlc_media_list_player_new (vlc, &ex);
131 libvlc_media_list_add_media( ml, md, &ex );
134 libvlc_media_list_player_set_media_list( mlp, ml, &ex );
136 libvlc_media_list_player_play_item( mlp, md, &ex );
139 libvlc_media_list_player_pause (mlp, &ex);
142 libvlc_media_list_player_stop (mlp, &ex);
145 libvlc_media_release (md);
147 libvlc_media_list_player_release (mlp);
150 libvlc_release (vlc);
154 static void test_media_list_player_play_item_at_index(const char** argv, int argc)
156 libvlc_instance_t *vlc;
158 libvlc_media_list_t *ml;
159 libvlc_media_list_player_t *mlp;
161 const char * file = test_default_sample;
163 log ("Testing play_item_at_index of %s using the media list.\n", file);
165 libvlc_exception_init (&ex);
166 vlc = libvlc_new (argc, argv, &ex);
169 md = libvlc_media_new (vlc, file, &ex);
172 ml = libvlc_media_list_new (vlc, &ex);
175 mlp = libvlc_media_list_player_new (vlc, &ex);
177 for (unsigned i = 0; i < 5; i++)
179 libvlc_media_list_add_media( ml, md, &ex );
183 libvlc_media_list_player_set_media_list( mlp, ml, &ex );
185 libvlc_media_list_player_play_item_at_index( mlp, 0, &ex );
188 libvlc_media_list_player_stop (mlp, &ex);
191 libvlc_media_release (md);
194 libvlc_media_list_player_release (mlp);
197 libvlc_release (vlc);
206 test_media_list_player_pause_stop (test_defaults_args, test_defaults_nargs);
207 test_media_list_player_play_item_at_index (test_defaults_args, test_defaults_nargs);
208 test_media_list_player_next (test_defaults_args, test_defaults_nargs);