forked from platypush/platypush
FIX: Don't try and set the volume of the omxplayer when the instance may not be ready yet
This commit is contained in:
parent
144700b693
commit
c3681e7b2a
1 changed files with 8 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
||||||
import enum
|
import enum
|
||||||
|
import threading
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
from platypush.context import get_bus
|
from platypush.context import get_bus
|
||||||
|
@ -41,6 +42,7 @@ class MediaOmxplayerPlugin(MediaPlugin):
|
||||||
self.args = args
|
self.args = args
|
||||||
self._player = None
|
self._player = None
|
||||||
self._handlers = {e.value: [] for e in PlayerEvent}
|
self._handlers = {e.value: [] for e in PlayerEvent}
|
||||||
|
self._play_started = threading.Event()
|
||||||
|
|
||||||
@action
|
@action
|
||||||
def play(self, resource=None, subtitles=None, *args, **kwargs):
|
def play(self, resource=None, subtitles=None, *args, **kwargs):
|
||||||
|
@ -63,6 +65,8 @@ class MediaOmxplayerPlugin(MediaPlugin):
|
||||||
self._player.play()
|
self._player.play()
|
||||||
|
|
||||||
return self.status()
|
return self.status()
|
||||||
|
else:
|
||||||
|
self._play_started.clear()
|
||||||
|
|
||||||
self._post_event(MediaPlayRequestEvent, resource=resource)
|
self._post_event(MediaPlayRequestEvent, resource=resource)
|
||||||
|
|
||||||
|
@ -89,12 +93,8 @@ class MediaOmxplayerPlugin(MediaPlugin):
|
||||||
'be able to control the media')
|
'be able to control the media')
|
||||||
self.logger.exception(e)
|
self.logger.exception(e)
|
||||||
|
|
||||||
if self.volume:
|
|
||||||
self.set_volume(self.volume)
|
|
||||||
|
|
||||||
self._post_event(MediaPlayEvent, resource=resource)
|
self._post_event(MediaPlayEvent, resource=resource)
|
||||||
self._init_player_handlers()
|
self._init_player_handlers()
|
||||||
|
|
||||||
return self.status()
|
return self.status()
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
@ -359,6 +359,10 @@ class MediaOmxplayerPlugin(MediaPlugin):
|
||||||
|
|
||||||
def on_play(self):
|
def on_play(self):
|
||||||
def _f(player):
|
def _f(player):
|
||||||
|
if self.volume and not self._play_started.is_set():
|
||||||
|
self.set_volume(self.volume)
|
||||||
|
self._play_started.set()
|
||||||
|
|
||||||
resource = player.get_source()
|
resource = player.get_source()
|
||||||
self._post_event(MediaPlayEvent, resource=resource)
|
self._post_event(MediaPlayEvent, resource=resource)
|
||||||
for callback in self._handlers[PlayerEvent.PLAY.value]:
|
for callback in self._handlers[PlayerEvent.PLAY.value]:
|
||||||
|
|
Loading…
Reference in a new issue