Fix macOS version detection to use a proper API

CQTexperiment
Christopher Snowhill 2020-03-05 20:34:15 -08:00
parent fc2e6df38f
commit 17bb70e729
1 changed files with 18 additions and 29 deletions

View File

@ -37,15 +37,7 @@
options:NSKeyValueObservingOptionNew options:NSKeyValueObservingOptionNew
context:nil]; context:nil];
NSProcessInfo *processInfo = [NSProcessInfo processInfo]; if (@available(macOS 10.14, *)) {
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
NSOperatingSystemVersion version = {10,14};
if ([processInfo isOperatingSystemAtLeastVersion:version] && NSClassFromString(@"MPRemoteCommandCenter")) {
MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter]; MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter];
[remoteCommandCenter.playCommand setEnabled:YES]; [remoteCommandCenter.playCommand setEnabled:YES];
@ -63,11 +55,8 @@
[[remoteCommandCenter changePlaybackPositionCommand] addTarget:self action:@selector(clickSeek:)]; [[remoteCommandCenter changePlaybackPositionCommand] addTarget:self action:@selector(clickSeek:)];
[[remoteCommandCenter nextTrackCommand] addTarget:self action:@selector(clickNext)]; [[remoteCommandCenter nextTrackCommand] addTarget:self action:@selector(clickNext)];
[[remoteCommandCenter previousTrackCommand] addTarget:self action:@selector(clickPrev)]; [[remoteCommandCenter previousTrackCommand] addTarget:self action:@selector(clickPrev)];
return;
} }
} else
{ {
keyTap = [[SPMediaKeyTap alloc] initWithDelegate:self]; keyTap = [[SPMediaKeyTap alloc] initWithDelegate:self];
if([SPMediaKeyTap usesGlobalMediaKeyTap]) { if([SPMediaKeyTap usesGlobalMediaKeyTap]) {