mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Re-introduce autoplay
command-line option as an override
This commit is contained in:
parent
d07f58e6df
commit
6dc7a11b09
5 changed files with 46 additions and 10 deletions
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -49,6 +49,10 @@ https://github.com/librespot-org/librespot
|
||||||
- [core] Cache resolved access points during runtime (breaking)
|
- [core] Cache resolved access points during runtime (breaking)
|
||||||
- [core] `FileId` is moved out of `SpotifyId`. For now it will be re-exported.
|
- [core] `FileId` is moved out of `SpotifyId`. For now it will be re-exported.
|
||||||
- [core] Report actual platform data on login
|
- [core] Report actual platform data on login
|
||||||
|
- [main] `autoplay {on|off}` now acts as an override. If unspecified, `librespot`
|
||||||
|
now follows the setting in the Connect client that controls it. (breaking)
|
||||||
|
- [metadata] Most metadata is now retrieved with the `spclient` (breaking)
|
||||||
|
- [metadata] Playlists are moved to the `playlist4_external` protobuf (breaking)
|
||||||
- [playback] The audio decoder has been switched from `lewton` to `Symphonia`.
|
- [playback] The audio decoder has been switched from `lewton` to `Symphonia`.
|
||||||
This improves the Vorbis sound quality, adds support for MP3 as well as for
|
This improves the Vorbis sound quality, adds support for MP3 as well as for
|
||||||
FLAC in the future. (breaking)
|
FLAC in the future. (breaking)
|
||||||
|
@ -56,8 +60,6 @@ https://github.com/librespot-org/librespot
|
||||||
- [playback] The passthrough decoder is now feature-gated (breaking)
|
- [playback] The passthrough decoder is now feature-gated (breaking)
|
||||||
- [playback] `rodio`: call play and pause
|
- [playback] `rodio`: call play and pause
|
||||||
- [protocol] protobufs have been updated
|
- [protocol] protobufs have been updated
|
||||||
- [metadata] Most metadata is now retrieved with the `spclient` (breaking)
|
|
||||||
- [metadata] Playlists are moved to the `playlist4_external` protobuf (breaking)
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
@ -100,13 +102,6 @@ https://github.com/librespot-org/librespot
|
||||||
- [playback] Handle disappearing and invalid devices better
|
- [playback] Handle disappearing and invalid devices better
|
||||||
- [playback] Handle seek, pause, and play commands while loading
|
- [playback] Handle seek, pause, and play commands while loading
|
||||||
|
|
||||||
### Removed
|
|
||||||
|
|
||||||
- [main] `autoplay` is no longer a command-line option. Instead, librespot now
|
|
||||||
follows the setting in the Connect client that controls it. Applications that
|
|
||||||
use librespot as a library without Connect should now instead use the
|
|
||||||
'autoplay' user attribute in the session.
|
|
||||||
|
|
||||||
## [0.4.2] - 2022-07-29
|
## [0.4.2] - 2022-07-29
|
||||||
|
|
||||||
Besides a couple of small fixes, this point release is mainly to blacklist the
|
Besides a couple of small fixes, this point release is mainly to blacklist the
|
||||||
|
|
|
@ -772,6 +772,12 @@ impl SpircTask {
|
||||||
fn handle_user_attributes_mutation(&mut self, mutation: UserAttributesMutation) {
|
fn handle_user_attributes_mutation(&mut self, mutation: UserAttributesMutation) {
|
||||||
for attribute in mutation.get_fields().iter() {
|
for attribute in mutation.get_fields().iter() {
|
||||||
let key = attribute.get_name();
|
let key = attribute.get_name();
|
||||||
|
|
||||||
|
if key == "autoplay" && self.session.config().autoplay.is_some() {
|
||||||
|
trace!("Autoplay override active. Ignoring mutation.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(old_value) = self.session.user_data().attributes.get(key) {
|
if let Some(old_value) = self.session.user_data().attributes.get(key) {
|
||||||
let new_value = match old_value.as_ref() {
|
let new_value = match old_value.as_ref() {
|
||||||
"0" => "1",
|
"0" => "1",
|
||||||
|
|
|
@ -13,6 +13,7 @@ pub struct SessionConfig {
|
||||||
pub proxy: Option<Url>,
|
pub proxy: Option<Url>,
|
||||||
pub ap_port: Option<u16>,
|
pub ap_port: Option<u16>,
|
||||||
pub tmp_dir: PathBuf,
|
pub tmp_dir: PathBuf,
|
||||||
|
pub autoplay: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SessionConfig {
|
impl Default for SessionConfig {
|
||||||
|
@ -31,6 +32,7 @@ impl Default for SessionConfig {
|
||||||
proxy: None,
|
proxy: None,
|
||||||
ap_port: None,
|
ap_port: None,
|
||||||
tmp_dir: std::env::temp_dir(),
|
tmp_dir: std::env::temp_dir(),
|
||||||
|
autoplay: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -438,6 +438,10 @@ impl Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn autoplay(&self) -> bool {
|
pub fn autoplay(&self) -> bool {
|
||||||
|
if let Some(overide) = self.config().autoplay {
|
||||||
|
return overide;
|
||||||
|
}
|
||||||
|
|
||||||
match self.get_user_attribute("autoplay") {
|
match self.get_user_attribute("autoplay") {
|
||||||
Some(value) => matches!(&*value, "1"),
|
Some(value) => matches!(&*value, "1"),
|
||||||
None => false,
|
None => false,
|
||||||
|
|
31
src/main.rs
31
src/main.rs
|
@ -197,6 +197,7 @@ fn get_setup() -> Setup {
|
||||||
const VALID_NORMALISATION_RELEASE_RANGE: RangeInclusive<u64> = 1..=1000;
|
const VALID_NORMALISATION_RELEASE_RANGE: RangeInclusive<u64> = 1..=1000;
|
||||||
|
|
||||||
const AP_PORT: &str = "ap-port";
|
const AP_PORT: &str = "ap-port";
|
||||||
|
const AUTOPLAY: &str = "autoplay";
|
||||||
const BACKEND: &str = "backend";
|
const BACKEND: &str = "backend";
|
||||||
const BITRATE: &str = "bitrate";
|
const BITRATE: &str = "bitrate";
|
||||||
const CACHE: &str = "cache";
|
const CACHE: &str = "cache";
|
||||||
|
@ -242,6 +243,7 @@ fn get_setup() -> Setup {
|
||||||
|
|
||||||
// Mostly arbitrary.
|
// Mostly arbitrary.
|
||||||
const AP_PORT_SHORT: &str = "a";
|
const AP_PORT_SHORT: &str = "a";
|
||||||
|
const AUTOPLAY_SHORT: &str = "A";
|
||||||
const BACKEND_SHORT: &str = "B";
|
const BACKEND_SHORT: &str = "B";
|
||||||
const BITRATE_SHORT: &str = "b";
|
const BITRATE_SHORT: &str = "b";
|
||||||
const SYSTEM_CACHE_SHORT: &str = "C";
|
const SYSTEM_CACHE_SHORT: &str = "C";
|
||||||
|
@ -562,6 +564,12 @@ fn get_setup() -> Setup {
|
||||||
AP_PORT,
|
AP_PORT,
|
||||||
"Connect to an AP with a specified port 1 - 65535. Available ports are usually 80, 443 and 4070.",
|
"Connect to an AP with a specified port 1 - 65535. Available ports are usually 80, 443 and 4070.",
|
||||||
"PORT",
|
"PORT",
|
||||||
|
)
|
||||||
|
.optopt(
|
||||||
|
AUTOPLAY_SHORT,
|
||||||
|
AUTOPLAY,
|
||||||
|
"Explicitly set autoplay {on|off}. Defaults to following the client setting.",
|
||||||
|
"OVERRIDE",
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "passthrough-decoder")]
|
#[cfg(feature = "passthrough-decoder")]
|
||||||
|
@ -1140,6 +1148,26 @@ fn get_setup() -> Setup {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// #1046: not all connections are supplied an `autoplay` user attribute to run statelessly.
|
||||||
|
// This knob allows for a manual override.
|
||||||
|
let autoplay = match opt_str(AUTOPLAY) {
|
||||||
|
Some(value) => match value.as_ref() {
|
||||||
|
"on" => Some(true),
|
||||||
|
"off" => Some(false),
|
||||||
|
_ => {
|
||||||
|
invalid_error_msg(
|
||||||
|
AUTOPLAY,
|
||||||
|
AUTOPLAY_SHORT,
|
||||||
|
&opt_str(AUTOPLAY).unwrap_or_default(),
|
||||||
|
"on, off",
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => SessionConfig::default().autoplay,
|
||||||
|
};
|
||||||
|
|
||||||
let connect_config = {
|
let connect_config = {
|
||||||
let connect_default_config = ConnectConfig::default();
|
let connect_default_config = ConnectConfig::default();
|
||||||
|
|
||||||
|
@ -1293,7 +1321,8 @@ fn get_setup() -> Setup {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
tmp_dir,
|
tmp_dir,
|
||||||
..SessionConfig::default()
|
autoplay,
|
||||||
|
..SessionConfig::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let player_config = {
|
let player_config = {
|
||||||
|
|
Loading…
Reference in a new issue