mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Fix behavior after last track of an album/playlist
* When autoplay is disabled, then loop back to the first track instead of 10 tracks back. Continue or stop playing depending on the state of the repeat button. * When autoplay is enabled, then extend the playlist *after* the last track. #844 broke this such that the last track of an album or playlist was never played. Fixes: #434
This commit is contained in:
parent
095536f100
commit
289b4f9bcc
2 changed files with 16 additions and 30 deletions
|
@ -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
|
||||||
|
|
|
@ -84,7 +84,6 @@ struct SpircTaskConfig {
|
||||||
autoplay: bool,
|
autoplay: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
const CONTEXT_TRACKS_HISTORY: usize = 10;
|
|
||||||
const CONTEXT_FETCH_THRESHOLD: u32 = 5;
|
const CONTEXT_FETCH_THRESHOLD: u32 = 5;
|
||||||
|
|
||||||
const VOLUME_STEPS: i64 = 64;
|
const VOLUME_STEPS: i64 = 64;
|
||||||
|
@ -887,8 +886,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 +901,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 new_index >= tracks_len {
|
||||||
if self.config.autoplay && last_track {
|
if self.config.autoplay {
|
||||||
// Extend the playlist
|
// 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);
|
debug!("Extending playlist <{}>", context_uri);
|
||||||
self.update_tracks_from_context();
|
self.update_tracks_from_context();
|
||||||
}
|
self.player.set_auto_normalise_as_album(false);
|
||||||
if new_index >= tracks_len {
|
} else {
|
||||||
new_index = 0; // Loop around back to start
|
new_index = 0;
|
||||||
continue_playing = self.state.get_repeat();
|
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);
|
||||||
|
@ -1054,21 +1051,9 @@ impl SpircTask {
|
||||||
let new_tracks = &context.tracks;
|
let new_tracks = &context.tracks;
|
||||||
debug!("Adding {:?} tracks from context to frame", new_tracks.len());
|
debug!("Adding {:?} tracks from context to frame", new_tracks.len());
|
||||||
let mut track_vec = self.state.take_track().into_vec();
|
let mut track_vec = self.state.take_track().into_vec();
|
||||||
if let Some(head) = track_vec.len().checked_sub(CONTEXT_TRACKS_HISTORY) {
|
|
||||||
track_vec.drain(0..head);
|
|
||||||
}
|
|
||||||
track_vec.extend_from_slice(new_tracks);
|
track_vec.extend_from_slice(new_tracks);
|
||||||
self.state
|
self.state
|
||||||
.set_track(protobuf::RepeatedField::from_vec(track_vec));
|
.set_track(protobuf::RepeatedField::from_vec(track_vec));
|
||||||
|
|
||||||
// Update playing index
|
|
||||||
if let Some(new_index) = self
|
|
||||||
.state
|
|
||||||
.get_playing_track_index()
|
|
||||||
.checked_sub(CONTEXT_TRACKS_HISTORY as u32)
|
|
||||||
{
|
|
||||||
self.state.set_playing_track_index(new_index);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
warn!("No context to update from!");
|
warn!("No context to update from!");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue