1
0
This repository has been archived on 2024-11-10. You can view files and clone it. You cannot open issues, pull requests or push a commit.
Files
Lakka-rk322x/packages/addons/service/librespot/patches/librespot-01_notify_kodi.patch

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,
}
};