vlc | branch: master | Felix Paul Kühne <[email protected]> | Sun Apr 21 18:08:11 2019 +0200| [02f0392f56cb8cfe2fa2b4722337e105f8061ca6] | committer: Felix Paul Kühne
macosx: improve AppleScript API (closes #22213) > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=02f0392f56cb8cfe2fa2b4722337e105f8061ca6 --- NEWS | 1 + modules/gui/macosx/Resources/vlc.scriptSuite | Bin 2424 -> 2987 bytes modules/gui/macosx/Resources/vlc.scriptTerminology | Bin 2796 -> 4063 bytes modules/gui/macosx/os-integration/applescript.h | 6 ++ modules/gui/macosx/os-integration/applescript.m | 75 ++++++++++++++++++++- 5 files changed, 81 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 6801d24de5..df6d552ce4 100644 --- a/NEWS +++ b/NEWS @@ -64,6 +64,7 @@ Service discovery: macOS: * Remove Growl notification support + * Improved AppleScript API with support for playback modes, recording, rate appleOS: * Improved proxy configuration handling diff --git a/modules/gui/macosx/Resources/vlc.scriptSuite b/modules/gui/macosx/Resources/vlc.scriptSuite index c9e59a6bc0..539da9df53 100644 Binary files a/modules/gui/macosx/Resources/vlc.scriptSuite and b/modules/gui/macosx/Resources/vlc.scriptSuite differ diff --git a/modules/gui/macosx/Resources/vlc.scriptTerminology b/modules/gui/macosx/Resources/vlc.scriptTerminology index a846462ce8..b744aa5a9d 100644 Binary files a/modules/gui/macosx/Resources/vlc.scriptTerminology and b/modules/gui/macosx/Resources/vlc.scriptTerminology differ diff --git a/modules/gui/macosx/os-integration/applescript.h b/modules/gui/macosx/os-integration/applescript.h index 2f83864e53..46c0421205 100644 --- a/modules/gui/macosx/os-integration/applescript.h +++ b/modules/gui/macosx/os-integration/applescript.h @@ -43,9 +43,15 @@ @property (readwrite) float audioVolume; @property (readwrite) long long audioDesync; @property (readwrite) int currentTime; +@property (readwrite) float playbackRate; @property (readonly) NSInteger durationOfCurrentItem; @property (readonly) NSString *pathOfCurrentItem; @property (readonly) NSString *nameOfCurrentItem; @property (readonly) BOOL playbackShowsMenu; +@property (readonly) BOOL recordable; +@property (readwrite) BOOL recordingEnabled; +@property (readwrite) BOOL shuffledPlayback; +@property (readwrite) BOOL repeatOne; +@property (readwrite) BOOL repeatAll; @end diff --git a/modules/gui/macosx/os-integration/applescript.m b/modules/gui/macosx/os-integration/applescript.m index 7260ab6308..7babde2250 100644 --- a/modules/gui/macosx/os-integration/applescript.m +++ b/modules/gui/macosx/os-integration/applescript.m @@ -76,6 +76,10 @@ NSString *commandString = [[self commandDescription] commandName]; NSString *parameterString = [self directParameter]; + if (commandString == nil || commandString.length == 0) { + return nil; + } + if ([commandString isEqualToString:@"play"]) { [playerController togglePlayPause]; } else if ([commandString isEqualToString:@"stop"]) { @@ -102,6 +106,10 @@ [playerController navigateInInteractiveContent:VLC_PLAYER_NAV_RIGHT]; } else if ([commandString isEqualToString:@"menuFocusActivate"]) { [playerController navigateInInteractiveContent:VLC_PLAYER_NAV_ACTIVATE]; + } else if ([commandString isEqualToString:@"menuActivatePopupMenu"]) { + [playerController navigateInInteractiveContent:VLC_PLAYER_NAV_POPUP]; + } else if ([commandString isEqualToString:@"menuActivateDiscRootMenu"]) { + [playerController navigateInInteractiveContent:VLC_PLAYER_NAV_MENU]; } else if ([commandString isEqualToString:@"stepForward"]) { if (parameterString) { int parameterInt = [parameterString intValue]; @@ -143,8 +151,15 @@ } } else [playerController jumpBackwardShort]; + } else if ([commandString isEqualToString:@"incrementPlaybackRate"]) { + [[[[VLCMain sharedInstance] playlistController] playerController] incrementPlaybackRate]; + } else if ([commandString isEqualToString:@"decrementPlaybackRate"]) { + [[[[VLCMain sharedInstance] playlistController] playerController] decrementPlaybackRate]; + } else { + msg_Err(getIntf(), "Unhandled AppleScript command '%s'", [commandString UTF8String]); } - return nil; + + return nil; } @end @@ -210,6 +225,16 @@ [[[[VLCMain sharedInstance] playlistController] playerController] setTimeFast: VLC_TICK_FROM_SEC(currentTime)]; } +- (float)playbackRate +{ + return [[[[VLCMain sharedInstance] playlistController] playerController] playbackRate]; +} + +- (void)setPlaybackRate:(float)playbackRate +{ + [[[[VLCMain sharedInstance] playlistController] playerController] setPlaybackRate:playbackRate]; +} + - (NSInteger)durationOfCurrentItem { return SEC_FROM_VLC_TICK([[[VLCMain sharedInstance] playlistController] playerController].durationOfCurrentMediaItem); @@ -239,4 +264,52 @@ return NO; } +- (BOOL)recordable +{ + return [[[[VLCMain sharedInstance] playlistController] playerController] recordable]; +} + +- (BOOL)recordingEnabled +{ + return [[[[VLCMain sharedInstance] playlistController] playerController] enableRecording]; +} + +- (void)setRecordingEnabled:(BOOL)recordingEnabled +{ + [[[[VLCMain sharedInstance] playlistController] playerController] setEnableRecording:recordingEnabled]; +} + +- (BOOL)shuffledPlayback +{ + enum vlc_playlist_playback_order playbackOrder = [[[VLCMain sharedInstance] playlistController] playbackOrder]; + return playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM ? YES : NO; +} + +- (void)setShuffledPlayback:(BOOL)shuffledPlayback +{ + [[[VLCMain sharedInstance] playlistController] setPlaybackOrder: shuffledPlayback ? VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM : VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL]; +} + +- (BOOL)repeatOne +{ + enum vlc_playlist_playback_repeat repeatMode = [[[VLCMain sharedInstance] playlistController] playbackRepeat]; + return repeatMode == VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT ? YES : NO; +} + +- (void)setRepeatOne:(BOOL)repeatOne +{ + [[[VLCMain sharedInstance] playlistController] setPlaybackRepeat: repeatOne == YES ? VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT : VLC_PLAYLIST_PLAYBACK_REPEAT_NONE]; +} + +- (BOOL)repeatAll +{ + enum vlc_playlist_playback_repeat repeatMode = [[[VLCMain sharedInstance] playlistController] playbackRepeat]; + return repeatMode == VLC_PLAYLIST_PLAYBACK_REPEAT_ALL ? YES : NO; +} + +- (void)setRepeatAll:(BOOL)repeatAll +{ + [[[VLCMain sharedInstance] playlistController] setPlaybackRepeat: repeatAll == YES ? VLC_PLAYLIST_PLAYBACK_REPEAT_ALL : VLC_PLAYLIST_PLAYBACK_REPEAT_NONE]; +} + @end _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
