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

Added distributed notifications #647

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions radiant-player-mac/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,11 @@ - (void)notifySong:(NSString *)title withArtist:(NSString *)artist album:(NSStri
{
[[NotificationCenter center] scheduleNotificationWithTitle:title artist:artist album:album imageURL:art];
}

if (![defaults boolForKey:@"disableDistributednotifications"])
{
[[NotificationCenter center] postDistributedNotificationWithTitle:title artist:artist album:album imageURL:art];
}

if ([defaults boolForKey:@"dock.show-art"])
{
Expand Down
2 changes: 1 addition & 1 deletion radiant-player-mac/Notifications/NotificationCenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ typedef NS_ENUM(NSInteger, NotificationActivationType) {

+ (NotificationCenter *) center;
- (void) scheduleNotificationWithTitle:(NSString *)title artist:(NSString *)artist album:(NSString *)album imageURL:(NSString *)imageURL;

- (void) postDistributedNotificationWithTitle:(NSString *)title artist:(NSString *)artist album:(NSString *)album imageURL:(NSString *)imageURL;
@end
8 changes: 8 additions & 0 deletions radiant-player-mac/Notifications/NotificationCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ - (void)_scheduleNSUserNotificationWithTitle:(NSString *)title artist:(NSString
[[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification:notif];
}

- (void) postDistributedNotificationWithTitle:(NSString *)title artist:(NSString *)artist album:(NSString *)album imageURL:(NSString *)imageURL
{
NSDistributedNotificationCenter *center = [NSDistributedNotificationCenter defaultCenter];
NSDictionary *userInfo = @{@"title" : title, @"artist" : artist, @"album" : album, @"albumArtURL" : imageURL};

[center postNotificationName:@"com.sajidanwar.Radiant-Player.PlaybackStateChange" object:nil userInfo:userInfo options:NSDistributedNotificationDeliverImmediately];
}

- (void)_scheduleGrowlNotificationWithTitle:(NSString *)title artist:(NSString *)artist album:(NSString *)album image:(NSImage *)image
{
NSData *imageData = [NSData data];
Expand Down