Skip to content

Commit 8ab5a94

Browse files
authored
Merge pull request #859 from roderickvd/fix-album-play
Fix behavior after last track of an album/playlist Partly fixes: #434
2 parents afbdd11 + 0f5d610 commit 8ab5a94

2 files changed

Lines changed: 16 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4646

4747
### Fixed
4848
- [connect] Fix step size on volume up/down events
49+
- [connect] Fix looping back to the first track after the last track of an album or playlist
4950
- [playback] Incorrect `PlayerConfig::default().normalisation_threshold` caused distortion when using dynamic volume normalisation downstream
5051
- [playback] Fix `log` and `cubic` volume controls to be mute at zero volume
5152
- [playback] Fix `S24_3` format on big-endian systems

connect/src/spirc.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -887,8 +887,8 @@ impl SpircTask {
887887
let tracks_len = self.state.get_track().len() as u32;
888888
debug!(
889889
"At track {:?} of {:?} <{:?}> update [{}]",
890-
new_index,
891-
self.state.get_track().len(),
890+
new_index + 1,
891+
tracks_len,
892892
self.state.get_context_uri(),
893893
tracks_len - new_index < CONTEXT_FETCH_THRESHOLD
894894
);
@@ -902,27 +902,25 @@ impl SpircTask {
902902
self.context_fut = self.resolve_station(&context_uri);
903903
self.update_tracks_from_context();
904904
}
905-
let last_track = new_index == tracks_len - 1;
906-
if self.config.autoplay && last_track {
907-
// Extend the playlist
908-
// Note: This doesn't seem to reflect in the UI
909-
// the additional tracks in the frame don't show up as with station view
910-
debug!("Extending playlist <{}>", context_uri);
911-
self.update_tracks_from_context();
912-
}
913905
if new_index >= tracks_len {
914-
new_index = 0; // Loop around back to start
915-
continue_playing = self.state.get_repeat();
906+
if self.config.autoplay {
907+
// Extend the playlist
908+
debug!("Extending playlist <{}>", context_uri);
909+
self.update_tracks_from_context();
910+
self.player.set_auto_normalise_as_album(false);
911+
} else {
912+
new_index = 0;
913+
continue_playing = self.state.get_repeat();
914+
debug!(
915+
"Looping around back to start, repeat is {}",
916+
continue_playing
917+
);
918+
}
916919
}
917920

918921
if tracks_len > 0 {
919922
self.state.set_playing_track_index(new_index);
920923
self.load_track(continue_playing, 0);
921-
if self.config.autoplay && last_track {
922-
// If we're now playing the last track of an album, then
923-
// switch to track normalisation mode for the autoplay to come.
924-
self.player.set_auto_normalise_as_album(false);
925-
}
926924
} else {
927925
info!("Not playing next track because there are no more tracks left in queue.");
928926
self.state.set_playing_track_index(0);

0 commit comments

Comments
 (0)