|
|
|
@ -3,8 +3,9 @@ pub struct Player {
|
|
|
|
|
pub sink: rodio::Sink,
|
|
|
|
|
pub stream_thread: std::thread::JoinHandle<()>,
|
|
|
|
|
pub stream_handle: rodio::OutputStreamHandle,
|
|
|
|
|
pub volume: f32,
|
|
|
|
|
pub stream_source: String,
|
|
|
|
|
pub stream_exif: String,
|
|
|
|
|
pub volume: f32,
|
|
|
|
|
pub playing: bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -14,8 +15,9 @@ impl Player {
|
|
|
|
|
sink,
|
|
|
|
|
stream_handle,
|
|
|
|
|
stream_thread: std::thread::spawn(|| {}),
|
|
|
|
|
volume: 100.0,
|
|
|
|
|
stream_source: "https://radio.wownero.com/wow.ogg".to_owned(),
|
|
|
|
|
stream_exif: "".to_owned(),
|
|
|
|
|
volume: 100.0,
|
|
|
|
|
playing: false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -27,8 +29,9 @@ impl Player {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn start_radio_stream(&self) -> std::thread::JoinHandle<()> {
|
|
|
|
|
let url: String = self.stream_source.clone();
|
|
|
|
|
let t: Result<std::thread::JoinHandle<()>, std::io::Error> = std::thread::Builder::new().name("radio_stream".to_string()).spawn(move || {
|
|
|
|
|
let mut res: reqwest::blocking::Response = reqwest::blocking::get("https://radio.wownero.com/wow.ogg").expect("request failed");
|
|
|
|
|
let mut res: reqwest::blocking::Response = reqwest::blocking::get(url).expect("request failed");
|
|
|
|
|
let mut out: std::fs::File = std::fs::File::create(&crate::RADIO_STREAM).expect("failed to create file");
|
|
|
|
|
std::io::copy(&mut res, &mut out).expect("failed to copy content");
|
|
|
|
|
});
|
|
|
|
|