Browse Source

Add MediaPlayer stop command and correctly handle return values for all MediaPlayer remote events

master
Christopher Snowhill 4 months ago
parent
commit
6847f1bcbf
1 changed files with 34 additions and 6 deletions
  1. +34
    -6
      Application/MediaKeysApplication.m

+ 34
- 6
Application/MediaKeysApplication.m View File

@@ -43,16 +43,18 @@
[remoteCommandCenter.playCommand setEnabled:YES];
[remoteCommandCenter.pauseCommand setEnabled:YES];
[remoteCommandCenter.togglePlayPauseCommand setEnabled:YES];
[remoteCommandCenter.stopCommand setEnabled:YES];
[remoteCommandCenter.changePlaybackPositionCommand setEnabled:YES];
[remoteCommandCenter.nextTrackCommand setEnabled:YES];
[remoteCommandCenter.previousTrackCommand setEnabled:YES];
[[remoteCommandCenter playCommand] addTarget:[self delegate] action:@selector(clickPlay)];
[[remoteCommandCenter pauseCommand] addTarget:[self delegate] action:@selector(clickPause)];
[[remoteCommandCenter togglePlayPauseCommand] addTarget:[self delegate] action:@selector(clickPlay)];
[[remoteCommandCenter playCommand] addTarget:self action:@selector(clickPlay)];
[[remoteCommandCenter pauseCommand] addTarget:self action:@selector(clickPause)];
[[remoteCommandCenter togglePlayPauseCommand] addTarget:self action:@selector(clickPlay)];
[[remoteCommandCenter stopCommand] addTarget:self action:@selector(clickStop)];
[[remoteCommandCenter changePlaybackPositionCommand] addTarget:self action:@selector(clickSeek:)];
[[remoteCommandCenter nextTrackCommand] addTarget:[self delegate] action:@selector(clickNext)];
[[remoteCommandCenter previousTrackCommand] addTarget:[self delegate] action:@selector(clickPrev)];
[[remoteCommandCenter nextTrackCommand] addTarget:self action:@selector(clickNext)];
[[remoteCommandCenter previousTrackCommand] addTarget:self action:@selector(clickPrev)];
} else {
keyTap = [[SPMediaKeyTap alloc] initWithDelegate:self];
if([SPMediaKeyTap usesGlobalMediaKeyTap]) {
@@ -63,8 +65,34 @@
}
}

- (void)clickSeek: (MPChangePlaybackPositionCommandEvent*)event {
- (MPRemoteCommandHandlerStatus)clickPlay {
[(AppController *)[self delegate] clickPlay];
return MPRemoteCommandHandlerStatusSuccess;
}

- (MPRemoteCommandHandlerStatus)clickPause {
[(AppController *)[self delegate] clickPause];
return MPRemoteCommandHandlerStatusSuccess;
}

- (MPRemoteCommandHandlerStatus)clickStop {
[(AppController *)[self delegate] clickStop];
return MPRemoteCommandHandlerStatusSuccess;
}

- (MPRemoteCommandHandlerStatus)clickNext {
[(AppController *)[self delegate] clickNext];
return MPRemoteCommandHandlerStatusSuccess;
}

- (MPRemoteCommandHandlerStatus)clickPrev {
[(AppController *)[self delegate] clickPrev];
return MPRemoteCommandHandlerStatusSuccess;
}

- (MPRemoteCommandHandlerStatus)clickSeek: (MPChangePlaybackPositionCommandEvent*)event {
[(AppController *)[self delegate] clickSeek:event.positionTime];
return MPRemoteCommandHandlerStatusSuccess;
}

- (void)sendEvent: (NSEvent*)event


Loading…
Cancel
Save