update 0.1.6 (2021-02-22) to 0.3.1 (2021-10-25) release notes: - https://github.com/librespot-org/librespot/releases/tag/v0.2.0 - https://github.com/librespot-org/librespot/releases/tag/v0.3.0 - https://github.com/librespot-org/librespot/releases/tag/v0.3.1
109 lines
2.9 KiB
Diff
109 lines
2.9 KiB
Diff
commit 10489ef0b9de4241eb8e007596f3d62616120545
|
|
Author: awiouy <awiouy@gmail.com>
|
|
Date: Fri May 29 07:40:19 2020 +0200
|
|
|
|
Notify Kodi
|
|
|
|
diff --git a/core/src/spotify_id.rs b/core/src/spotify_id.rs
|
|
index 1a5fcd2..c670977 100644
|
|
--- a/core/src/spotify_id.rs
|
|
+++ b/core/src/spotify_id.rs
|
|
@@ -9,6 +9,12 @@
|
|
Podcast,
|
|
NonPlayable,
|
|
}
|
|
+
|
|
+impl fmt::Display for SpotifyAudioType {
|
|
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
+ write!(f, "{:?}", self)
|
|
+ }
|
|
+}
|
|
|
|
impl From<&str> for SpotifyAudioType {
|
|
fn from(v: &str) -> Self {
|
|
diff --git a/playback/src/config.rs b/playback/src/config.rs
|
|
index 9d65042..6d098db 100644
|
|
--- a/playback/src/config.rs
|
|
+++ b/playback/src/config.rs
|
|
@@ -142,6 +142,7 @@
|
|
// pass function pointers so they can be lazily instantiated *after* spawning a thread
|
|
// (thereby circumventing Send bounds that they might not satisfy)
|
|
pub ditherer: Option<DithererBuilder>,
|
|
+ pub notify_kodi: bool,
|
|
}
|
|
|
|
impl Default for PlayerConfig {
|
|
@@ -159,6 +160,7 @@
|
|
normalisation_knee: 1.0,
|
|
passthrough: false,
|
|
ditherer: Some(mk_ditherer::<TriangularDitherer>),
|
|
+ notify_kodi: false,
|
|
}
|
|
}
|
|
}
|
|
diff --git a/playback/src/player.rs b/playback/src/player.rs
|
|
index 2dd8f3b..67b3b28 100644
|
|
--- a/playback/src/player.rs
|
|
+++ b/playback/src/player.rs
|
|
@@ -1868,6 +1868,10 @@ impl PlayerInternal {
|
|
}
|
|
}
|
|
|
|
+ fn notify_kodi(&mut self, event: String) {
|
|
+ eprintln!("@{}", event);
|
|
+ }
|
|
+
|
|
fn send_event(&mut self, event: PlayerEvent) {
|
|
let mut index = 0;
|
|
while index < self.event_senders.len() {
|
|
@@ -1878,6 +1882,16 @@ impl PlayerInternal {
|
|
}
|
|
}
|
|
}
|
|
+ if self.config.notify_kodi {
|
|
+ use PlayerEvent::*;
|
|
+ match event {
|
|
+ Playing {track_id, .. } => self.notify_kodi(["Playing",
|
|
+ &track_id.audio_type.to_string(),
|
|
+ &track_id.to_base62()].join(" ")),
|
|
+ Stopped { .. } => self.notify_kodi("Stopped".to_string()),
|
|
+ _ => ()
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
fn load_track(
|
|
diff --git a/src/main.rs b/src/main.rs
|
|
index 2efd62b..ecee2ff 100644
|
|
--- a/src/main.rs
|
|
+++ b/src/main.rs
|
|
@@ -424,6 +424,11 @@
|
|
"",
|
|
PASSTHROUGH,
|
|
"Pass a raw stream to the output. Only works with the pipe and subprocess backends.",
|
|
+ )
|
|
+ .optflag(
|
|
+ "",
|
|
+ "notify-kodi",
|
|
+ "Notify Kodi",
|
|
);
|
|
|
|
let matches = match opts.parse(&args[1..]) {
|
|
@@ -644,6 +649,8 @@ fn setup(args: &[String]) -> Setup {
|
|
)
|
|
};
|
|
|
|
+ let notify_kodi = matches.opt_present("notify-kodi");
|
|
+
|
|
let session_config = {
|
|
let device_id = device_id(&name);
|
|
|
|
@@ -763,6 +763,7 @@
|
|
normalisation_release,
|
|
normalisation_knee,
|
|
ditherer,
|
|
+ notify_kodi: notify_kodi,
|
|
}
|
|
};
|
|
|