mirror of
https://github.com/tsirysndr/music-player.git
synced 2026-01-10 05:37:57 -05:00
feat(dlna): implement get_current_playback()
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -8413,9 +8413,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
||||
|
||||
[[package]]
|
||||
name = "upnp-client"
|
||||
version = "0.1.5"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf6dac76130c77cc0ec22b783400dfc417447bd804b256a5cba6b3385dc12659"
|
||||
checksum = "f0fb040a8994c1908b78abf4c81d8649083326ac360e0bb07dc417863bbe0a41"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-stream 0.3.3",
|
||||
|
||||
@@ -29,7 +29,7 @@ jsonrpsee = { version = "0.16.2", features = ["jsonrpsee-ws-client", "jsonrpsee-
|
||||
url = "2.3.1"
|
||||
md5 = "0.7.0"
|
||||
local-ip-addr = "0.1.1"
|
||||
upnp-client = "0.1.5"
|
||||
upnp-client = "0.1.6"
|
||||
futures = "0.3.26"
|
||||
tokio = { version = "1.25.0", features = ["time"] }
|
||||
hyper = { version = "0.14.23", features = ["runtime", "client", "stream", "tcp", "http1", "http2"] }
|
||||
|
||||
@@ -277,15 +277,48 @@ impl Player for Dlna {
|
||||
}
|
||||
|
||||
async fn get_current_playback(&mut self) -> Result<Playback, Error> {
|
||||
// TODO: Implement
|
||||
Ok(Playback {
|
||||
current_track: None,
|
||||
index: 0,
|
||||
position_ms: 0,
|
||||
is_playing: false,
|
||||
current_item_id: None,
|
||||
items: vec![],
|
||||
})
|
||||
if let Some(client) = &self.client {
|
||||
let position = client.get_position().await?;
|
||||
let duration = client.get_duration().await?;
|
||||
let transport_info = client.get_transport_info().await?;
|
||||
if duration != 0 && position >= (duration - 10) {
|
||||
self.preload_next_track().await?;
|
||||
}
|
||||
if duration != 0 && position >= (duration - 1) {
|
||||
self.next().await?;
|
||||
}
|
||||
let (previous_tracks, next_tracks) = self.tracklist.lock().unwrap().tracks();
|
||||
let tracks: Vec<Track> = previous_tracks
|
||||
.iter()
|
||||
.map(|t| t.clone().into())
|
||||
.chain(next_tracks.iter().map(|t| t.clone().into()))
|
||||
.collect();
|
||||
let items: Vec<(Track, i32)> = tracks
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, t)| (t.clone(), (i + 1) as i32))
|
||||
.collect();
|
||||
let (current_track, index) = self.tracklist.lock().unwrap().current_track();
|
||||
return match current_track {
|
||||
Some(track) => Ok(Playback {
|
||||
current_track: Some(track.clone().into()),
|
||||
index: index as u32,
|
||||
position_ms: position * 1000 as u32,
|
||||
is_playing: transport_info.current_transport_state == "PLAYING",
|
||||
current_item_id: Some(index as i32),
|
||||
items,
|
||||
}),
|
||||
None => Ok(Playback {
|
||||
current_track: None,
|
||||
index: 0,
|
||||
position_ms: 0,
|
||||
is_playing: false,
|
||||
current_item_id: None,
|
||||
items: vec![],
|
||||
}),
|
||||
};
|
||||
}
|
||||
Err(Error::msg("device not connected"))
|
||||
}
|
||||
|
||||
fn device_type(&self) -> String {
|
||||
|
||||
@@ -18,4 +18,4 @@ md5 = "0.7.0"
|
||||
sea-orm = { version = "0.9.2", features = ["runtime-tokio-rustls", "sqlx-sqlite"] }
|
||||
serde = "1.0.145"
|
||||
chrono = "0.4.23"
|
||||
upnp-client = "0.1.5"
|
||||
upnp-client = "0.1.6"
|
||||
|
||||
@@ -72,4 +72,4 @@ serde = { version = "1.0.148", features = ["serde_derive"] }
|
||||
mdns-sd = "0.5.9"
|
||||
anyhow = "1.0.67"
|
||||
url = "2.3.1"
|
||||
upnp-client = "0.1.2"
|
||||
upnp-client = "0.1.6"
|
||||
|
||||
@@ -24,5 +24,5 @@ tantivy = "0.18.1"
|
||||
mdns-sd = "0.5.9"
|
||||
minreq = { version = "2.6.0" }
|
||||
local-ip-addr = "0.1.1"
|
||||
upnp-client = "0.1.2"
|
||||
upnp-client = "0.1.6"
|
||||
url = "2.3.1"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"files": {
|
||||
"main.css": "/static/css/main.6215da36.css",
|
||||
"main.js": "/static/js/main.42a36401.js",
|
||||
"main.js": "/static/js/main.2461da8f.js",
|
||||
"static/js/787.26bf0a29.chunk.js": "/static/js/787.26bf0a29.chunk.js",
|
||||
"static/media/RockfordSans-ExtraBold.otf": "/static/media/RockfordSans-ExtraBold.1513e8fd97078bfb7708.otf",
|
||||
"static/media/RockfordSans-Bold.otf": "/static/media/RockfordSans-Bold.c9f599ae01b13e565598.otf",
|
||||
@@ -10,11 +10,11 @@
|
||||
"static/media/RockfordSans-Light.otf": "/static/media/RockfordSans-Light.b4a12e8abb38f7d105c4.otf",
|
||||
"index.html": "/index.html",
|
||||
"main.6215da36.css.map": "/static/css/main.6215da36.css.map",
|
||||
"main.42a36401.js.map": "/static/js/main.42a36401.js.map",
|
||||
"main.2461da8f.js.map": "/static/js/main.2461da8f.js.map",
|
||||
"787.26bf0a29.chunk.js.map": "/static/js/787.26bf0a29.chunk.js.map"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/css/main.6215da36.css",
|
||||
"static/js/main.42a36401.js"
|
||||
"static/js/main.2461da8f.js"
|
||||
]
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Music Player</title><script defer="defer" src="/static/js/main.42a36401.js"></script><link href="/static/css/main.6215da36.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Music Player</title><script defer="defer" src="/static/js/main.2461da8f.js"></script><link href="/static/css/main.6215da36.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
1
webui/musicplayer/build/static/js/main.2461da8f.js.map
Normal file
1
webui/musicplayer/build/static/js/main.2461da8f.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -6,6 +6,7 @@ import { Device } from "../../../Types/Device";
|
||||
import { MusicPlayer } from "@styled-icons/bootstrap";
|
||||
import { Laptop } from "@styled-icons/ionicons-outline";
|
||||
import { Kodi, Airplayaudio, Chromecast } from "@styled-icons/simple-icons";
|
||||
import { Speaker } from "@styled-icons/remix-fill";
|
||||
|
||||
const Container = styled.div`
|
||||
max-height: calc(100vh - 153px); /* - 90px */
|
||||
@@ -96,6 +97,7 @@ const Artwork: FC<ArtworkProps> = ({ icon, color }) => {
|
||||
{icon === "chromecast" && (
|
||||
<Chromecast size={18} color={theme.colors.text} />
|
||||
)}
|
||||
{icon === "dlna" && <Speaker size={18} color={"#ff00c3"} />}
|
||||
</Icon>
|
||||
);
|
||||
};
|
||||
@@ -131,6 +133,7 @@ const DeviceList: FC<DeviceListProps> = ({
|
||||
"music-player": "rgba(40, 252, 227, 0.088)",
|
||||
xbmc: "rgba(40, 203, 252, 0.082)",
|
||||
airplay: "rgba(255, 0, 195, 0.063)",
|
||||
dlna: "rgba(255, 0, 195, 0.063)",
|
||||
};
|
||||
|
||||
const _onConnectToCastDevice = (deviceId: string) => {
|
||||
|
||||
Reference in New Issue
Block a user