diff --git a/Application/PlaybackController.h b/Application/PlaybackController.h index 584b42b47..f2f8f6432 100644 --- a/Application/PlaybackController.h +++ b/Application/PlaybackController.h @@ -72,6 +72,9 @@ - (void)playEntryAtIndex:(int)i; - (void)playEntry:(PlaylistEntry *)pe; +// Playlist notifications +- (void)playlistDidChange:(PlaylistController *)p; + // For bindings - (void)setPosition:(double)p; diff --git a/Application/PlaybackController.m b/Application/PlaybackController.m index eeadd2106..4ad1cb545 100644 --- a/Application/PlaybackController.m +++ b/Application/PlaybackController.m @@ -549,6 +549,11 @@ playbackStatus = status; } +- (void)playlistDidChange:(PlaylistController *)p +{ + [audioPlayer resetNextStreams]; +} + - (void)setPosition:(double)p { position = p; diff --git a/Audio/AudioPlayer.h b/Audio/AudioPlayer.h index b24b46dad..334e78159 100644 --- a/Audio/AudioPlayer.h +++ b/Audio/AudioPlayer.h @@ -50,6 +50,7 @@ - (void)setNextStream:(NSURL *)url; - (void)setNextStream:(NSURL *)url withUserInfo:(id)userInfo; +- (void)resetNextStreams; + (NSArray *)fileTypes; + (NSArray *)schemes; @@ -68,6 +69,7 @@ - (void)requestNextStream:(id)userInfo; - (void)requestNextStreamMainThread:(id)userInfo; + - (void)notifyStreamChanged:(id)userInfo; - (void)notifyStreamChangedMainThread:(id)userInfo; diff --git a/Audio/AudioPlayer.m b/Audio/AudioPlayer.m index 698e49b6e..0a5e246a7 100644 --- a/Audio/AudioPlayer.m +++ b/Audio/AudioPlayer.m @@ -164,6 +164,16 @@ } +// Called when the playlist changed before we actually started playing a requested stream. We will re-request. +- (void)resetNextStreams +{ + @synchronized (chainQueue) { + [chainQueue removeAllObjects]; + } + + [self endOfInputReached:bufferChain]; +} + - (void)setShouldContinue:(BOOL)s { diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 42360cfb6..5555c146e 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -166,6 +166,8 @@ if (lowerIndex != NSNotFound) index = lowerIndex; } + + [playbackController playlistDidChange:self]; } - (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard @@ -308,6 +310,8 @@ if ([self shuffle] == YES) [self resetShuffleList]; + + [playbackController playlistDidChange:self]; } - (void)setSortDescriptors:(NSArray *)sortDescriptors @@ -326,6 +330,8 @@ [super setSortDescriptors:sortDescriptors]; [self rearrangeObjects]; + + [playbackController playlistDidChange:self]; } - (IBAction)sortByPath