diff --git a/Application/MediaKeysApplication.m b/Application/MediaKeysApplication.m index 60c645750..a62117c8c 100644 --- a/Application/MediaKeysApplication.m +++ b/Application/MediaKeysApplication.m @@ -37,37 +37,26 @@ options:NSKeyValueObservingOptionNew context:nil]; - NSProcessInfo *processInfo = [NSProcessInfo processInfo]; - - if ([processInfo respondsToSelector:@selector(isOperatingSystemAtLeastVersion:)]) { - // For some STUPID reason, this interface only really works properly - // on Mojave or newer. On the other hand, the fallback interface - // only stopped working on Catalina + if (@available(macOS 10.14, *)) { + MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter]; - NSOperatingSystemVersion version = {10,14}; - if ([processInfo isOperatingSystemAtLeastVersion:version] && NSClassFromString(@"MPRemoteCommandCenter")) { - MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter]; - - [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 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 action:@selector(clickNext)]; - [[remoteCommandCenter previousTrackCommand] addTarget:self action:@selector(clickPrev)]; - - return; - } + [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 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 action:@selector(clickNext)]; + [[remoteCommandCenter previousTrackCommand] addTarget:self action:@selector(clickPrev)]; } - + else { keyTap = [[SPMediaKeyTap alloc] initWithDelegate:self]; if([SPMediaKeyTap usesGlobalMediaKeyTap]) {