diff --git a/src/main.rs b/src/main.rs index e8c9f4b..5f6fe1f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,6 @@ fn init() -> Result, utils::Error> { audio::init(settings.clone(), error_in.clone(), player_events_in.clone())?; let api_event_chan = ssonic::init(settings.clone(), error_in.clone(), player_events_in.clone())?; - std::thread::sleep(std::time::Duration::from_secs(5)); let mut player = player::init( settings.clone(), audio_event_chan, @@ -29,11 +28,18 @@ fn init() -> Result, utils::Error> { } fn main() { - match init() { + let err_chan = match init() { Err(x) => { eprintln!("{}", x); exit(1) } - Ok(_) => exit(0), + Ok(err_chan) => err_chan, }; + match err_chan.recv() { + Err(_) => exit(0), + Ok(err) => { + eprintln!("{}", err); + exit(1) + } + } } diff --git a/src/player/begin.rs b/src/player/begin.rs index 65e7523..632769e 100644 --- a/src/player/begin.rs +++ b/src/player/begin.rs @@ -4,6 +4,8 @@ use super::Player; impl Player { pub fn begin(&mut self) -> Result<(), Error> { - unimplemented!() + std::thread::sleep(std::time::Duration::from_secs(5)); + ratatui::restore(); + Ok(()) } } diff --git a/src/player/mod.rs b/src/player/mod.rs index f614c20..88356dd 100644 --- a/src/player/mod.rs +++ b/src/player/mod.rs @@ -3,11 +3,15 @@ use std::sync::{ Arc, }; +use ratatui::DefaultTerminal; + use crate::{audio::AudioEvent, config::Settings, ssonic::APIEvent, utils::Error}; pub struct PlayerEvent {} -pub struct Player {} +pub struct Player { + terminal: DefaultTerminal, +} pub fn init( settings: Arc, @@ -16,7 +20,8 @@ pub fn init( error_chan: Sender, player_chan: Receiver, ) -> Result { - unimplemented!() + let mut terminal = ratatui::init(); + Ok(Player { terminal }) } mod begin; diff --git a/src/ssonic/client.rs b/src/ssonic/client.rs index e358e24..03f97bb 100644 --- a/src/ssonic/client.rs +++ b/src/ssonic/client.rs @@ -1,5 +1,3 @@ -use std::io::Read; - use reqwest::{blocking::Response, header::ACCEPT}; use serde::Serialize;