From 2d6994c0571e29b86374f9f574162f74b787c9c2 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 14 Jun 2018 21:13:01 +0200 Subject: [PATCH] send_message over Redis for OMXPlayer plugin --- platypush/backend/__init__.py | 2 +- platypush/plugins/video/omxplayer.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/platypush/backend/__init__.py b/platypush/backend/__init__.py index 0d81c2f74..4c9a670ae 100644 --- a/platypush/backend/__init__.py +++ b/platypush/backend/__init__.py @@ -191,7 +191,7 @@ class Backend(Thread): backend is configured then it will try to deliver the message to other consumers through the configured Redis main queue. - Param: + Params: msg -- The message """ try: diff --git a/platypush/plugins/video/omxplayer.py b/platypush/plugins/video/omxplayer.py index 38e22d504..34a904f01 100644 --- a/platypush/plugins/video/omxplayer.py +++ b/platypush/plugins/video/omxplayer.py @@ -10,6 +10,7 @@ import urllib.parse from dbus.exceptions import DBusException from omxplayer import OMXPlayer +from platypush.context import get_backend from platypush.plugins.media import PlayerState from platypush.message.response import Response from platypush.message.event.video import VideoPlayEvent, VideoPauseEvent, \ @@ -195,6 +196,18 @@ class VideoOmxplayerPlugin(Plugin): 'state': PlayerState.STOP.value })) + def send_message(self, msg): + try: + redis = get_backend('redis') + if not redis: + raise KeyError() + except KeyError: + self.logger.warning("Backend {} does not implement send_message " + + "and the fallback Redis backend isn't configured") + return + + redis.send_message(msg) + def on_play(self): def _f(player): self.send_message(VideoPlayEvent(video=self.player.get_source()))