diff --git a/radiant-player-mac/AppDelegate.m b/radiant-player-mac/AppDelegate.m index 3f0dbeee..a781a74d 100644 --- a/radiant-player-mac/AppDelegate.m +++ b/radiant-player-mac/AppDelegate.m @@ -70,6 +70,27 @@ - (void)receiveSleepNotification:(NSNotification*)notification [self playPause:self]; } +#pragma mark - screen locked/unlocked events + +- (void)RadiantScreenLocked { + + if ([defaults boolForKey:@"toggleMusicOnScreenLock"]) + { + if (currentPlaybackMode == MUSIC_PLAYING) { + [self playPause:self]; + } + } +} + +- (void)RadiantScreenUnlocked { + if ([defaults boolForKey:@"toggleMusicOnScreenLock"]) + { + if (currentPlaybackMode == MUSIC_PAUSED) { + [self playPause:self]; + } + } +} + /** * Application finished launching, we will register the event tap callback. */ @@ -254,6 +275,26 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification // Register for machine sleep notifications [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(receiveSleepNotification:) name:NSWorkspaceWillSleepNotification object:nil]; + + // Register screen locked/unlocked events + [[NSDistributedNotificationCenter defaultCenter] addObserver:self + selector:@selector(RadiantScreenLocked) + name:@"com.apple.screenIsLocked" + object:nil]; + + [[NSDistributedNotificationCenter defaultCenter] addObserver:self + selector:@selector(RadiantScreenUnlocked) + name:@"com.apple.screenIsUnlocked" + object:nil]; + + [[NSDistributedNotificationCenter defaultCenter] addObserver: self + selector: @selector(RadiantScreenLocked) + name: @"com.apple.sessionDidMoveOffConsole" + object: nil]; + [[NSDistributedNotificationCenter defaultCenter] addObserver: self + selector: @selector(RadiantScreenUnlocked) + name: @"com.apple.sessionDidMoveOnConsole" + object: nil]; } - (NSMutableDictionary *)styles diff --git a/radiant-player-mac/Preferences.plist b/radiant-player-mac/Preferences.plist index 9129904c..39c50979 100644 --- a/radiant-player-mac/Preferences.plist +++ b/radiant-player-mac/Preferences.plist @@ -56,5 +56,7 @@ WebKitDeveloperExtras + toggleMusicOnScreenLock + diff --git a/radiant-player-mac/Preferences/PreferencesWindowController.xib b/radiant-player-mac/Preferences/PreferencesWindowController.xib index e9d46034..d8968603 100644 --- a/radiant-player-mac/Preferences/PreferencesWindowController.xib +++ b/radiant-player-mac/Preferences/PreferencesWindowController.xib @@ -1,8 +1,8 @@ - + - + @@ -17,13 +17,12 @@ - + - + - @@ -31,9 +30,8 @@ - + - @@ -87,9 +82,8 @@ - + - @@ -122,9 +114,8 @@ - + - @@ -132,9 +123,8 @@ - + - @@ -142,9 +132,8 @@ - + - @@ -152,9 +141,8 @@ - + - @@ -162,9 +150,8 @@ - + - @@ -206,9 +191,8 @@ - + - @@ -229,9 +212,8 @@ + + + + + + + + + + + + + + + + + + + - - + @@ -268,7 +277,6 @@ - @@ -491,13 +484,11 @@ with moving the window or the player freezing - - @@ -507,7 +498,6 @@ with moving the window or the player freezing