Add an event posting on track change notification

This event should be helpful for implementing a Last.FM API into the
player once again.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
lastfm
Christopher Snowhill 2022-07-06 12:19:38 -07:00
parent c54062f4bf
commit 05a5c95106
1 changed files with 15 additions and 0 deletions

View File

@ -32,6 +32,8 @@ NSString *CogPlaybackDidPauseNotficiation = @"CogPlaybackDidPauseNotficiation";
NSString *CogPlaybackDidResumeNotficiation = @"CogPlaybackDidResumeNotficiation";
NSString *CogPlaybackDidStopNotficiation = @"CogPlaybackDidStopNotficiation";
NSString *CogPlaybackDidChangeTrackNotification = @"CogPlaybackDidChangeTrackNotification";
@synthesize playbackStatus;
@synthesize progressOverall;
@ -621,6 +623,19 @@ NSDictionary *makeRGInfo(PlaylistEntry *pe) {
[self removeHDCD:nil];
});
if(playlistController.currentEntry) {
NSDictionary *info;
if(pe) {
info = @{ @"previous": playlistController.currentEntry,
@"playPosition": @(playlistController.currentEntry.currentPosition),
@"current": pe };
} else {
info = @{ @"previous": playlistController.currentEntry,
@"playPosition": @(playlistController.currentEntry.currentPosition) };
}
[[NSNotificationCenter defaultCenter] postNotificationName:CogPlaybackDidChangeTrackNotification object:info];
}
if(pe) {
[[NSNotificationCenter defaultCenter] postNotificationName:CogPlaybackDidBeginNotficiation object:pe];
}