Fix macOS version detection to use a proper API
parent
fc2e6df38f
commit
17bb70e729
|
@ -37,37 +37,26 @@
|
||||||
options:NSKeyValueObservingOptionNew
|
options:NSKeyValueObservingOptionNew
|
||||||
context:nil];
|
context:nil];
|
||||||
|
|
||||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
if (@available(macOS 10.14, *)) {
|
||||||
|
MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter];
|
||||||
|
|
||||||
if ([processInfo respondsToSelector:@selector(isOperatingSystemAtLeastVersion:)]) {
|
[remoteCommandCenter.playCommand setEnabled:YES];
|
||||||
// For some STUPID reason, this interface only really works properly
|
[remoteCommandCenter.pauseCommand setEnabled:YES];
|
||||||
// on Mojave or newer. On the other hand, the fallback interface
|
[remoteCommandCenter.togglePlayPauseCommand setEnabled:YES];
|
||||||
// only stopped working on Catalina
|
[remoteCommandCenter.stopCommand setEnabled:YES];
|
||||||
|
[remoteCommandCenter.changePlaybackPositionCommand setEnabled:YES];
|
||||||
|
[remoteCommandCenter.nextTrackCommand setEnabled:YES];
|
||||||
|
[remoteCommandCenter.previousTrackCommand setEnabled:YES];
|
||||||
|
|
||||||
NSOperatingSystemVersion version = {10,14};
|
[[remoteCommandCenter playCommand] addTarget:self action:@selector(clickPlay)];
|
||||||
if ([processInfo isOperatingSystemAtLeastVersion:version] && NSClassFromString(@"MPRemoteCommandCenter")) {
|
[[remoteCommandCenter pauseCommand] addTarget:self action:@selector(clickPause)];
|
||||||
MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter];
|
[[remoteCommandCenter togglePlayPauseCommand] addTarget:self action:@selector(clickPlay)];
|
||||||
|
[[remoteCommandCenter stopCommand] addTarget:self action:@selector(clickStop)];
|
||||||
[remoteCommandCenter.playCommand setEnabled:YES];
|
[[remoteCommandCenter changePlaybackPositionCommand] addTarget:self action:@selector(clickSeek:)];
|
||||||
[remoteCommandCenter.pauseCommand setEnabled:YES];
|
[[remoteCommandCenter nextTrackCommand] addTarget:self action:@selector(clickNext)];
|
||||||
[remoteCommandCenter.togglePlayPauseCommand setEnabled:YES];
|
[[remoteCommandCenter previousTrackCommand] addTarget:self action:@selector(clickPrev)];
|
||||||
[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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
keyTap = [[SPMediaKeyTap alloc] initWithDelegate:self];
|
keyTap = [[SPMediaKeyTap alloc] initWithDelegate:self];
|
||||||
if([SPMediaKeyTap usesGlobalMediaKeyTap]) {
|
if([SPMediaKeyTap usesGlobalMediaKeyTap]) {
|
||||||
|
|
Loading…
Reference in New Issue