[vlc-commits] macosx: expand AppleScript API for menu navigation and menu status checks
Felix Paul Kühne
git at videolan.org
Sun Jun 5 14:16:08 CEST 2016
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Jun 5 14:06:55 2016 +0200| [e799040c185b3e4f083cff6d867c89c69d9be524] | committer: Felix Paul Kühne
macosx: expand AppleScript API for menu navigation and menu status checks
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e799040c185b3e4f083cff6d867c89c69d9be524
---
NEWS | 1 +
extras/package/macosx/Resources/vlc.scriptSuite | Bin 2111 -> 2425 bytes
modules/gui/macosx/CoreInteraction.h | 6 +++
modules/gui/macosx/CoreInteraction.m | 51 +++++++++++++++++++++++
modules/gui/macosx/applescript.h | 1 +
modules/gui/macosx/applescript.m | 44 +++++++++++++++++++
6 files changed, 103 insertions(+)
diff --git a/NEWS b/NEWS
index b738334..1d7f62b 100644
--- a/NEWS
+++ b/NEWS
@@ -158,6 +158,7 @@ Mac OS X Interface
* new AppleScript API giving access to audio desynchronization
* Support for building with disabled sparkle update mechanism
* New configure flag to disable automatic updates
+ * Expanded AppleScript API for menu detection and navigation
iOS:
* Dropped support for iOS 6.x
diff --git a/extras/package/macosx/Resources/vlc.scriptSuite b/extras/package/macosx/Resources/vlc.scriptSuite
index 8ade5ba..e12ef53 100644
Binary files a/extras/package/macosx/Resources/vlc.scriptSuite and b/extras/package/macosx/Resources/vlc.scriptSuite differ
diff --git a/modules/gui/macosx/CoreInteraction.h b/modules/gui/macosx/CoreInteraction.h
index 043e4fb..f00cef2 100644
--- a/modules/gui/macosx/CoreInteraction.h
+++ b/modules/gui/macosx/CoreInteraction.h
@@ -70,6 +70,12 @@
- (void)startListeningWithAppleRemote;
- (void)stopListeningWithAppleRemote;
+- (void)menuFocusActivate;
+- (void)moveMenuFocusLeft;
+- (void)moveMenuFocusRight;
+- (void)moveMenuFocusUp;
+- (void)moveMenuFocusDown;
+
- (void)addSubtitlesToCurrentInput:(NSArray *)paths;
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
diff --git a/modules/gui/macosx/CoreInteraction.m b/modules/gui/macosx/CoreInteraction.m
index f6394ad..0eec81a 100644
--- a/modules/gui/macosx/CoreInteraction.m
+++ b/modules/gui/macosx/CoreInteraction.m
@@ -1057,6 +1057,57 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
[_remote stopListening:self];
}
+#pragma mark - menu navigation
+- (void)menuFocusActivate
+{
+ input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
+ if (p_input_thread == NULL)
+ return;
+
+ input_Control(p_input_thread, INPUT_NAV_ACTIVATE, NULL );
+ vlc_object_release(p_input_thread);
+}
+
+- (void)moveMenuFocusLeft
+{
+ input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
+ if (p_input_thread == NULL)
+ return;
+
+ input_Control(p_input_thread, INPUT_NAV_LEFT, NULL );
+ vlc_object_release(p_input_thread);
+}
+
+- (void)moveMenuFocusRight
+{
+ input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
+ if (p_input_thread == NULL)
+ return;
+
+ input_Control(p_input_thread, INPUT_NAV_RIGHT, NULL );
+ vlc_object_release(p_input_thread);
+}
+
+- (void)moveMenuFocusUp
+{
+ input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
+ if (p_input_thread == NULL)
+ return;
+
+ input_Control(p_input_thread, INPUT_NAV_UP, NULL );
+ vlc_object_release(p_input_thread);
+}
+
+- (void)moveMenuFocusDown
+{
+ input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
+ if (p_input_thread == NULL)
+ return;
+
+ input_Control(p_input_thread, INPUT_NAV_DOWN, NULL );
+ vlc_object_release(p_input_thread);
+}
+
/* Helper method for the remote control interface in order to trigger forward/backward and volume
increase/decrease as long as the user holds the left/right, plus/minus button */
- (void) executeHoldActionForRemoteButton: (NSNumber*) buttonIdentifierNumber
diff --git a/modules/gui/macosx/applescript.h b/modules/gui/macosx/applescript.h
index 71dff0c..aee356b 100644
--- a/modules/gui/macosx/applescript.h
+++ b/modules/gui/macosx/applescript.h
@@ -47,5 +47,6 @@
@property (readonly) int durationOfCurrentItem;
@property (readonly) NSString *pathOfCurrentItem;
@property (readonly) NSString *nameOfCurrentItem;
+ at property (readonly) BOOL playbackShowsMenu;
@end
diff --git a/modules/gui/macosx/applescript.m b/modules/gui/macosx/applescript.m
index 0f374f8..e6fb610 100644
--- a/modules/gui/macosx/applescript.m
+++ b/modules/gui/macosx/applescript.m
@@ -102,6 +102,16 @@
[[VLCCoreInteraction sharedInstance] volumeUp];
else if ([o_command isEqualToString:@"volumeDown"])
[[VLCCoreInteraction sharedInstance] volumeDown];
+ else if ([o_command isEqualToString:@"moveMenuFocusUp"])
+ [[VLCCoreInteraction sharedInstance] moveMenuFocusUp];
+ else if ([o_command isEqualToString:@"moveMenuFocusDown"])
+ [[VLCCoreInteraction sharedInstance] moveMenuFocusDown];
+ else if ([o_command isEqualToString:@"moveMenuFocusLeft"])
+ [[VLCCoreInteraction sharedInstance] moveMenuFocusLeft];
+ else if ([o_command isEqualToString:@"moveMenuFocusRight"])
+ [[VLCCoreInteraction sharedInstance] moveMenuFocusRight];
+ else if ([o_command isEqualToString:@"menuFocusActivate"])
+ [[VLCCoreInteraction sharedInstance] menuFocusActivate];
else if ([o_command isEqualToString:@"stepForward"]) {
//default: forwardShort
if (o_parameter) {
@@ -268,4 +278,38 @@
return [[VLCCoreInteraction sharedInstance] nameOfCurrentPlaylistItem];
}
+- (BOOL)playbackShowsMenu {
+ input_thread_t *p_input_thread = pl_CurrentInput(getIntf());
+
+ if (!p_input_thread)
+ return NO;
+
+ int i_current_title = var_GetInteger(p_input_thread, "title");
+
+ input_title_t **p_input_title;
+ int count;
+
+ /* fetch data */
+ int coreret = input_Control(p_input_thread, INPUT_GET_FULL_TITLE_INFO,
+ &p_input_title, &count);
+ vlc_object_release(p_input_thread);
+
+ if (coreret != VLC_SUCCESS)
+ return NO;
+
+ BOOL ret = NO;
+
+ if (count > 0 && i_current_title < count) {
+ ret = p_input_title[i_current_title]->i_flags & INPUT_TITLE_MENU;
+ }
+
+ /* free array */
+ for (int i = 0; i < count; i++) {
+ vlc_input_title_Delete(p_input_title[i]);
+ }
+ free(p_input_title);
+
+ return ret;
+}
+
@end
More information about the vlc-commits
mailing list