[vlc-devel] [PATCH 10/12] core: playlist: configure main playlist from vars
Romain Vimont
rom1v at videolabs.io
Thu Oct 11 23:14:48 CEST 2018
Initialize the main playlist playback order and repeat mode from VLC
variables.
---
src/libvlc.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/libvlc.c b/src/libvlc.c
index 438f958e2e..d147739b6c 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -102,6 +102,30 @@ libvlc_int_t * libvlc_InternalCreate( void )
return p_libvlc;
}
+static void
+PlaylistConfigureFromVariables(vlc_playlist_t *playlist, vlc_object_t *obj)
+{
+ enum vlc_playlist_playback_order order;
+ if (var_InheritBool(obj, "random"))
+ order = VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM;
+ else
+ order = VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL;
+
+ /* repeat = repeat current; loop = repeat_all */
+ enum vlc_playlist_playback_repeat repeat;
+ if (var_InheritBool(obj, "repeat"))
+ repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT;
+ else if (var_InheritBool(obj, "loop"))
+ repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_ALL;
+ else
+ repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE;
+
+ vlc_playlist_Lock(playlist);
+ vlc_playlist_SetPlaybackOrder(playlist, order);
+ vlc_playlist_SetPlaybackRepeat(playlist, repeat);
+ vlc_playlist_Unlock(playlist);
+}
+
/**
* Initialize a libvlc instance
* This function initializes a previously allocated libvlc instance:
@@ -282,6 +306,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
if (unlikely(!priv->main_playlist))
goto error;
+ PlaylistConfigureFromVariables(priv->main_playlist, VLC_OBJECT(p_libvlc));
+
/*
* Load background interfaces
*/
--
2.19.1
More information about the vlc-devel
mailing list