mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-06 03:50:06 +02:00
Merge f0d6afe3e7
into a407beaa45
This commit is contained in:
commit
5b52ec0db9
3 changed files with 27 additions and 6 deletions
|
@ -19,6 +19,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- [player] `preload` function changed from accepting a `SpotifyId` to accepting a `SpotifyUri` (breaking)
|
||||
- [spclient] `get_radio_for_track` function changed from accepting a `SpotifyId` to accepting a `SpotifyUri` (breaking)
|
||||
|
||||
### Fixed
|
||||
|
||||
- [connect] Use the provided index or the first as fallback value to always play a track on loading
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -651,7 +651,7 @@ impl SpircTask {
|
|||
SpircCommand::RepeatTrack(repeat) => self.handle_repeat_track(repeat),
|
||||
SpircCommand::SetPosition(position) => self.handle_seek(position),
|
||||
SpircCommand::SetVolume(volume) => self.set_volume(volume),
|
||||
SpircCommand::Load(command) => self.handle_load(command, None).await?,
|
||||
SpircCommand::Load(command) => self.handle_load(command, None, None).await?,
|
||||
};
|
||||
|
||||
self.notify().await
|
||||
|
@ -998,6 +998,13 @@ impl SpircTask {
|
|||
.map(Into::into)
|
||||
.map(LoadContextOptions::Options);
|
||||
|
||||
let fallback_index = play
|
||||
.options
|
||||
.skip_to
|
||||
.as_ref()
|
||||
.and_then(|s| s.track_index)
|
||||
.map(|i| i as usize);
|
||||
|
||||
self.handle_load(
|
||||
LoadRequest {
|
||||
context,
|
||||
|
@ -1009,6 +1016,7 @@ impl SpircTask {
|
|||
},
|
||||
},
|
||||
play.context.pages.pop(),
|
||||
fallback_index,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
@ -1217,6 +1225,7 @@ impl SpircTask {
|
|||
&mut self,
|
||||
cmd: LoadRequest,
|
||||
page: Option<ContextPage>,
|
||||
fallback_index: Option<usize>,
|
||||
) -> Result<(), Error> {
|
||||
self.connect_state
|
||||
.reset_context(if let PlayContext::Uri(ref uri) = cmd.context {
|
||||
|
@ -1253,17 +1262,26 @@ impl SpircTask {
|
|||
let index = match cmd_options.playing_track {
|
||||
None => None,
|
||||
Some(ref playing_track) => Some(match playing_track {
|
||||
PlayingTrack::Index(i) => *i as usize,
|
||||
PlayingTrack::Index(i) => Ok(*i as usize),
|
||||
PlayingTrack::Uri(uri) => {
|
||||
let ctx = self.connect_state.get_context(ContextType::Default)?;
|
||||
ConnectState::find_index_in_context(ctx, |t| &t.uri == uri)?
|
||||
ConnectState::find_index_in_context(ctx, |t| &t.uri == uri)
|
||||
}
|
||||
PlayingTrack::Uid(uid) => {
|
||||
let ctx = self.connect_state.get_context(ContextType::Default)?;
|
||||
ConnectState::find_index_in_context(ctx, |t| &t.uid == uid)?
|
||||
ConnectState::find_index_in_context(ctx, |t| &t.uid == uid)
|
||||
}
|
||||
}),
|
||||
};
|
||||
}
|
||||
.map(|i| {
|
||||
i.unwrap_or_else(|why| {
|
||||
warn!(
|
||||
"Failed to resolve index by {:?}, using fallback index: {:?} (Error: {why})",
|
||||
cmd_options.playing_track, fallback_index
|
||||
);
|
||||
fallback_index.unwrap_or_default()
|
||||
})
|
||||
});
|
||||
|
||||
if let Some(LoadContextOptions::Options(ref options)) = cmd_options.context_options {
|
||||
debug!(
|
||||
|
|
|
@ -406,7 +406,7 @@ fn launch_libmdns(
|
|||
}
|
||||
.map_err(|e| DiscoveryError::DnsSdError(Box::new(e)))?;
|
||||
|
||||
let svc = responder.register(&DNS_SD_SERVICE_NAME, &name, port, &TXT_RECORD);
|
||||
let svc = responder.register(DNS_SD_SERVICE_NAME, &name, port, &TXT_RECORD);
|
||||
|
||||
let _ = shutdown_rx.blocking_recv();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue