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,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;