summaryrefslogtreecommitdiff
path: root/src/audio/rodio.rs
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2024-06-04 20:50:46 +0200
committerYuval Adam <_@yuv.al>2024-06-04 20:50:46 +0200
commit355743d349d8f63a5d98246c0f0265812fbb2482 (patch)
treec48c313ebad2949afa96e64d8ed48e1d2b16fdf7 /src/audio/rodio.rs
parent482a942cd9e62fadee4ee7bc1fd7e8def8a85f71 (diff)
Initial spinner mpsc
Diffstat (limited to 'src/audio/rodio.rs')
-rw-r--r--src/audio/rodio.rs7
1 files changed, 4 insertions, 3 deletions
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<String>) {
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());
}
}
},