[vlc-commits] macosx/coreinteraction: switch to new playlist

Felix Paul Kühne git at videolan.org
Fri Feb 1 16:41:58 CET 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Fri Feb  1 16:10:57 2019 +0100| [f2aab964a23d8a0f98691ff0e21d0f157b6a4a15] | committer: Felix Paul Kühne

macosx/coreinteraction: switch to new playlist

Note that this is not recognized by the typical playback controls yet.

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

 modules/gui/macosx/VLCCoreInteraction.h    |  4 +-
 modules/gui/macosx/VLCCoreInteraction.m    | 90 ++++++++++--------------------
 modules/gui/macosx/VLCPlaylistController.m | 14 +++--
 3 files changed, 41 insertions(+), 67 deletions(-)

diff --git a/modules/gui/macosx/VLCCoreInteraction.h b/modules/gui/macosx/VLCCoreInteraction.h
index 96c6ff800d..f735ae8785 100644
--- a/modules/gui/macosx/VLCCoreInteraction.h
+++ b/modules/gui/macosx/VLCCoreInteraction.h
@@ -43,8 +43,8 @@
 - (void)slower;
 - (void)normalSpeed;
 - (void)toggleRecord;
-- (void)next;
-- (void)previous;
+- (int)next;
+- (int)previous;
 - (void)forwardExtraShort;
 - (void)backwardExtraShort;
 - (void)forwardShort;
diff --git a/modules/gui/macosx/VLCCoreInteraction.m b/modules/gui/macosx/VLCCoreInteraction.m
index 7c0462434b..4918259d41 100644
--- a/modules/gui/macosx/VLCCoreInteraction.m
+++ b/modules/gui/macosx/VLCCoreInteraction.m
@@ -30,6 +30,7 @@
 #import <vlc_plugin.h>
 #import <vlc_actions.h>
 #import "VLCClickerManager.h"
+#import "VLCPlaylistController.h"
 
 static int BossCallback(vlc_object_t *p_this, const char *psz_var,
                         vlc_value_t oldval, vlc_value_t new_val, void *param)
@@ -54,6 +55,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
     NSArray *_usedHotkeys;
 
     VLCClickerManager *_clickerManager;
+    VLCPlaylistController *_playlistController;
 }
 @end
 
@@ -86,6 +88,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
                             object:nil];
 
         _clickerManager = [[VLCClickerManager alloc] init];
+        _playlistController = [[VLCMain sharedInstance] playlistController];
 
         var_AddCallback(pl_Get(p_intf), "intf-boss", BossCallback, (__bridge void *)self);
     }
@@ -106,8 +109,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
 
 - (void)play
 {
-    playlist_t *p_playlist = pl_Get(getIntf());
-    playlist_Play(p_playlist);
+    [_playlistController startPlaylist];
 }
 
 - (void)playOrPause
@@ -130,13 +132,12 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
 
 - (void)pause
 {
-    playlist_t *p_playlist = pl_Get(getIntf());
-    playlist_Pause(p_playlist);
+    [_playlistController pausePlayback];
 }
 
 - (void)stop
 {
-    playlist_Stop(pl_Get(getIntf()));
+    [_playlistController stopPlayback];
 }
 
 - (void)faster
@@ -209,14 +210,14 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
     return returnValue;
 }
 
-- (void)previous
+- (int)previous
 {
-    playlist_Prev(pl_Get(getIntf()));
+    return [_playlistController playPreviousItem];
 }
 
-- (void)next
+- (int)next
 {
-    playlist_Next(pl_Get(getIntf()));
+    return [_playlistController playNextItem];
 }
 
 - (NSInteger)durationOfCurrentPlaylistItem
@@ -368,46 +369,31 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
 
 - (void)shuffle
 {
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
+    BOOL on = NO;
+    if (_playlistController.playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL) {
+        _playlistController.playbackOrder = VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM;
+        on = YES;
+    } else {
+        _playlistController.playbackOrder = VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL;
+    }
+    config_PutInt("random", on);
 
-    vlc_value_t val;
-    playlist_t * p_playlist = pl_Get(p_intf);
     vout_thread_t *p_vout = getVout();
-
-    var_Get(p_playlist, "random", &val);
-    val.b_bool = !val.b_bool;
-    var_Set(p_playlist, "random", val);
-    if (val.b_bool) {
-        if (p_vout) {
-            vout_OSDMessage(p_vout, VOUT_SPU_CHANNEL_OSD, "%s", _("Random On"));
-            vlc_object_release(p_vout);
-        }
-        config_PutInt("random", 1);
+    if (!p_vout) {
+        return;
     }
-    else
-    {
-        if (p_vout) {
-            vout_OSDMessage(p_vout, VOUT_SPU_CHANNEL_OSD, "%s", _("Random Off"));
-            vlc_object_release(p_vout);
-        }
-        config_PutInt("random", 0);
+    if (on) {
+        vout_OSDMessage(p_vout, VOUT_SPU_CHANNEL_OSD, "%s", _("Random On"));
+    } else {
+        vout_OSDMessage(p_vout, VOUT_SPU_CHANNEL_OSD, "%s", _("Random Off"));
     }
+
+    vlc_object_release(p_vout);
 }
 
 - (void)repeatAll
 {
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    playlist_t * p_playlist = pl_Get(p_intf);
-
-    var_SetBool(p_playlist, "repeat", NO);
-    var_SetBool(p_playlist, "loop", YES);
-    config_PutInt("repeat", NO);
-    config_PutInt("loop", YES);
+    _playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_ALL;
 
     vout_thread_t *p_vout = getVout();
     if (p_vout) {
@@ -418,16 +404,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
 
 - (void)repeatOne
 {
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    playlist_t * p_playlist = pl_Get(p_intf);
-
-    var_SetBool(p_playlist, "repeat", YES);
-    var_SetBool(p_playlist, "loop", NO);
-    config_PutInt("repeat", YES);
-    config_PutInt("loop", NO);
+    _playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT;
 
     vout_thread_t *p_vout = getVout();
     if (p_vout) {
@@ -438,16 +415,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
 
 - (void)repeatOff
 {
-    intf_thread_t *p_intf = getIntf();
-    if (!p_intf)
-        return;
-
-    playlist_t * p_playlist = pl_Get(p_intf);
-
-    var_SetBool(p_playlist, "repeat", NO);
-    var_SetBool(p_playlist, "loop", NO);
-    config_PutInt("repeat", NO);
-    config_PutInt("loop", NO);
+    _playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE;
 
     vout_thread_t *p_vout = getVout();
     if (p_vout) {
diff --git a/modules/gui/macosx/VLCPlaylistController.m b/modules/gui/macosx/VLCPlaylistController.m
index ccbb214d6e..7035e8fb6e 100644
--- a/modules/gui/macosx/VLCPlaylistController.m
+++ b/modules/gui/macosx/VLCPlaylistController.m
@@ -116,17 +116,23 @@ cb_playlist_items_updated(vlc_playlist_t *playlist,
 static void
 cb_playlist_playback_repeat_changed(vlc_playlist_t *playlist,
                                     enum vlc_playlist_playback_repeat repeat,
-                                    void *userdata)
+                                    void *p_data)
 {
-    NSLog(@"%s: repeat mode: %u", __func__, repeat);
+    dispatch_async(dispatch_get_main_queue(), ^{
+        VLCPlaylistController *playlistController = (__bridge VLCPlaylistController *)p_data;
+        [playlistController playlistPlaybackRepeatUpdated:repeat];
+    });
 }
 
 static void
 cb_playlist_playback_order_changed(vlc_playlist_t *playlist,
                                    enum vlc_playlist_playback_order order,
-                                   void *userdata)
+                                   void *p_data)
 {
-    NSLog(@"%s: playback order: %u", __func__, order);
+    dispatch_async(dispatch_get_main_queue(), ^{
+        VLCPlaylistController *playlistController = (__bridge VLCPlaylistController *)p_data;
+        [playlistController playlistPlaybackOrderUpdated:order];
+    });
 }
 
 static void



More information about the vlc-commits mailing list