Skip to content

Commit

Permalink
feat(playback): support volume control
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Sep 24, 2023
1 parent 6486f41 commit a920c0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ impl App {
if key_config.embed.unwrap_or(false) {
let sound = BufReader::new(Box::new(EmbeddedSound::get_sound(&key_config.file)?));
sink.stop();
sink.set_volume(key_config.volume.unwrap_or(1.0));
sink.append(Decoder::new(sound)?);
} else {
let sound = BufReader::new(Box::new(File::open(&key_config.file)?));
sink.stop();
sink.set_volume(key_config.volume.unwrap_or(1.0));
sink.append(Decoder::new(sound)?);
};
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub struct KeyConfig {
/// MP3 file.
pub file: String,
/// Volume.
pub volume: Option<f64>,
pub volume: Option<f32>,
/// Whether if the file is embedded.
pub embed: Option<bool>,
}
Expand Down

0 comments on commit a920c0c

Please sign in to comment.