mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-14 13:21:28 +00:00
playback/player: gst-play: add playlist loop command line option
This commit is contained in:
parent
9a7d2f031f
commit
eb42154608
1 changed files with 15 additions and 1 deletions
|
@ -46,6 +46,8 @@ typedef struct
|
||||||
GstPlayer *player;
|
GstPlayer *player;
|
||||||
GstState desired_state;
|
GstState desired_state;
|
||||||
|
|
||||||
|
gboolean repeat;
|
||||||
|
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
} GstPlay;
|
} GstPlay;
|
||||||
|
|
||||||
|
@ -70,6 +72,9 @@ error_cb (GstPlayer * player, GError * err, GstPlay * play)
|
||||||
{
|
{
|
||||||
g_printerr ("ERROR %s for %s\n", err->message, play->uris[play->cur_idx]);
|
g_printerr ("ERROR %s for %s\n", err->message, play->uris[play->cur_idx]);
|
||||||
|
|
||||||
|
/* if looping is enabled, then disable it else will keep looping forever */
|
||||||
|
play->repeat = FALSE;
|
||||||
|
|
||||||
/* try next item in list then */
|
/* try next item in list then */
|
||||||
if (!play_next (play)) {
|
if (!play_next (play)) {
|
||||||
g_print ("Reached end of play list.\n");
|
g_print ("Reached end of play list.\n");
|
||||||
|
@ -438,8 +443,14 @@ play_uri (GstPlay * play, const gchar * next_uri)
|
||||||
static gboolean
|
static gboolean
|
||||||
play_next (GstPlay * play)
|
play_next (GstPlay * play)
|
||||||
{
|
{
|
||||||
if ((play->cur_idx + 1) >= play->num_uris)
|
if ((play->cur_idx + 1) >= play->num_uris) {
|
||||||
|
if (play->repeat) {
|
||||||
|
g_print ("Looping playlist \n");
|
||||||
|
play->cur_idx = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
play_uri (play, play->uris[++play->cur_idx]);
|
play_uri (play, play->uris[++play->cur_idx]);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -632,6 +643,7 @@ main (int argc, char **argv)
|
||||||
gboolean print_version = FALSE;
|
gboolean print_version = FALSE;
|
||||||
gboolean interactive = FALSE; /* FIXME: maybe enable by default? */
|
gboolean interactive = FALSE; /* FIXME: maybe enable by default? */
|
||||||
gboolean shuffle = FALSE;
|
gboolean shuffle = FALSE;
|
||||||
|
gboolean repeat = FALSE;
|
||||||
gdouble volume = 1.0;
|
gdouble volume = 1.0;
|
||||||
gchar **filenames = NULL;
|
gchar **filenames = NULL;
|
||||||
gchar **uris;
|
gchar **uris;
|
||||||
|
@ -650,6 +662,7 @@ main (int argc, char **argv)
|
||||||
"Volume", NULL},
|
"Volume", NULL},
|
||||||
{"playlist", 0, 0, G_OPTION_ARG_FILENAME, &playlist_file,
|
{"playlist", 0, 0, G_OPTION_ARG_FILENAME, &playlist_file,
|
||||||
"Playlist file containing input media files", NULL},
|
"Playlist file containing input media files", NULL},
|
||||||
|
{"loop", 0, 0, G_OPTION_ARG_NONE, &repeat, "Repeat all", NULL},
|
||||||
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL},
|
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
@ -738,6 +751,7 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
/* prepare */
|
/* prepare */
|
||||||
play = play_new (uris, volume);
|
play = play_new (uris, volume);
|
||||||
|
play->repeat = repeat;
|
||||||
|
|
||||||
if (interactive) {
|
if (interactive) {
|
||||||
if (gst_play_kb_set_key_handler (keyboard_cb, play)) {
|
if (gst_play_kb_set_key_handler (keyboard_cb, play)) {
|
||||||
|
|
Loading…
Reference in a new issue