[vlc-commits] macosx/player controller: expose A→B loop

Felix Paul Kühne git at videolan.org
Mon Mar 25 17:11:20 CET 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Mon Mar 25 17:04:21 2019 +0100| [a82e9a035087c6f5f59e0a638f158e0e88ca3d8d] | committer: Felix Paul Kühne

macosx/player controller: expose A→B loop

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

 modules/gui/macosx/playlist/VLCPlayerController.h | 27 +++++++++++++
 modules/gui/macosx/playlist/VLCPlayerController.m | 48 ++++++++++++++++++++++-
 2 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/modules/gui/macosx/playlist/VLCPlayerController.h b/modules/gui/macosx/playlist/VLCPlayerController.h
index fd87fee484..0cb0f7c19a 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.h
+++ b/modules/gui/macosx/playlist/VLCPlayerController.h
@@ -93,6 +93,12 @@ extern NSString *VLCPlayerTitleSelectionChanged;
 extern NSString *VLCPlayerTitleListChanged;
 
 /**
+ * Listen to VLCPlayerABLoopStateChanged to be notified if the A→B loop state changes
+ * @note the affected player object will be the object of the notification
+ */
+extern NSString *VLCPlayerABLoopStateChanged;
+
+/**
  * Listen to VLCPlayerTeletextMenuAvailable to be notified if a teletext menu becomes (un-)available
  * @note the affected player object will be the object of the notification
  */
@@ -222,6 +228,27 @@ extern NSString *VLCPlayerMuteChanged;
 - (void)stop;
 
 /**
+ * the current status of the A→B loop
+ * It will be A if A is set, B if A _and_ B are set or none if there is none
+ * @note listen to VLCPlayerABLoopStateChanged for changes to this property
+ */
+ at property (readonly) enum vlc_player_abloop abLoopState;
+
+/**
+ * set the A→B loop
+ * this function will need to be called twice to set the A and the B point
+ * @note VLC core will automatically pick the current time stamp, so there is no parameter to this method
+ * @return VLC_SUCCESS or a VLC error code
+ */
+- (int)setABLoop;
+
+/**
+ * disable the A→B loop
+ * @return VLC_SUCCESS or a VLC error code
+ */
+- (int)disableABLoop;
+
+/**
  * Define the action to perform after playback of the current media stopped (for any reason)
  * Options are: continue with next time, pause on last frame, stop even if there is a next item and quit VLC
  * @see the vlc_player_media_stopped_action enum for details
diff --git a/modules/gui/macosx/playlist/VLCPlayerController.m b/modules/gui/macosx/playlist/VLCPlayerController.m
index 1b61f218aa..8e25ed5f2d 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.m
+++ b/modules/gui/macosx/playlist/VLCPlayerController.m
@@ -42,6 +42,7 @@ NSString *VLCPlayerTimeAndPositionChanged = @"VLCPlayerTimeAndPositionChanged";
 NSString *VLCPlayerLengthChanged = @"VLCPlayerLengthChanged";
 NSString *VLCPlayerTitleSelectionChanged = @"VLCPlayerTitleSelectionChanged";
 NSString *VLCPlayerTitleListChanged = @"VLCPlayerTitleListChanged";
+NSString *VLCPlayerABLoopStateChanged = @"VLCPlayerABLoopStateChanged";
 NSString *VLCPlayerTeletextMenuAvailable = @"VLCPlayerTeletextMenuAvailable";
 NSString *VLCPlayerTeletextEnabled = @"VLCPlayerTeletextEnabled";
 NSString *VLCPlayerTeletextPageChanged = @"VLCPlayerTeletextPageChanged";
@@ -99,6 +100,7 @@ NSString *VLCPlayerMuteChanged = @"VLCPlayerMuteChanged";
 - (void)subtitlesFPSChanged:(float)subtitlesFPS;
 - (void)recordingChanged:(BOOL)recording;
 - (void)inputStatsUpdated:(VLCInputStats *)inputStats;
+- (void)ABLoopStateChanged:(enum vlc_player_abloop)abLoopState;
 - (void)stopActionChanged:(enum vlc_player_media_stopped_action)stoppedAction;
 - (void)metaDataChangedForInput:(input_item_t *)inputItem;
 - (void)voutListUpdated;
@@ -328,6 +330,18 @@ static void cb_player_stats_changed(vlc_player_t *p_player,
     });
 }
 
+static void cb_player_atobloop_changed(vlc_player_t *p_player,
+                                       enum vlc_player_abloop new_state,
+                                       vlc_tick_t time, float pos,
+                                       void *p_data)
+{
+    VLC_UNUSED(p_player);
+    dispatch_async(dispatch_get_main_queue(), ^{
+        VLCPlayerController *playerController = (__bridge VLCPlayerController *)p_data;
+        [playerController ABLoopStateChanged:new_state];
+    });
+}
+
 static void cb_player_media_stopped_action_changed(vlc_player_t *p_player,
                                                    enum vlc_player_media_stopped_action newAction,
                                                    void *p_data)
@@ -391,7 +405,7 @@ static const struct vlc_player_cbs player_callbacks = {
     cb_player_record_changed,
     NULL, //cb_player_signal_changed,
     cb_player_stats_changed,
-    NULL, //cb_player_atobloop_changed,
+    cb_player_atobloop_changed,
     cb_player_media_stopped_action_changed,
     cb_player_item_meta_changed,
     NULL, //cb_player_item_epg_changed,
@@ -1119,6 +1133,38 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
                                             userInfo:@{VLCPlayerInputStats : inputStats}];
 }
 
+- (void)ABLoopStateChanged:(enum vlc_player_abloop)abLoopState
+{
+    _abLoopState = abLoopState;
+    [_defaultNotificationCenter postNotificationName:VLCPlayerABLoopStateChanged
+                                              object:self];
+}
+
+- (int)setABLoop
+{
+    int ret = 0;
+    switch (_abLoopState) {
+        case VLC_PLAYER_ABLOOP_A:
+            ret = vlc_player_SetAtoBLoop(_p_player, VLC_PLAYER_ABLOOP_B);
+            break;
+
+        case VLC_PLAYER_ABLOOP_B:
+            ret = vlc_player_SetAtoBLoop(_p_player, VLC_PLAYER_ABLOOP_NONE);
+            break;
+
+        default:
+            ret = vlc_player_SetAtoBLoop(_p_player, VLC_PLAYER_ABLOOP_A);
+            break;
+    }
+
+    return ret;
+}
+
+- (int)disableABLoop
+{
+    return vlc_player_SetAtoBLoop(_p_player, VLC_PLAYER_ABLOOP_NONE);
+}
+
 - (void)setEnableRecording:(BOOL)enableRecording
 {
     vlc_player_Lock(_p_player);



More information about the vlc-commits mailing list