forked from platypush/platypush
[media.vlc] A more robust logic for the player monitor thread.
The player may sometimes stop, or the VLC instance crash, without sending a stop event. This may leave the Platypush plugin in a PLAYING state, and the instance may not be properly cleaned up. This commit adds a polling logic to the monitor thread to verify every second if the player is still running, and terminate the instance if that's not the case.
This commit is contained in:
parent
25b77f068b
commit
8fa2080652
1 changed files with 9 additions and 1 deletions
|
@ -124,7 +124,15 @@ class MediaVlcPlugin(MediaPlugin):
|
|||
self._player.set_media(self._instance.media_new(resource.resource))
|
||||
|
||||
def _player_monitor(self):
|
||||
self._on_stop_event.wait()
|
||||
import vlc
|
||||
|
||||
while True:
|
||||
self._on_stop_event.wait(1)
|
||||
if self._player:
|
||||
state = self._player.get_state()
|
||||
if state in {vlc.State.Stopped, vlc.State.Ended, vlc.State.Error}: # type: ignore
|
||||
break
|
||||
|
||||
self.logger.info('VLC stream terminated')
|
||||
self.quit()
|
||||
|
||||
|
|
Loading…
Reference in a new issue