video-player: Only play when the player is mapped

This commit is contained in:
Kévin Commaille 2023-11-12 11:22:14 +01:00 committed by Kévin Commaille
parent 1530a68d7b
commit 0391911e3e

View file

@ -111,7 +111,17 @@ mod imp {
}
}
impl WidgetImpl for VideoPlayer {}
impl WidgetImpl for VideoPlayer {
fn map(&self) {
self.parent_map();
self.player.play();
}
fn unmap(&self) {
self.player.stop();
self.parent_unmap();
}
}
impl BinImpl for VideoPlayer {}
}
@ -155,7 +165,6 @@ impl VideoPlayer {
let player = self.player();
player.set_uri(Some(file.uri().as_ref()));
player.set_audio_track_enabled(false);
player.play();
}
fn duration_changed(&self, duration: Option<ClockTime>) {