diff --git a/src/lib.rs b/src/lib.rs index 4c85b14..370fed7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,10 +24,11 @@ pub mod pomodoro { } pub fn play(&self) { - let file = File::open(self.path).unwrap(); - let source = Decoder::new(BufReader::new(file)).unwrap(); - - rodio::play_raw(self.device, source.convert_samples()); + if self.path.exists() { + let file = File::open(self.path).unwrap(); + let source = Decoder::new(BufReader::new(file)).unwrap(); + rodio::play_raw(self.device, source.convert_samples()); + } } } @@ -180,7 +181,7 @@ pub mod pomodoro { match elapsed { 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 hours = seconds / 3600;