Commit efb6269f authored by Niles Bindel's avatar Niles Bindel Committed by Pierre d'Herbemont

Added ability to move to previous item in the media list player playlist....

Added ability to move to previous item in the media list player playlist. Added playback modes to allow for automatic looping and repeating of playlist items. Fixed a race condition with Pause and Play functions by adding appropriate locks to these functions. Added automated testing for previous item and playback options.
Signed-off-by: default avatarPierre d'Herbemont <pdherbemont@free.fr>
parent 365408f9
...@@ -45,6 +45,16 @@ extern "C" { ...@@ -45,6 +45,16 @@ extern "C" {
typedef struct libvlc_media_list_player_t libvlc_media_list_player_t; typedef struct libvlc_media_list_player_t libvlc_media_list_player_t;
/*
* Defines playback modes for playlist.
*/
typedef enum libvlc_playback_mode_t
{
libvlc_playback_mode_default,
libvlc_playback_mode_loop,
libvlc_playback_mode_repeat
} libvlc_playback_mode_t;
/** /**
* Create new media_list_player. * Create new media_list_player.
* *
...@@ -172,7 +182,30 @@ VLC_PUBLIC_API void ...@@ -172,7 +182,30 @@ VLC_PUBLIC_API void
libvlc_media_list_player_next( libvlc_media_list_player_t * p_mlp, libvlc_media_list_player_next( libvlc_media_list_player_t * p_mlp,
libvlc_exception_t * p_e ); libvlc_exception_t * p_e );
/* NOTE: shouldn't there also be a libvlc_media_list_player_prev() */ /**
* Play previous item from media list
*
* \param p_mlp media list player instance
* \param p_e initialized exception instance
*/
VLC_PUBLIC_API void
libvlc_media_list_player_previous( libvlc_media_list_player_t * p_mlp,
libvlc_exception_t * p_e );
/**
* Sets the playback mode for the playlist
*
* \param p_mlp media list player instance
* \param e_mode playback mode specification
* \param p_e initialized exception instance
*/
VLC_PUBLIC_API void
libvlc_media_list_player_set_playback_mode(
libvlc_media_list_player_t * p_mlp,
libvlc_playback_mode_t e_mode,
libvlc_exception_t * p_e );
/** @} media_list_player */ /** @} media_list_player */
......
This diff is collapsed.
...@@ -95,9 +95,11 @@ libvlc_media_list_player_pause ...@@ -95,9 +95,11 @@ libvlc_media_list_player_pause
libvlc_media_list_player_play libvlc_media_list_player_play
libvlc_media_list_player_play_item libvlc_media_list_player_play_item
libvlc_media_list_player_play_item_at_index libvlc_media_list_player_play_item_at_index
libvlc_media_list_player_previous
libvlc_media_list_player_release libvlc_media_list_player_release
libvlc_media_list_player_set_media_list libvlc_media_list_player_set_media_list
libvlc_media_list_player_set_media_player libvlc_media_list_player_set_media_player
libvlc_media_list_player_set_playback_mode
libvlc_media_list_player_stop libvlc_media_list_player_stop
libvlc_media_list_release libvlc_media_list_release
libvlc_media_list_remove_index libvlc_media_list_remove_index
......
...@@ -29,6 +29,13 @@ ...@@ -29,6 +29,13 @@
#include "libvlc_additions.h" #include "libvlc_additions.h"
/*
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"
struct check_items_order_data { struct check_items_order_data {
bool done_playing; bool done_playing;
unsigned count; unsigned count;
...@@ -155,6 +162,73 @@ static void test_media_list_player_items_queue(const char** argv, int argc) ...@@ -155,6 +162,73 @@ static void test_media_list_player_items_queue(const char** argv, int argc)
catch (); catch ();
} }
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;
const char * file = test_default_sample;
log ("Testing media player previous()\n");
libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv, &ex);
catch ();
md = libvlc_media_new (vlc, file, &ex);
catch ();
ml = libvlc_media_list_new (vlc, &ex);
catch ();
mlp = libvlc_media_list_player_new (vlc, &ex);
catch ();
libvlc_media_list_add_media (ml, md, &ex);
catch ();
// 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);
libvlc_media_list_player_set_media_list (mlp, ml, &ex);
libvlc_media_list_player_play_item (mlp, md, &ex);
catch ();
libvlc_media_release (md);
msleep(100000);
libvlc_media_list_player_previous (mlp, &ex);
catch ();
libvlc_media_list_player_pause (mlp, &ex);
catch();
msleep(100000);
libvlc_media_list_player_previous (mlp, &ex);
catch ();
libvlc_media_list_player_stop (mlp, &ex);
catch ();
msleep(100000);
libvlc_media_list_player_previous (mlp, &ex);
catch ();
libvlc_media_list_player_release (mlp);
catch ();
libvlc_release (vlc);
catch ();
}
static void test_media_list_player_next(const char** argv, int argc) static void test_media_list_player_next(const char** argv, int argc)
{ {
libvlc_instance_t *vlc; libvlc_instance_t *vlc;
...@@ -315,6 +389,171 @@ static void test_media_list_player_play_item_at_index(const char** argv, int arg ...@@ -315,6 +389,171 @@ static void test_media_list_player_play_item_at_index(const char** argv, int arg
catch (); catch ();
} }
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;
const char * file = test_default_sample;
log ("Testing media player playback options()\n");
libvlc_exception_init (&ex);
vlc = libvlc_new (argc, argv, &ex);
catch ();
/*
* 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
*/
md = libvlc_media_new (vlc, file, &ex);
catch ();
md2 = libvlc_media_new (vlc, file, &ex);
catch ();
md3 = libvlc_media_new (vlc, file, &ex);
catch ();
md4 = libvlc_media_new (vlc, file, &ex);
catch ();
md5 = libvlc_media_new (vlc, file, &ex);
catch ();
ml = libvlc_media_list_new (vlc, &ex);
catch ();
ml2 = libvlc_media_list_new (vlc, &ex);
catch ();
ml3 = libvlc_media_list_new (vlc, &ex);
catch ();
ml4 = libvlc_media_list_new (vlc, &ex);
catch ();
ml5 = libvlc_media_list_new (vlc, &ex);
catch ();
ml6 = libvlc_media_list_new (vlc, &ex);
catch ();
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);
libvlc_media_list_add_media (ml3, md4, &ex);
catch ();
media_list_add_file_path (vlc, ml3, file);
media_list_add_file_path (vlc, ml3, file);
media_list_add_file_path (vlc, ml3, file);
libvlc_media_list_add_media (ml3, md5, &ex);
catch ();
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;
libvlc_media_list_add_media (ml, md, &ex);
catch ();
libvlc_media_list_add_media (ml, md2, &ex);
catch ();
libvlc_media_list_add_media (ml, md3, &ex);
catch ();
mlp = libvlc_media_list_player_new (vlc, &ex);
catch ();
libvlc_media_list_player_set_media_list (mlp, ml, &ex);
catch ();
// Test default playback mode
libvlc_media_list_player_set_playback_mode(mlp, libvlc_playback_mode_default, &ex);
catch ();
libvlc_media_list_player_play_item (mlp, md, &ex);
catch ();
libvlc_media_release (md);
catch ();
libvlc_media_release (md2);
catch ();
libvlc_media_release (md3);
catch ();
libvlc_media_release (md4);
catch ();
libvlc_media_release (md5);
catch ();
msleep(500000);
libvlc_media_list_player_stop (mlp, &ex);
catch ();
// Test looping playback mode
log ("Testing media player playback option - Loop\n");
libvlc_media_list_player_set_playback_mode(mlp, libvlc_playback_mode_loop, &ex);
catch ();
libvlc_media_list_player_play_item (mlp, md, &ex);
catch ();
msleep(500000);
libvlc_media_list_player_stop (mlp, &ex);
catch ();
// Test repeat playback mode
log ("Testing media player playback option - Repeat\n");
libvlc_media_list_player_set_playback_mode(mlp, libvlc_playback_mode_repeat, &ex);
catch ();
libvlc_media_list_player_play_item (mlp, md, &ex);
catch ();
msleep(500000);
libvlc_media_list_player_release (mlp);
catch ();
libvlc_release (vlc);
catch ();
}
int main (void) int main (void)
{ {
...@@ -322,7 +561,9 @@ int main (void) ...@@ -322,7 +561,9 @@ int main (void)
test_media_list_player_pause_stop (test_defaults_args, test_defaults_nargs); test_media_list_player_pause_stop (test_defaults_args, test_defaults_nargs);
test_media_list_player_play_item_at_index (test_defaults_args, test_defaults_nargs); test_media_list_player_play_item_at_index (test_defaults_args, test_defaults_nargs);
test_media_list_player_previous (test_defaults_args, test_defaults_nargs);
test_media_list_player_next (test_defaults_args, test_defaults_nargs); test_media_list_player_next (test_defaults_args, test_defaults_nargs);
test_media_list_player_items_queue (test_defaults_args, test_defaults_nargs); test_media_list_player_items_queue (test_defaults_args, test_defaults_nargs);
test_media_list_player_playback_options (test_defaults_args, test_defaults_nargs);
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment