Merge pull request #859 from roderickvd/fix-album-play

Fix behavior after last track of an album/playlist

Partly fixes: #434
This commit is contained in:
Roderick van Domburg 2021-10-13 20:33:57 +02:00 committed by GitHub
commit 8ab5a94451
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 17 deletions

View file

@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- [connect] Fix step size on volume up/down events - [connect] Fix step size on volume up/down events
- [connect] Fix looping back to the first track after the last track of an album or playlist
- [playback] Incorrect `PlayerConfig::default().normalisation_threshold` caused distortion when using dynamic volume normalisation downstream - [playback] Incorrect `PlayerConfig::default().normalisation_threshold` caused distortion when using dynamic volume normalisation downstream
- [playback] Fix `log` and `cubic` volume controls to be mute at zero volume - [playback] Fix `log` and `cubic` volume controls to be mute at zero volume
- [playback] Fix `S24_3` format on big-endian systems - [playback] Fix `S24_3` format on big-endian systems

View file

@ -887,8 +887,8 @@ impl SpircTask {
let tracks_len = self.state.get_track().len() as u32; let tracks_len = self.state.get_track().len() as u32;
debug!( debug!(
"At track {:?} of {:?} <{:?}> update [{}]", "At track {:?} of {:?} <{:?}> update [{}]",
new_index, new_index + 1,
self.state.get_track().len(), tracks_len,
self.state.get_context_uri(), self.state.get_context_uri(),
tracks_len - new_index < CONTEXT_FETCH_THRESHOLD tracks_len - new_index < CONTEXT_FETCH_THRESHOLD
); );
@ -902,27 +902,25 @@ impl SpircTask {
self.context_fut = self.resolve_station(&context_uri); self.context_fut = self.resolve_station(&context_uri);
self.update_tracks_from_context(); self.update_tracks_from_context();
} }
let last_track = new_index == tracks_len - 1;
if self.config.autoplay && last_track {
// Extend the playlist
// Note: This doesn't seem to reflect in the UI
// the additional tracks in the frame don't show up as with station view
debug!("Extending playlist <{}>", context_uri);
self.update_tracks_from_context();
}
if new_index >= tracks_len { if new_index >= tracks_len {
new_index = 0; // Loop around back to start if self.config.autoplay {
continue_playing = self.state.get_repeat(); // Extend the playlist
debug!("Extending playlist <{}>", context_uri);
self.update_tracks_from_context();
self.player.set_auto_normalise_as_album(false);
} else {
new_index = 0;
continue_playing = self.state.get_repeat();
debug!(
"Looping around back to start, repeat is {}",
continue_playing
);
}
} }
if tracks_len > 0 { if tracks_len > 0 {
self.state.set_playing_track_index(new_index); self.state.set_playing_track_index(new_index);
self.load_track(continue_playing, 0); self.load_track(continue_playing, 0);
if self.config.autoplay && last_track {
// If we're now playing the last track of an album, then
// switch to track normalisation mode for the autoplay to come.
self.player.set_auto_normalise_as_album(false);
}
} else { } else {
info!("Not playing next track because there are no more tracks left in queue."); info!("Not playing next track because there are no more tracks left in queue.");
self.state.set_playing_track_index(0); self.state.set_playing_track_index(0);