[vlc-devel] [vlc-commits] macosx/apple script: remove dependency on core interaction singleton
David Fuhrmann
david.fuhrmann at gmail.com
Sun Apr 14 13:11:23 CEST 2019
> Am 13.04.2019 um 22:10 schrieb Felix Paul Kühne <git at videolan.org>:
>
> vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sat Apr 13 21:19:32 2019 +0200| [53fe076816151f9be1ecd59c92b0e7f051625ba5] | committer: Felix Paul Kühne
>
> macosx/apple script: remove dependency on core interaction singleton
>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=53fe076816151f9be1ecd59c92b0e7f051625ba5
> ---
>
> modules/gui/macosx/os-integration/applescript.h | 4 +-
> modules/gui/macosx/os-integration/applescript.m | 108 ++++++++++++------------
> 2 files changed, 54 insertions(+), 58 deletions(-)
>
> diff --git a/modules/gui/macosx/os-integration/applescript.h b/modules/gui/macosx/os-integration/applescript.h
> index eecfd15a47..2f83864e53 100644
> --- a/modules/gui/macosx/os-integration/applescript.h
> +++ b/modules/gui/macosx/os-integration/applescript.h
> @@ -1,7 +1,7 @@
> /*****************************************************************************
> * applescript.h: MacOS X AppleScript support
> *****************************************************************************
> - * Copyright (C) 2002-2012 VLC authors and VideoLAN
> + * Copyright (C) 2002-2019 VLC authors and VideoLAN
> *
> * Authors: Derk-Jan Hartman <thedj at users.sourceforge.net>
> *
> @@ -40,7 +40,7 @@
> @interface NSApplication(ScriptSupport)
>
> @property (readwrite) BOOL scriptFullscreenMode;
> - at property (readwrite) int audioVolume;
> + at property (readwrite) float audioVolume;
> @property (readwrite) long long audioDesync;
> @property (readwrite) int currentTime;
> @property (readonly) NSInteger durationOfCurrentItem;
> diff --git a/modules/gui/macosx/os-integration/applescript.m b/modules/gui/macosx/os-integration/applescript.m
> index 8e20127548..120d81bb8f 100644
> --- a/modules/gui/macosx/os-integration/applescript.m
> +++ b/modules/gui/macosx/os-integration/applescript.m
> @@ -31,7 +31,6 @@
> #import <vlc_url.h>
>
> #import "main/VLCMain.h"
> -#import "coreinteraction/VLCCoreInteraction.h"
> #import "playlist/VLCPlaylistController.h"
> #import "playlist/VLCPlayerController.h"
> #import "windows/VLCOpenInputMetadata.h"
> @@ -59,7 +58,6 @@
>
> @end
>
> -
> /*****************************************************************************
> * VLControlScriptCommand implementation
> *****************************************************************************/
> @@ -67,86 +65,84 @@
> * This entire control command needs a better design. more object oriented.
> * Applescript developers would be very welcome (hartman)
> */
> +
> @implementation VLControlScriptCommand
>
> - (id)performDefaultImplementation
> {
> + VLCPlaylistController *playlistController;
> + VLCPlayerController *playerController;
Hey,
How is this supposed to work if you never initialise those variables? ;-)
BR. David
> +
> NSString *commandString = [[self commandDescription] commandName];
> NSString *parameterString = [self directParameter];
> - VLCCoreInteraction *coreInteractionInstance = [VLCCoreInteraction sharedInstance];
> -
> - if ([commandString isEqualToString:@"play"])
> - [coreInteractionInstance playOrPause];
> - else if ([commandString isEqualToString:@"stop"])
> - [coreInteractionInstance stop];
> - else if ([commandString isEqualToString:@"previous"])
> - [coreInteractionInstance previous];
> - else if ([commandString isEqualToString:@"next"])
> - [coreInteractionInstance next];
> - else if ([commandString isEqualToString:@"fullscreen"])
> - [coreInteractionInstance toggleFullscreen];
> - else if ([commandString isEqualToString:@"mute"])
> - [coreInteractionInstance toggleMute];
> - else if ([commandString isEqualToString:@"volumeUp"])
> - [coreInteractionInstance volumeUp];
> - else if ([commandString isEqualToString:@"volumeDown"])
> - [coreInteractionInstance volumeDown];
> - else if ([commandString isEqualToString:@"moveMenuFocusUp"])
> - [coreInteractionInstance moveMenuFocusUp];
> - else if ([commandString isEqualToString:@"moveMenuFocusDown"])
> - [coreInteractionInstance moveMenuFocusDown];
> - else if ([commandString isEqualToString:@"moveMenuFocusLeft"])
> - [coreInteractionInstance moveMenuFocusLeft];
> - else if ([commandString isEqualToString:@"moveMenuFocusRight"])
> - [coreInteractionInstance moveMenuFocusRight];
> - else if ([commandString isEqualToString:@"menuFocusActivate"])
> - [coreInteractionInstance menuFocusActivate];
> - else if ([commandString isEqualToString:@"stepForward"]) {
> - //default: forwardShort
> +
> + if ([commandString isEqualToString:@"play"]) {
> + [playerController togglePlayPause];
> + } else if ([commandString isEqualToString:@"stop"]) {
> + [playerController stop];
> + } else if ([commandString isEqualToString:@"previous"]) {
> + [playlistController playPreviousItem];
> + } else if ([commandString isEqualToString:@"next"]) {
> + [playlistController playNextItem];
> + } else if ([commandString isEqualToString:@"fullscreen"]) {
> + [playerController toggleFullscreen];
> + } else if ([commandString isEqualToString:@"mute"]) {
> + [playerController toggleMute];
> + } else if ([commandString isEqualToString:@"volumeUp"]) {
> + [playerController incrementVolume];
> + } else if ([commandString isEqualToString:@"volumeDown"]) {
> + [playerController decrementVolume];
> + } else if ([commandString isEqualToString:@"moveMenuFocusUp"]) {
> + [playerController navigateInInteractiveContent:VLC_PLAYER_NAV_UP];
> + } else if ([commandString isEqualToString:@"moveMenuFocusDown"]) {
> + [playerController navigateInInteractiveContent:VLC_PLAYER_NAV_DOWN];
> + } else if ([commandString isEqualToString:@"moveMenuFocusLeft"]) {
> + [playerController navigateInInteractiveContent:VLC_PLAYER_NAV_LEFT];
> + } else if ([commandString isEqualToString:@"moveMenuFocusRight"]) {
> + [playerController navigateInInteractiveContent:VLC_PLAYER_NAV_RIGHT];
> + } else if ([commandString isEqualToString:@"menuFocusActivate"]) {
> + [playerController navigateInInteractiveContent:VLC_PLAYER_NAV_ACTIVATE];
> + } else if ([commandString isEqualToString:@"stepForward"]) {
> if (parameterString) {
> int parameterInt = [parameterString intValue];
> switch (parameterInt) {
> case 1:
> - [coreInteractionInstance forwardExtraShort];
> - break;
> - case 2:
> - [coreInteractionInstance forwardShort];
> + [playerController jumpForwardExtraShort];
> break;
> case 3:
> - [coreInteractionInstance forwardMedium];
> + [playerController jumpForwardMedium];
> break;
> case 4:
> - [coreInteractionInstance forwardLong];
> + [playerController jumpForwardLong];
> break;
> + case 2:
> default:
> - [coreInteractionInstance forwardShort];
> + [playerController jumpForwardShort];
> break;
> }
> } else
> - [coreInteractionInstance forwardShort];
> + [playerController jumpForwardShort];
> } else if ([commandString isEqualToString:@"stepBackward"]) {
> //default: backwardShort
> if (parameterString) {
> int parameterInt = [parameterString intValue];
> switch (parameterInt) {
> case 1:
> - [coreInteractionInstance backwardExtraShort];
> - break;
> - case 2:
> - [coreInteractionInstance backwardShort];
> + [playerController jumpBackwardExtraShort];
> break;
> case 3:
> - [coreInteractionInstance backwardMedium];
> + [playerController jumpBackwardMedium];
> break;
> case 4:
> - [coreInteractionInstance backwardLong];
> + [playerController jumpBackwardLong];
> break;
> + case 2:
> default:
> - [coreInteractionInstance backwardShort];
> + [playerController jumpBackwardShort];
> break;
> }
> } else
> - [coreInteractionInstance backwardShort];
> + [playerController jumpBackwardShort];
> }
> return nil;
> }
> @@ -170,7 +166,7 @@
>
> - (BOOL)muted
> {
> - return [[VLCCoreInteraction sharedInstance] mute];
> + return [[[[VLCMain sharedInstance] playlistController] playerController] mute];
> }
>
> - (BOOL)playing
> @@ -184,14 +180,14 @@
> return NO;
> }
>
> -- (int)audioVolume
> +- (float)audioVolume
> {
> - return [[VLCCoreInteraction sharedInstance] volume];
> + return [[[[VLCMain sharedInstance] playlistController] playerController] volume];
> }
>
> -- (void)setAudioVolume:(int)volume
> +- (void)setAudioVolume:(float)volume
> {
> - [[VLCCoreInteraction sharedInstance] setVolume:volume];
> + [[[[VLCMain sharedInstance] playlistController] playerController] setVolume:volume];
> }
>
> - (long long)audioDesync
> @@ -216,17 +212,17 @@
>
> - (NSInteger)durationOfCurrentItem
> {
> - return [[VLCCoreInteraction sharedInstance] durationOfCurrentPlaylistItem];
> + return SEC_FROM_VLC_TICK([[[VLCMain sharedInstance] playlistController] playerController].durationOfCurrentMediaItem);
> }
>
> - (NSString *)pathOfCurrentItem
> {
> - return [[[VLCCoreInteraction sharedInstance] URLOfCurrentPlaylistItem] path];
> + return [[[[VLCMain sharedInstance] playlistController] playerController].URLOfCurrentMediaItem path];
> }
>
> - (NSString *)nameOfCurrentItem
> {
> - return [[VLCCoreInteraction sharedInstance] nameOfCurrentPlaylistItem];
> + return [[[[VLCMain sharedInstance] playlistController] playerController] nameOfCurrentMediaItem];
> }
>
> - (BOOL)playbackShowsMenu
>
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits
More information about the vlc-devel
mailing list