Handle missing audio file and, fix logic error

This commit is contained in:
Rekai Musuka 2020-05-21 23:59:38 -05:00
parent 171ccafe72
commit 01d92aaede
1 changed files with 6 additions and 5 deletions

View File

@ -24,12 +24,13 @@ pub mod pomodoro {
} }
pub fn play(&self) { pub fn play(&self) {
if self.path.exists() {
let file = File::open(self.path).unwrap(); let file = File::open(self.path).unwrap();
let source = Decoder::new(BufReader::new(file)).unwrap(); let source = Decoder::new(BufReader::new(file)).unwrap();
rodio::play_raw(self.device, source.convert_samples()); rodio::play_raw(self.device, source.convert_samples());
} }
} }
}
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub enum State { pub enum State {
@ -180,7 +181,7 @@ pub mod pomodoro {
match elapsed { match elapsed {
Some(duration) => { Some(duration) => {
let remaining = (status.length.as_secs() * 60) - duration.as_secs(); let remaining = status.length.as_secs() - duration.as_secs();
let seconds = remaining; let seconds = remaining;
let hours = seconds / 3600; let hours = seconds / 3600;