diff --git a/playback/src/config.rs b/playback/src/config.rs index 0f711100..9d65042c 100644 --- a/playback/src/config.rs +++ b/playback/src/config.rs @@ -30,6 +30,7 @@ pub struct PlayerConfig { pub bitrate: Bitrate, pub normalisation: bool, pub normalisation_pregain: f32, + pub gapless: bool, } impl Default for PlayerConfig { @@ -38,6 +39,7 @@ impl Default for PlayerConfig { bitrate: Bitrate::default(), normalisation: false, normalisation_pregain: 0.0, + gapless: true, } } } diff --git a/playback/src/player.rs b/playback/src/player.rs index 4b207790..30faadc6 100644 --- a/playback/src/player.rs +++ b/playback/src/player.rs @@ -1102,6 +1102,9 @@ impl PlayerInternal { play: bool, position_ms: u32, ) { + if !self.config.gapless { + self.ensure_sink_stopped(); + } // emit the correct player event match self.state { PlayerState::Playing { diff --git a/src/main.rs b/src/main.rs index a6afb46a..263e2a29 100644 --- a/src/main.rs +++ b/src/main.rs @@ -182,6 +182,11 @@ fn setup(args: &[String]) -> Setup { "", "autoplay", "autoplay similar songs when your music ends.", + ) + .optflag( + "", + "disable-gapless", + "disable gapless playback.", ); let matches = match opts.parse(&args[1..]) { @@ -314,9 +319,9 @@ fn setup(args: &[String]) -> Setup { .as_ref() .map(|bitrate| Bitrate::from_str(bitrate).expect("Invalid bitrate")) .unwrap_or(Bitrate::default()); - PlayerConfig { bitrate: bitrate, + gapless: !matches.opt_present("disable-gapless"), normalisation: matches.opt_present("enable-volume-normalisation"), normalisation_pregain: matches .opt_str("normalisation-pregain")