[vlc-commits] core: playlist: configure main playlist from vars

Romain Vimont git at videolan.org
Thu Nov 15 16:23:44 CET 2018


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Thu Oct  4 15:07:31 2018 +0200| [76091aa9eae1bd47589391df5cf3599417eab935] | committer: Thomas Guillem

core: playlist: configure main playlist from vars

Initialize the main playlist playback order and repeat mode from VLC
variables.

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=76091aa9eae1bd47589391df5cf3599417eab935
---

 src/libvlc.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/libvlc.c b/src/libvlc.c
index 7516c43b74..078672ddef 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -103,6 +103,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:
@@ -287,6 +311,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
      */



More information about the vlc-commits mailing list