forked from platypush/platypush
FIX: Various omxplayer fixes
- Better synchronization with the player upon `play` request - wait until the play started event is received before returning the status - DBus exceptions should be caught and handled in the status call
This commit is contained in:
parent
c3681e7b2a
commit
f9ce03919b
2 changed files with 17 additions and 3 deletions
|
@ -12,6 +12,12 @@ Given the high speed of development in the first phase, changes are being report
|
||||||
method (closes #115).
|
method (closes #115).
|
||||||
- Support for custom YouTube video/audio formats on media plugins.
|
- Support for custom YouTube video/audio formats on media plugins.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Responses for requests received over an MQTT backend are now delivered to the right topic
|
||||||
|
(`<device_base_topic>/responses/<msg_id>`).
|
||||||
|
- Various fixes on media plugins.
|
||||||
|
|
||||||
## [0.22.3] - 2021-10-01
|
## [0.22.3] - 2021-10-01
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -25,13 +25,14 @@ class MediaOmxplayerPlugin(MediaPlugin):
|
||||||
* **omxplayer-wrapper** (``pip install omxplayer-wrapper``)
|
* **omxplayer-wrapper** (``pip install omxplayer-wrapper``)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, args=None, *argv, **kwargs):
|
def __init__(self, args=None, *argv, timeout: float = 20., **kwargs):
|
||||||
"""
|
"""
|
||||||
:param args: Arguments that will be passed to the OMXPlayer constructor
|
:param args: Arguments that will be passed to the OMXPlayer constructor
|
||||||
(e.g. subtitles, volume, start position, window size etc.) see
|
(e.g. subtitles, volume, start position, window size etc.) see
|
||||||
https://github.com/popcornmix/omxplayer#synopsis and
|
https://github.com/popcornmix/omxplayer#synopsis and
|
||||||
https://python-omxplayer-wrapper.readthedocs.io/en/latest/omxplayer/#omxplayer.player.OMXPlayer
|
https://python-omxplayer-wrapper.readthedocs.io/en/latest/omxplayer/#omxplayer.player.OMXPlayer
|
||||||
:type args: list
|
:type args: list
|
||||||
|
:param timeout: How long the plugin should wait for a video to start upon play request (default: 20 seconds).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
super().__init__(*argv, **kwargs)
|
super().__init__(*argv, **kwargs)
|
||||||
|
@ -40,6 +41,7 @@ class MediaOmxplayerPlugin(MediaPlugin):
|
||||||
args = []
|
args = []
|
||||||
|
|
||||||
self.args = args
|
self.args = args
|
||||||
|
self.timeout = timeout
|
||||||
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()
|
self._play_started = threading.Event()
|
||||||
|
@ -95,6 +97,8 @@ class MediaOmxplayerPlugin(MediaPlugin):
|
||||||
|
|
||||||
self._post_event(MediaPlayEvent, resource=resource)
|
self._post_event(MediaPlayEvent, resource=resource)
|
||||||
self._init_player_handlers()
|
self._init_player_handlers()
|
||||||
|
if not self._play_started.wait(timeout=self.timeout):
|
||||||
|
self.logger.warning(f'The player has not sent a play started event within {self.timeout}')
|
||||||
return self.status()
|
return self.status()
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
@ -308,6 +312,7 @@ class MediaOmxplayerPlugin(MediaPlugin):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from omxplayer.player import OMXPlayerDeadError
|
from omxplayer.player import OMXPlayerDeadError
|
||||||
|
from dbus import DBusException
|
||||||
|
|
||||||
if not self._player:
|
if not self._player:
|
||||||
return {
|
return {
|
||||||
|
@ -316,8 +321,11 @@ class MediaOmxplayerPlugin(MediaPlugin):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
state = self._player.playback_status().lower()
|
state = self._player.playback_status().lower()
|
||||||
except OMXPlayerDeadError:
|
except (OMXPlayerDeadError, DBusException) as e:
|
||||||
|
self.logger.warning(f'Could not retrieve player status: {e}')
|
||||||
|
if isinstance(e, OMXPlayerDeadError):
|
||||||
self._player = None
|
self._player = None
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'state': PlayerState.STOP.value
|
'state': PlayerState.STOP.value
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue