From 05a5c9510600e5b552f407688a2541d391be88e8 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Wed, 6 Jul 2022 12:19:38 -0700 Subject: [PATCH] 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 --- Application/PlaybackController.m | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Application/PlaybackController.m b/Application/PlaybackController.m index 350dbea9a..f36510101 100644 --- a/Application/PlaybackController.m +++ b/Application/PlaybackController.m @@ -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]; }