Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #611 from BarakaAka1Only/master
Browse files Browse the repository at this point in the history
Adds a feature request for pausing currently playing music on screen lock
  • Loading branch information
jacobwgillespie authored Sep 22, 2016
2 parents 39b2924 + c052f72 commit ab7d1f0
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 90 deletions.
41 changes: 41 additions & 0 deletions radiant-player-mac/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions radiant-player-mac/Preferences.plist
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@
<false/>
<key>WebKitDeveloperExtras</key>
<true/>
<key>toggleMusicOnScreenLock</key>
<false/>
</dict>
</plist>
Loading

0 comments on commit ab7d1f0

Please sign in to comment.