Handle missing audio file and, fix logic error
This commit is contained in:
parent
171ccafe72
commit
01d92aaede
|
@ -24,12 +24,13 @@ pub mod pomodoro {
|
|||
}
|
||||
|
||||
pub fn play(&self) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum State {
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue