From 355743d349d8f63a5d98246c0f0265812fbb2482 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Tue, 4 Jun 2024 20:50:46 +0200 Subject: Initial spinner mpsc --- src/audio/rodio.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/audio/rodio.rs') diff --git a/src/audio/rodio.rs b/src/audio/rodio.rs index 0f9fbb2..695c6cb 100644 --- a/src/audio/rodio.rs +++ b/src/audio/rodio.rs @@ -6,13 +6,14 @@ use stream_download::http::HttpStream; use stream_download::storage::bounded::BoundedStorageProvider; use stream_download::storage::memory::MemoryStorageProvider; use stream_download::{Settings, StreamDownload}; +use tokio::sync::mpsc; const AUDIO_BUFFER_SECONDS: u32 = 5; pub struct Rodio {} impl Rodio { - pub async fn play(&self, url: &str) { + pub async fn play(&self, url: &str, tx: mpsc::Sender) { let (_stream, handle) = OutputStream::try_default().unwrap(); let sink = Sink::try_new(&handle).unwrap(); @@ -48,10 +49,10 @@ impl Rodio { // Since we requested icy metadata, the metadata interval header should be present in the // response. This will allow us to parse the metadata within the stream icy_headers.metadata_interval(), - |metadata| { + move |metadata| { if let Ok(md) = metadata { if let Some(tr) = md.stream_title() { - println!(" {tr}"); + let _ = tx.send(tr.to_string()); } } }, -- cgit v1.3.1