Skip to content

Commit

Permalink
connect: fix: shuffle on startup isn't applied
Browse files Browse the repository at this point in the history
  • Loading branch information
photovoltex committed Nov 16, 2024
1 parent 93c5655 commit b52a176
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions connect/src/spirc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,19 +919,19 @@ impl SpircTask {
RequestCommand::Play(play) => {
let shuffle = play
.options
.player_options_overrides
.player_options_override
.as_ref()
.map(|o| o.shuffling_context)
.unwrap_or_else(|| self.connect_state.shuffling_context());
let repeat = play
.options
.player_options_overrides
.player_options_override
.as_ref()
.map(|o| o.repeating_context)
.unwrap_or_else(|| self.connect_state.repeat_context());
let repeat_track = play
.options
.player_options_overrides
.player_options_override
.as_ref()
.map(|o| o.repeating_track)
.unwrap_or_else(|| self.connect_state.repeat_track());
Expand Down Expand Up @@ -1179,7 +1179,14 @@ impl SpircTask {
}
};

debug!(
"loading with shuffle: <{}>, repeat track: <{}> context: <{}>",
cmd.shuffle, cmd.repeat, cmd.repeat_track
);

self.connect_state.set_shuffle(cmd.shuffle);
self.connect_state.set_repeat_context(cmd.repeat);

if cmd.shuffle {
self.connect_state.active_context = ContextType::Default;
self.connect_state.set_current_track(index)?;
Expand All @@ -1190,7 +1197,6 @@ impl SpircTask {
self.connect_state.reset_playback_context(Some(index))?;
}

self.connect_state.set_repeat_context(cmd.repeat);
self.connect_state.set_repeat_track(cmd.repeat_track);

if self.connect_state.current_track(MessageField::is_some) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/dealer/protocol/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub struct TransferOptions {
pub struct PlayOptions {
pub skip_to: SkipTo,
#[serde(default, deserialize_with = "option_json_proto")]
pub player_options_overrides: Option<ContextPlayerOptionOverrides>,
pub player_options_override: Option<ContextPlayerOptionOverrides>,
pub license: String,
// mobile
pub always_play_something: Option<bool>,
Expand Down

0 comments on commit b52a176

Please sign in to comment.