2008-04-09 11:45:35 +02:00
|
|
|
/*
|
|
|
|
* media_list_player.c - libvlc smoke test
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* Copyright (C) 2007 Rémi Denis-Courmont. *
|
|
|
|
* This program is free software; you can redistribute and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published *
|
|
|
|
* by the Free Software Foundation; version 2 of the license, or (at *
|
|
|
|
* your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
|
|
|
* See the GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, you can get it from: *
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html *
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#include "test.h"
|
|
|
|
|
2009-06-05 09:50:42 +02:00
|
|
|
// For msleep
|
|
|
|
#include <vlc_common.h>
|
|
|
|
#include <vlc_mtime.h>
|
|
|
|
|
2009-08-24 17:14:02 +02:00
|
|
|
#include "libvlc_additions.h"
|
2009-05-21 08:34:03 +02:00
|
|
|
|
2010-01-07 14:07:00 +01:00
|
|
|
/*
|
2009-08-27 00:03:59 +02:00
|
|
|
HACK - FIX ME
|
|
|
|
This allows for the direct addition of subitems in the playback options test.
|
|
|
|
This would not be necessary if there were an add subitems function.
|
|
|
|
*/
|
|
|
|
#include "../../src/control/media_internal.h"
|
|
|
|
|
2009-08-24 17:14:02 +02:00
|
|
|
struct check_items_order_data {
|
|
|
|
bool done_playing;
|
|
|
|
unsigned count;
|
|
|
|
unsigned index;
|
|
|
|
void * items[16];
|
|
|
|
};
|
2009-05-21 08:34:03 +02:00
|
|
|
|
2009-08-24 17:14:02 +02:00
|
|
|
static inline void check_data_init(struct check_items_order_data *check)
|
|
|
|
{
|
|
|
|
check->index = 0;
|
|
|
|
check->count = 0;
|
|
|
|
check->done_playing = false;
|
2009-08-20 01:02:56 +02:00
|
|
|
}
|
|
|
|
|
2009-08-24 17:14:02 +02:00
|
|
|
static inline void queue_expected_item(struct check_items_order_data *check, void *item)
|
|
|
|
{
|
|
|
|
assert(check->count < 16);
|
|
|
|
check->items[check->count] = item;
|
|
|
|
check->count++;
|
|
|
|
}
|
2009-08-20 01:02:56 +02:00
|
|
|
|
2009-08-24 17:14:02 +02:00
|
|
|
static inline void wait_queued_items(struct check_items_order_data *check)
|
2009-08-20 01:02:56 +02:00
|
|
|
{
|
2009-08-24 17:14:02 +02:00
|
|
|
// Wait dummily for check_items_order_callback() to flag 'done_playing':
|
|
|
|
while (!check->done_playing)
|
|
|
|
msleep(100000);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_items_order_callback(const libvlc_event_t * p_event, void * user_data)
|
|
|
|
{
|
|
|
|
struct check_items_order_data *checks = user_data;
|
2009-08-20 01:02:56 +02:00
|
|
|
libvlc_media_t *md = p_event->u.media_list_player_next_item_set.item;
|
2009-08-24 17:14:02 +02:00
|
|
|
assert(checks->index < checks->count);
|
|
|
|
if (checks->items[checks->index] != md)
|
|
|
|
{
|
2009-10-05 21:06:14 +02:00
|
|
|
char *title = libvlc_media_get_meta(md, libvlc_meta_Title);
|
2009-08-24 17:14:02 +02:00
|
|
|
log ("Got items %s\n", title);
|
|
|
|
free(title);
|
|
|
|
}
|
|
|
|
assert(checks->items[checks->index] == md);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2009-10-05 21:06:14 +02:00
|
|
|
char *title = libvlc_media_get_meta(md, libvlc_meta_Title);
|
2009-08-24 17:14:02 +02:00
|
|
|
log ("Item %d '%s' was correctly queued\n", checks->index, title);
|
|
|
|
free(title);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2009-08-24 17:14:02 +02:00
|
|
|
if (checks->index == (checks->count - 1))
|
|
|
|
{
|
|
|
|
log ("Done playing with success\n");
|
|
|
|
checks->done_playing = true;
|
|
|
|
}
|
|
|
|
checks->index++;
|
2009-08-20 01:02:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_media_list_player_items_queue(const char** argv, int argc)
|
|
|
|
{
|
|
|
|
libvlc_instance_t *vlc;
|
|
|
|
libvlc_media_t *md;
|
|
|
|
libvlc_media_list_t *ml;
|
|
|
|
libvlc_media_list_player_t *mlp;
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2009-08-20 01:02:56 +02:00
|
|
|
const char * file = test_default_sample;
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2009-08-20 01:02:56 +02:00
|
|
|
log ("Testing media player item queue-ing\n");
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-31 22:40:16 +01:00
|
|
|
vlc = libvlc_new (argc, argv);
|
|
|
|
assert (vlc != NULL);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
md = libvlc_media_new_path (vlc, file);
|
|
|
|
assert(md);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-28 21:49:15 +01:00
|
|
|
ml = libvlc_media_list_new (vlc);
|
|
|
|
assert (ml != NULL);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
mlp = libvlc_media_list_player_new (vlc);
|
|
|
|
assert(mlp);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_add_media (ml, md);
|
2009-08-24 17:14:02 +02:00
|
|
|
|
|
|
|
static struct check_items_order_data check;
|
|
|
|
check_data_init(&check);
|
|
|
|
queue_expected_item(&check, md);
|
2009-08-20 01:02:56 +02:00
|
|
|
|
|
|
|
// Add three more media
|
2009-08-24 17:14:02 +02:00
|
|
|
queue_expected_item(&check, media_list_add_file_path (vlc, ml, file));
|
|
|
|
queue_expected_item(&check, media_list_add_file_path (vlc, ml, file));
|
|
|
|
queue_expected_item(&check, media_list_add_file_path (vlc, ml, file));
|
|
|
|
|
|
|
|
// Add a node
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_t *node = libvlc_media_new_as_node(vlc, "node");
|
|
|
|
assert(node);
|
|
|
|
libvlc_media_list_add_media(ml, node);
|
2009-08-24 17:14:02 +02:00
|
|
|
queue_expected_item(&check, node);
|
|
|
|
|
|
|
|
// Add items to that node
|
2009-10-05 21:06:14 +02:00
|
|
|
libvlc_media_list_t *subitems = libvlc_media_subitems(node);
|
2009-08-24 17:14:02 +02:00
|
|
|
queue_expected_item(&check, media_list_add_file_path(vlc, subitems, file));
|
|
|
|
queue_expected_item(&check, media_list_add_file_path(vlc, subitems, file));
|
|
|
|
queue_expected_item(&check, media_list_add_file_path(vlc, subitems, file));
|
|
|
|
libvlc_media_list_release(subitems);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_set_media_list (mlp, ml);
|
2009-08-20 01:02:56 +02:00
|
|
|
|
|
|
|
libvlc_event_manager_t * em = libvlc_media_list_player_event_manager(mlp);
|
2010-01-25 18:19:19 +01:00
|
|
|
int val = libvlc_event_attach(em, libvlc_MediaListPlayerNextItemSet,
|
|
|
|
check_items_order_callback, &check);
|
|
|
|
assert(val == 0);
|
2009-08-20 01:02:56 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_play(mlp);
|
2009-08-20 01:02:56 +02:00
|
|
|
|
2009-08-24 17:14:02 +02:00
|
|
|
// Wait until all item are read
|
|
|
|
wait_queued_items(&check);
|
2009-08-20 01:02:56 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_stop (mlp);
|
|
|
|
while (libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:20:12 +01:00
|
|
|
|
2009-08-20 01:02:56 +02:00
|
|
|
libvlc_media_list_player_release (mlp);
|
|
|
|
libvlc_release (vlc);
|
2009-05-21 08:34:03 +02:00
|
|
|
}
|
|
|
|
|
2009-08-27 00:03:59 +02:00
|
|
|
static void test_media_list_player_previous(const char** argv, int argc)
|
|
|
|
{
|
|
|
|
libvlc_instance_t *vlc;
|
|
|
|
libvlc_media_t *md;
|
|
|
|
libvlc_media_list_t *ml;
|
|
|
|
libvlc_media_list_player_t *mlp;
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2009-08-27 00:03:59 +02:00
|
|
|
const char * file = test_default_sample;
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2009-08-27 00:03:59 +02:00
|
|
|
log ("Testing media player previous()\n");
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-31 22:40:16 +01:00
|
|
|
vlc = libvlc_new (argc, argv);
|
|
|
|
assert (vlc != NULL);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
md = libvlc_media_new_path (vlc, file);
|
|
|
|
assert(md);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-28 21:49:15 +01:00
|
|
|
ml = libvlc_media_list_new (vlc);
|
|
|
|
assert (ml != NULL);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
mlp = libvlc_media_list_player_new (vlc);
|
|
|
|
assert(mlp);;
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_add_media (ml, md);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
|
|
|
// Add three media
|
|
|
|
media_list_add_file_path (vlc, ml, file);
|
|
|
|
media_list_add_file_path (vlc, ml, file);
|
|
|
|
media_list_add_file_path (vlc, ml, file);
|
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_set_media_list (mlp, ml);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_play_item (mlp, md);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-18 09:06:49 +01:00
|
|
|
libvlc_media_release (md);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_previous (mlp);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:06:49 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_pause (mlp);
|
|
|
|
libvlc_media_list_player_previous (mlp);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:06:49 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_stop (mlp);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:20:12 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_previous (mlp);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:06:49 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_stop (mlp);
|
2010-01-07 14:11:13 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:20:12 +01:00
|
|
|
|
2009-08-27 00:03:59 +02:00
|
|
|
libvlc_media_list_player_release (mlp);
|
|
|
|
libvlc_release (vlc);
|
|
|
|
}
|
|
|
|
|
2009-05-21 08:34:03 +02:00
|
|
|
static void test_media_list_player_next(const char** argv, int argc)
|
|
|
|
{
|
|
|
|
libvlc_instance_t *vlc;
|
|
|
|
libvlc_media_t *md;
|
|
|
|
libvlc_media_list_t *ml;
|
|
|
|
libvlc_media_list_player_t *mlp;
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2009-05-21 08:34:03 +02:00
|
|
|
const char * file = test_default_sample;
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2009-05-21 08:34:03 +02:00
|
|
|
log ("Testing media player next()\n");
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-31 22:40:16 +01:00
|
|
|
vlc = libvlc_new (argc, argv);
|
|
|
|
assert (vlc != NULL);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
md = libvlc_media_new_path (vlc, file);
|
|
|
|
assert(md);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-28 21:49:15 +01:00
|
|
|
ml = libvlc_media_list_new (vlc);
|
|
|
|
assert (ml != NULL);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
mlp = libvlc_media_list_player_new (vlc);
|
|
|
|
assert(mlp);
|
2009-05-21 08:34:03 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_add_media (ml, md);
|
2009-05-21 08:34:03 +02:00
|
|
|
|
|
|
|
// Add three media
|
|
|
|
media_list_add_file_path (vlc, ml, file);
|
|
|
|
media_list_add_file_path (vlc, ml, file);
|
|
|
|
media_list_add_file_path (vlc, ml, file);
|
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_set_media_list (mlp, ml);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_play_item (mlp, md);
|
2009-05-21 08:34:03 +02:00
|
|
|
|
|
|
|
libvlc_media_release (md);
|
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_next (mlp);
|
2009-05-21 08:34:03 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:06:49 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_pause (mlp);
|
|
|
|
libvlc_media_list_player_next (mlp);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:06:49 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_stop (mlp);
|
2009-05-21 08:34:03 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:20:12 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_next (mlp);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:06:49 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_stop (mlp);
|
|
|
|
while (libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:20:12 +01:00
|
|
|
|
2009-05-21 08:34:03 +02:00
|
|
|
libvlc_media_list_player_release (mlp);
|
|
|
|
libvlc_release (vlc);
|
|
|
|
}
|
|
|
|
|
2008-04-09 11:45:35 +02:00
|
|
|
static void test_media_list_player_pause_stop(const char** argv, int argc)
|
|
|
|
{
|
|
|
|
libvlc_instance_t *vlc;
|
|
|
|
libvlc_media_t *md;
|
|
|
|
libvlc_media_list_t *ml;
|
|
|
|
libvlc_media_list_player_t *mlp;
|
|
|
|
|
|
|
|
const char * file = test_default_sample;
|
|
|
|
|
|
|
|
log ("Testing play and pause of %s using the media list.\n", file);
|
|
|
|
|
2010-01-31 22:40:16 +01:00
|
|
|
vlc = libvlc_new (argc, argv);
|
|
|
|
assert (vlc != NULL);
|
2008-04-09 11:45:35 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
md = libvlc_media_new_path (vlc, file);
|
|
|
|
assert(md);
|
2008-04-09 11:45:35 +02:00
|
|
|
|
2010-01-28 21:49:15 +01:00
|
|
|
ml = libvlc_media_list_new (vlc);
|
|
|
|
assert (ml != NULL);
|
2008-04-09 11:45:35 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
mlp = libvlc_media_list_player_new (vlc);
|
|
|
|
assert(mlp);
|
2008-04-09 11:45:35 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_add_media( ml, md);
|
2008-04-09 11:45:35 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_set_media_list( mlp, ml );
|
2008-04-09 11:45:35 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_play_item( mlp, md );
|
2008-04-09 11:45:35 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:06:49 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_pause (mlp);
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_stop (mlp);
|
2008-04-09 11:45:35 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:20:12 +01:00
|
|
|
|
2008-04-09 11:45:35 +02:00
|
|
|
libvlc_media_release (md);
|
|
|
|
libvlc_media_list_player_release (mlp);
|
|
|
|
libvlc_release (vlc);
|
|
|
|
}
|
|
|
|
|
2008-06-29 14:34:55 +02:00
|
|
|
static void test_media_list_player_play_item_at_index(const char** argv, int argc)
|
|
|
|
{
|
|
|
|
libvlc_instance_t *vlc;
|
|
|
|
libvlc_media_t *md;
|
|
|
|
libvlc_media_list_t *ml;
|
|
|
|
libvlc_media_list_player_t *mlp;
|
|
|
|
|
|
|
|
const char * file = test_default_sample;
|
|
|
|
|
2009-05-21 07:07:25 +02:00
|
|
|
log ("Testing play_item_at_index of %s using the media list.\n", file);
|
2008-06-29 14:34:55 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
vlc = libvlc_new (argc, argv);
|
2010-01-31 22:40:16 +01:00
|
|
|
assert (vlc != NULL);
|
2008-06-29 14:34:55 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
md = libvlc_media_new_path (vlc, file);
|
|
|
|
assert(md);
|
2008-06-29 14:34:55 +02:00
|
|
|
|
2010-01-28 21:49:15 +01:00
|
|
|
ml = libvlc_media_list_new (vlc);
|
|
|
|
assert (ml != NULL);
|
2008-06-29 14:34:55 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
mlp = libvlc_media_list_player_new (vlc);
|
|
|
|
assert(mlp);
|
2008-06-29 14:34:55 +02:00
|
|
|
|
2009-06-01 17:31:28 +02:00
|
|
|
for (unsigned i = 0; i < 5; i++)
|
|
|
|
{
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_add_media( ml, md );
|
2009-06-01 17:31:28 +02:00
|
|
|
}
|
2008-06-29 14:34:55 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_set_media_list( mlp, ml );
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_play_item_at_index( mlp, 0 );
|
2008-06-29 14:34:55 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:06:49 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_stop (mlp);
|
2008-06-29 14:34:55 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:20:12 +01:00
|
|
|
|
2008-06-29 14:34:55 +02:00
|
|
|
libvlc_media_release (md);
|
|
|
|
libvlc_media_list_player_release (mlp);
|
|
|
|
libvlc_release (vlc);
|
|
|
|
}
|
|
|
|
|
2009-08-27 00:03:59 +02:00
|
|
|
static void test_media_list_player_playback_options (const char** argv, int argc)
|
|
|
|
{
|
|
|
|
libvlc_instance_t *vlc;
|
|
|
|
libvlc_media_t *md;
|
|
|
|
libvlc_media_t *md2;
|
|
|
|
libvlc_media_t *md3;
|
|
|
|
libvlc_media_t *md4;
|
|
|
|
libvlc_media_t *md5;
|
|
|
|
libvlc_media_list_t *ml;
|
|
|
|
libvlc_media_list_t *ml2;
|
|
|
|
libvlc_media_list_t *ml3;
|
|
|
|
libvlc_media_list_t *ml4;
|
|
|
|
libvlc_media_list_t *ml5;
|
|
|
|
libvlc_media_list_t *ml6;
|
|
|
|
libvlc_media_list_player_t *mlp;
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2009-08-27 00:03:59 +02:00
|
|
|
const char * file = test_default_sample;
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2009-08-27 00:03:59 +02:00
|
|
|
log ("Testing media player playback options()\n");
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-31 22:40:16 +01:00
|
|
|
vlc = libvlc_new (argc, argv);
|
|
|
|
assert (vlc != NULL);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2009-08-27 00:03:59 +02:00
|
|
|
/*
|
|
|
|
* Create the following media tree:
|
|
|
|
*
|
|
|
|
* ml1: 0 ---- 1 ---- 2
|
|
|
|
* / | \
|
|
|
|
* ml2&4: 0 -- 1 | 0 -- 1 -- 2
|
|
|
|
* |
|
|
|
|
* ml3: 0 -- 1 -- 2 -- 3 -- 4 -- 5 -- 6
|
|
|
|
* | |
|
|
|
|
* ml5&6: 0 0 -- 1
|
|
|
|
*/
|
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
md = libvlc_media_new_path (vlc, file);
|
|
|
|
assert(md);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
md2 = libvlc_media_new_path (vlc, file);
|
|
|
|
assert(md2);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
md3 = libvlc_media_new_path (vlc, file);
|
|
|
|
assert(md3);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
md4 = libvlc_media_new_path (vlc, file);
|
|
|
|
assert(md4);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
md5 = libvlc_media_new_path (vlc, file);
|
|
|
|
assert(md5);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-28 21:49:15 +01:00
|
|
|
ml = libvlc_media_list_new (vlc);
|
|
|
|
assert (ml != NULL);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-28 21:49:15 +01:00
|
|
|
ml2 = libvlc_media_list_new (vlc);
|
|
|
|
assert (ml2 != NULL);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-28 21:49:15 +01:00
|
|
|
ml3 = libvlc_media_list_new (vlc);
|
|
|
|
assert (ml3 != NULL);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-28 21:49:15 +01:00
|
|
|
ml4 = libvlc_media_list_new (vlc);
|
|
|
|
assert (ml4 != NULL);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-28 21:49:15 +01:00
|
|
|
ml5 = libvlc_media_list_new (vlc);
|
|
|
|
assert (ml5 != NULL);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-28 21:49:15 +01:00
|
|
|
ml6 = libvlc_media_list_new (vlc);
|
|
|
|
assert (ml6 != NULL);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
|
|
|
media_list_add_file_path (vlc, ml2, file);
|
|
|
|
media_list_add_file_path (vlc, ml2, file);
|
|
|
|
|
|
|
|
media_list_add_file_path (vlc, ml3, file);
|
|
|
|
media_list_add_file_path (vlc, ml3, file);
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_add_media (ml3, md4);
|
2009-08-27 00:03:59 +02:00
|
|
|
media_list_add_file_path (vlc, ml3, file);
|
|
|
|
media_list_add_file_path (vlc, ml3, file);
|
|
|
|
media_list_add_file_path (vlc, ml3, file);
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_add_media (ml3, md5);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
|
|
|
media_list_add_file_path (vlc, ml4, file);
|
|
|
|
media_list_add_file_path (vlc, ml4, file);
|
|
|
|
media_list_add_file_path (vlc, ml4, file);
|
|
|
|
|
|
|
|
media_list_add_file_path (vlc, ml5, file);
|
|
|
|
|
|
|
|
media_list_add_file_path (vlc, ml6, file);
|
|
|
|
media_list_add_file_path (vlc, ml6, file);
|
|
|
|
|
|
|
|
md->p_subitems = ml2;
|
|
|
|
md2->p_subitems = ml3;
|
|
|
|
md3->p_subitems = ml4;
|
|
|
|
md4->p_subitems = ml5;
|
|
|
|
md5->p_subitems = ml6;
|
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_add_media (ml, md);
|
|
|
|
libvlc_media_list_add_media (ml, md2);
|
|
|
|
libvlc_media_list_add_media (ml, md3);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
mlp = libvlc_media_list_player_new (vlc);
|
|
|
|
assert(mlp);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_set_media_list (mlp, ml);
|
2010-01-07 14:07:00 +01:00
|
|
|
|
|
|
|
// Test default playback mode
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_set_playback_mode(mlp, libvlc_playback_mode_default);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_play_item (mlp, md);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:06:49 +01:00
|
|
|
|
2009-08-27 00:03:59 +02:00
|
|
|
libvlc_media_release (md);
|
|
|
|
libvlc_media_release (md2);
|
|
|
|
libvlc_media_release (md3);
|
|
|
|
libvlc_media_release (md4);
|
|
|
|
libvlc_media_release (md5);
|
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_stop (mlp);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:20:12 +01:00
|
|
|
|
2009-08-27 00:03:59 +02:00
|
|
|
// Test looping playback mode
|
|
|
|
log ("Testing media player playback option - Loop\n");
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_set_playback_mode(mlp, libvlc_playback_mode_loop);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_play_item (mlp, md);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_stop (mlp);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:20:12 +01:00
|
|
|
|
2009-08-27 00:03:59 +02:00
|
|
|
// Test repeat playback mode
|
|
|
|
log ("Testing media player playback option - Repeat\n");
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_set_playback_mode(mlp, libvlc_playback_mode_repeat);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-02-19 11:39:10 +01:00
|
|
|
libvlc_media_list_player_play_item (mlp, md);
|
2009-08-27 00:03:59 +02:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (!libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-07 14:07:00 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
libvlc_media_list_player_stop (mlp);
|
2010-01-07 14:49:41 +01:00
|
|
|
|
2010-01-24 10:09:46 +01:00
|
|
|
while (libvlc_media_list_player_is_playing (mlp))
|
|
|
|
sched_yield();
|
2010-01-18 09:20:12 +01:00
|
|
|
|
2009-08-27 00:03:59 +02:00
|
|
|
libvlc_media_list_player_release (mlp);
|
|
|
|
libvlc_release (vlc);
|
|
|
|
}
|
|
|
|
|
2008-04-09 11:45:35 +02:00
|
|
|
|
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
test_init();
|
|
|
|
|
|
|
|
test_media_list_player_pause_stop (test_defaults_args, test_defaults_nargs);
|
2008-06-29 14:34:55 +02:00
|
|
|
test_media_list_player_play_item_at_index (test_defaults_args, test_defaults_nargs);
|
2009-08-27 00:03:59 +02:00
|
|
|
test_media_list_player_previous (test_defaults_args, test_defaults_nargs);
|
2009-06-02 09:56:08 +02:00
|
|
|
test_media_list_player_next (test_defaults_args, test_defaults_nargs);
|
2009-08-20 01:02:56 +02:00
|
|
|
test_media_list_player_items_queue (test_defaults_args, test_defaults_nargs);
|
2009-08-27 00:03:59 +02:00
|
|
|
test_media_list_player_playback_options (test_defaults_args, test_defaults_nargs);
|
2008-04-09 11:45:35 +02:00
|
|
|
return 0;
|
|
|
|
}
|