Store AppController<NSApplicationDelegate> in MediaKeysApplication

CQTexperiment
Dzmitry Neviadomski 2021-02-07 00:33:47 +03:00
parent 5e3ed2af4b
commit 864c56a408
1 changed files with 10 additions and 7 deletions

View File

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