Skip to content

Commit

Permalink
Prevent unexpected behavior of the headphone button
Browse files Browse the repository at this point in the history
  • Loading branch information
sungholee3526 committed Feb 4, 2018
1 parent ff5e894 commit d697595
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions HighSierraMediaKeyEnabler/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

#import "AppDelegate.h"
#import <MediaPlayer/MediaPlayer.h>

// NSUserDefaults key for the last user-chosen priority option
static NSString *kUserDefaultsPriorityOptionKey = @"user_priority_option";
Expand Down Expand Up @@ -203,6 +204,12 @@ - ( void ) applicationDidFinishLaunching : ( NSNotification*) theNotification
[ menu addItemWithTitle : NSLocalizedString(@"Check for updates", @"Check for updates") action : @selector(update) keyEquivalent : @"" ];
[ menu addItemWithTitle : NSLocalizedString(@"Quit", @"Quit") action : @selector(terminate) keyEquivalent : @"" ];

// Always return success when system media control is sent to the app.
// This will prevent unexpected behavior when the headphone button is pressed.
[[MPRemoteCommandCenter sharedCommandCenter].togglePlayPauseCommand addTargetWithHandler: ^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent *event) {
return MPRemoteCommandHandlerStatusSuccess;
}];

priorityOptionItems = [priorityItems copy];
priorityItems = nil;

Expand Down

0 comments on commit d697595

Please sign in to comment.