From 1920bd80a3deeb23716550ad990b0a0507cb1964 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 3 Feb 2021 17:34:11 +0100 Subject: [PATCH] First search among the configured media plugins in media.ctrl plugin --- platypush/plugins/media/ctrl.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/platypush/plugins/media/ctrl.py b/platypush/plugins/media/ctrl.py index cb94e2b8c..8f5adbfbe 100644 --- a/platypush/plugins/media/ctrl.py +++ b/platypush/plugins/media/ctrl.py @@ -2,7 +2,7 @@ import re import subprocess from platypush.context import get_plugin -from platypush.plugins.media import PlayerState +from platypush.plugins.media import PlayerState, MediaPlugin from platypush.plugins import Plugin, action @@ -18,10 +18,6 @@ class MediaCtrlPlugin(Plugin): """ - _supported_plugins = { - 'music.mpd', 'media', 'video.torrentcast' - } - def __init__(self, torrentcast_port=9090, *args, **kwargs): super().__init__() self.torrentcast_port = torrentcast_port @@ -62,7 +58,18 @@ class MediaCtrlPlugin(Plugin): if status['state'] == PlayerState.PLAY.value or state['state'] == PlayerState.PAUSE.value: return self.plugin - for plugin in self._supported_plugins: + configured_media_plugins = [ + Config.get(plugin) for plugin in self._supported_media_plugins + if Config.get(plugin) + ] + + if configured_media_plugins: + plugin = get_plugin(plugin) + status = plugin.status().output + if status.get('state') == PlayerState.PLAY.value or status.get('state') == PlayerState.PAUSE.value: + return plugin + + for plugin in MediaPlugin._supported_media_plugins: try: player = get_plugin(plugin) except: