[vlc-devel] [PATCH 11/12] core: player: configure main player from vars

Romain Vimont rom1v at videolabs.io
Thu Oct 11 23:14:49 CEST 2018


Initialize the main playlist player settings from VLC variables.
---
 src/libvlc.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/libvlc.c b/src/libvlc.c
index d147739b6c..2bbe3dadb9 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -68,6 +68,7 @@
 #include "libvlc.h"
 #include "playlist/playlist_internal.h"
 #include "misc/variables.h"
+#include "input/player.h"
 
 #include <vlc_vlm.h>
 
@@ -120,9 +121,29 @@ PlaylistConfigureFromVariables(vlc_playlist_t *playlist, vlc_object_t *obj)
     else
         repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE;
 
+    enum vlc_player_media_ended_action media_ended_action;
+    if (var_InheritBool(obj, "play-and-exit"))
+        media_ended_action = VLC_PLAYER_MEDIA_ENDED_EXIT;
+    else if (var_InheritBool(obj, "play-and-stop"))
+        media_ended_action = VLC_PLAYER_MEDIA_ENDED_STOP;
+    else if (var_InheritBool(obj, "play-and-pause"))
+        media_ended_action = VLC_PLAYER_MEDIA_ENDED_PAUSE;
+    else
+        media_ended_action = VLC_PLAYER_MEDIA_ENDED_CONTINUE;
+
+    bool start_paused = var_InheritBool(obj, "start-paused");
+
     vlc_playlist_Lock(playlist);
     vlc_playlist_SetPlaybackOrder(playlist, order);
     vlc_playlist_SetPlaybackRepeat(playlist, repeat);
+
+    vlc_player_t *player = vlc_playlist_GetPlayer(playlist);
+
+    /* the playlist and the player share the same lock, and this is not an
+     * implementation detail */
+    vlc_player_SetMediaEndedAction(player, media_ended_action);
+    vlc_player_SetStartPaused(player, start_paused);
+
     vlc_playlist_Unlock(playlist);
 }
 
-- 
2.19.1



More information about the vlc-devel mailing list