Properly handle EOS in player

This commit is contained in:
chmanie 2023-06-08 11:46:01 +02:00
parent 194334e360
commit 788ac6ba6d
2 changed files with 11 additions and 1 deletions

View File

@ -48,7 +48,7 @@ impl Default for Player {
player.toggle_play();
}
Ok(PlayerEngineCommand::Eos) => {
player.stop();
player.handle_eos();
}
Err(e) => {
// FIXME: debug!(e);

View File

@ -33,6 +33,7 @@ pub enum PlayerMessage {
Stopped,
Paused,
Playing,
EndOfStream,
}
// TODO:
@ -121,6 +122,15 @@ impl PlayerEngine {
}
}
pub fn handle_eos(&mut self) {
if let Some(sink) = &self.sink {
sink.stop();
self.sink.take();
self.stream.take();
self.tx_player.send(PlayerMessage::EndOfStream);
}
}
pub fn is_paused(&self) -> bool {
self.sink
.as_ref()