summaryrefslogtreecommitdiff
path: root/src/audio/rodio.rs
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2024-05-31 15:12:23 +0200
committerYuval Adam <_@yuv.al>2024-05-31 15:12:23 +0200
commit948c1f212cab5d56e82e47fd8ff10f20ecbf847f (patch)
treeab51c037c623c64422f4de2fd0a99120770c8ca0 /src/audio/rodio.rs
parent4a4c5b9174cf0182d4eb755f5d97ca432e5960ca (diff)
Initial attempt doesn't work
Diffstat (limited to 'src/audio/rodio.rs')
-rw-r--r--src/audio/rodio.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/audio/rodio.rs b/src/audio/rodio.rs
index 04883dd..8262b82 100644
--- a/src/audio/rodio.rs
+++ b/src/audio/rodio.rs
@@ -1,9 +1,24 @@
-use super::AudioBackend;
+use rodio::{Decoder, OutputStream, Sink};
+use stream_download::{storage::temp::TempStorageProvider, Settings, StreamDownload};
pub struct Rodio {}
-impl AudioBackend for Rodio {
- fn play(&self, _url: &str) {
- todo!()
+impl Rodio {
+ pub async fn play(&self, url: &str) {
+ let reader = StreamDownload::new_http(
+ url.parse().unwrap(),
+ TempStorageProvider::new(),
+ Settings::default(),
+ )
+ .await
+ .unwrap();
+
+ let _res = tokio::task::spawn_blocking(move || {
+ let (_stream, handle) = OutputStream::try_default().unwrap();
+ let sink = Sink::try_new(&handle).unwrap();
+ sink.append(Decoder::new(reader).unwrap());
+ sink.sleep_until_end();
+ })
+ .await;
}
}