Store AppController<NSApplicationDelegate> in MediaKeysApplication

This commit is contained in:
Dzmitry Neviadomski 2021-02-07 00:33:47 +03:00
parent 5e3ed2af4b
commit 864c56a408

View file

@ -16,10 +16,13 @@
#import <MediaPlayer/MPMediaItem.h> #import <MediaPlayer/MPMediaItem.h>
#import <MediaPlayer/MPRemoteCommandEvent.h> #import <MediaPlayer/MPRemoteCommandEvent.h>
@implementation MediaKeysApplication @implementation MediaKeysApplication {
AppController *_appController;
}
- (void)finishLaunching { - (void)finishLaunching {
[super finishLaunching]; [super finishLaunching];
_appController = (AppController *)[self delegate];
MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter]; MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter];
@ -41,32 +44,32 @@
} }
- (MPRemoteCommandHandlerStatus)clickPlay { - (MPRemoteCommandHandlerStatus)clickPlay {
[(AppController *)[self delegate] clickPlay]; [_appController clickPlay];
return MPRemoteCommandHandlerStatusSuccess; return MPRemoteCommandHandlerStatusSuccess;
} }
- (MPRemoteCommandHandlerStatus)clickPause { - (MPRemoteCommandHandlerStatus)clickPause {
[(AppController *)[self delegate] clickPause]; [_appController clickPause];
return MPRemoteCommandHandlerStatusSuccess; return MPRemoteCommandHandlerStatusSuccess;
} }
- (MPRemoteCommandHandlerStatus)clickStop { - (MPRemoteCommandHandlerStatus)clickStop {
[(AppController *)[self delegate] clickStop]; [_appController clickStop];
return MPRemoteCommandHandlerStatusSuccess; return MPRemoteCommandHandlerStatusSuccess;
} }
- (MPRemoteCommandHandlerStatus)clickNext { - (MPRemoteCommandHandlerStatus)clickNext {
[(AppController *)[self delegate] clickNext]; [_appController clickNext];
return MPRemoteCommandHandlerStatusSuccess; return MPRemoteCommandHandlerStatusSuccess;
} }
- (MPRemoteCommandHandlerStatus)clickPrev { - (MPRemoteCommandHandlerStatus)clickPrev {
[(AppController *)[self delegate] clickPrev]; [_appController clickPrev];
return MPRemoteCommandHandlerStatusSuccess; return MPRemoteCommandHandlerStatusSuccess;
} }
- (MPRemoteCommandHandlerStatus)clickSeek: (MPChangePlaybackPositionCommandEvent*)event { - (MPRemoteCommandHandlerStatus)clickSeek: (MPChangePlaybackPositionCommandEvent*)event {
[(AppController *)[self delegate] clickSeek:event.positionTime]; [_appController clickSeek:event.positionTime];
return MPRemoteCommandHandlerStatusSuccess; return MPRemoteCommandHandlerStatusSuccess;
} }