Skip to content

Commit accecb6

Browse files
committed
Merge commit 'refs/pull/1528/head' of https://github.com/librespot-org/librespot into mass
2 parents c7ed80c + bcfc88d commit accecb6

File tree

33 files changed

+604
-256
lines changed

33 files changed

+604
-256
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- [connect] Replaced `SpircLoadCommand` with `LoadRequest`, `LoadRequestOptions` and `LoadContextOptions` (breaking)
1717
- [connect] Moved all public items to the highest level (breaking)
1818
- [connect] Replaced Mercury usage in `Spirc` with Dealer
19+
- [metadata] Replaced `AudioFileFormat` with own enum. (breaking)
20+
- [playback] Changed trait `Mixer::open` to return `Result<Self, Error>` instead of `Self` (breaking)
21+
- [playback] Changed type alias `MixerFn` to return `Result<Arc<dyn Mixer>, Error>` instead of `Arc<dyn Mixer>` (breaking)
1922

2023
### Added
2124

25+
- [connect] Add command line parameter for setting volume steps.
2226
- [connect] Add support for `seek_to`, `repeat_track` and `autoplay` for `Spirc` loading
2327
- [connect] Add `pause` parameter to `Spirc::disconnect` method (breaking)
2428
- [connect] Add `volume_steps` to `ConnectConfig` (breaking)
2529
- [connect] Add and enforce rustdoc
2630
- [playback] Add `track` field to `PlayerEvent::RepeatChanged` (breaking)
31+
- [playback] Add `PlayerEvent::PositionChanged` event to notify about the current playback position
2732
- [core] Add `request_with_options` and `request_with_protobuf_and_options` to `SpClient`
2833
- [oauth] Add `OAuthClient` and `OAuthClientBuilder` structs to achieve a more customizable login process
2934

@@ -39,8 +44,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3944
- [connect] Fix "play" command not handled if missing "offset" property
4045
- [discovery] Fix libmdns zerconf setup errors not propagating to the main task.
4146
- [metadata] `Show::trailer_uri` is now optional since it isn't always present (breaking)
47+
- [metadata] Fix incorrect parsing of audio format
4248
- [connect] Handle transfer of playback with empty "uri" field
4349
- [connect] Correctly apply playing/paused state when transferring playback
50+
- [player] Saturate invalid seek positions to track duration
51+
- [core] Metadata requests failing with 500 Internal Server Error
4452

4553
### Deprecated
4654

@@ -49,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4957
### Removed
5058

5159
- [core] Removed `get_canvases` from SpClient (breaking)
60+
- [core] DeviceType `homething` removed due to crashes on Android (breaking)
5261
- [metadata] Removed `genres` from Album (breaking)
5362
- [metadata] Removed `genre` from Artists (breaking)
5463

Cargo.lock

Lines changed: 4 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

connect/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async fn create_basic_spirc() -> Result<(), Error> {
5555
session,
5656
credentials,
5757
player,
58-
mixer(MixerConfig::default())
58+
mixer(MixerConfig::default())?
5959
).await?;
6060

6161
Ok(())

connect/src/context_resolver.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ impl ResolveContext {
7676
// otherwise we might not even check if we need to fallback and just use the fallback uri
7777
match self.resolve {
7878
Resolve::Uri(ref uri) => ConnectState::valid_resolve_uri(uri),
79-
Resolve::Context(ref ctx) => ConnectState::get_context_uri_from_context(ctx),
79+
Resolve::Context(ref ctx) => {
80+
ConnectState::find_valid_uri(ctx.uri.as_deref(), ctx.pages.first())
81+
}
8082
}
8183
.or(self.fallback.as_deref())
8284
}
@@ -260,7 +262,7 @@ impl ContextResolver {
260262
ContextAction::Replace => {
261263
let remaining = state.update_context(context, next.update);
262264
if let Resolve::Context(ref ctx) = next.resolve {
263-
state.merge_context(Some(ctx.clone()));
265+
state.merge_context(ctx.pages.clone().pop());
264266
}
265267

266268
remaining

connect/src/model.rs

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use crate::{
55
use std::ops::Deref;
66

77
/// Request for loading playback
8-
#[derive(Debug)]
8+
#[derive(Debug, Clone)]
99
pub struct LoadRequest {
10-
pub(super) context_uri: String,
10+
pub(super) context: PlayContext,
1111
pub(super) options: LoadRequestOptions,
1212
}
1313

@@ -19,8 +19,14 @@ impl Deref for LoadRequest {
1919
}
2020
}
2121

22+
#[derive(Debug, Clone)]
23+
pub(super) enum PlayContext {
24+
Uri(String),
25+
Tracks(Vec<String>),
26+
}
27+
2228
/// The parameters for creating a load request
23-
#[derive(Debug, Default)]
29+
#[derive(Debug, Default, Clone)]
2430
pub struct LoadRequestOptions {
2531
/// Whether the given tracks should immediately start playing, or just be initially loaded.
2632
pub start_playing: bool,
@@ -44,7 +50,7 @@ pub struct LoadRequestOptions {
4450
///
4551
/// Separated into an `enum` to exclude the other variants from being used
4652
/// simultaneously, as they are not compatible.
47-
#[derive(Debug)]
53+
#[derive(Debug, Clone)]
4854
pub enum LoadContextOptions {
4955
/// Starts the context with options
5056
Options(Options),
@@ -56,7 +62,7 @@ pub enum LoadContextOptions {
5662
}
5763

5864
/// The available options that indicate how to start the context
59-
#[derive(Debug, Default)]
65+
#[derive(Debug, Default, Clone)]
6066
pub struct Options {
6167
/// Start the context in shuffle mode
6268
pub shuffle: bool,
@@ -80,16 +86,30 @@ impl LoadRequest {
8086
/// Create a load request from a `context_uri`
8187
///
8288
/// For supported `context_uri` see [`SpClient::get_context`](librespot_core::spclient::SpClient::get_context)
89+
///
90+
/// Equivalent to using [`/me/player/play`](https://developer.spotify.com/documentation/web-api/reference/start-a-users-playback)
91+
/// and providing `context_uri`
8392
pub fn from_context_uri(context_uri: String, options: LoadRequestOptions) -> Self {
8493
Self {
85-
context_uri,
94+
context: PlayContext::Uri(context_uri),
95+
options,
96+
}
97+
}
98+
99+
/// Create a load request from a set of `tracks`
100+
///
101+
/// Equivalent to using [`/me/player/play`](https://developer.spotify.com/documentation/web-api/reference/start-a-users-playback)
102+
/// and providing `uris`
103+
pub fn from_tracks(tracks: Vec<String>, options: LoadRequestOptions) -> Self {
104+
Self {
105+
context: PlayContext::Tracks(tracks),
86106
options,
87107
}
88108
}
89109
}
90110

91111
/// An item that represent a track to play
92-
#[derive(Debug)]
112+
#[derive(Debug, Clone)]
93113
pub enum PlayingTrack {
94114
/// Represent the track at a given index.
95115
Index(u32),

connect/src/shuffle_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<T> ShuffleVec<T> {
5555
self.unshuffle()
5656
}
5757

58-
let indices = {
58+
let indices: Vec<_> = {
5959
(1..self.vec.len())
6060
.rev()
6161
.map(|i| rng.gen_range(0..i + 1))

0 commit comments

Comments
 (0)