forked from platypush/platypush
Reload logic on media.ctrl in case the connection with the media plugin has been reset
This commit is contained in:
parent
6ef97e9ddc
commit
c4401b25be
1 changed files with 16 additions and 4 deletions
|
@ -63,6 +63,9 @@ class MediaCtrlPlugin(Plugin):
|
||||||
for plugin in self._supported_plugins:
|
for plugin in self._supported_plugins:
|
||||||
try:
|
try:
|
||||||
player = get_plugin(plugin)
|
player = get_plugin(plugin)
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
player = get_plugin(plugin, reload=True)
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -76,13 +79,22 @@ class MediaCtrlPlugin(Plugin):
|
||||||
def play(self, url):
|
def play(self, url):
|
||||||
(type, resource) = self._get_type_and_resource_by_url(url)
|
(type, resource) = self._get_type_and_resource_by_url(url)
|
||||||
response = Response(output='', errors = [])
|
response = Response(output='', errors = [])
|
||||||
|
plugin_name = None
|
||||||
|
|
||||||
if type == 'mpd':
|
if type == 'mpd':
|
||||||
self.plugin = get_plugin('music.mpd')
|
plugin_name = 'music.mpd'
|
||||||
elif type == 'youtube:video' or type == 'file':
|
elif type == 'youtube:video' or type == 'file':
|
||||||
self.plugin = get_plugin('video.omxplayer')
|
plugin_name = 'video.omxplayer'
|
||||||
elif type == 'torrent':
|
elif type == 'torrent':
|
||||||
self.plugin = get_plugin('video.torrentcast')
|
plugin_name = 'video.torrentcast'
|
||||||
|
|
||||||
|
if not plugin_name:
|
||||||
|
raise RuntimeError("Unsupported type '{}'".format(type))
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.plugin = get_plugin(plugin_name)
|
||||||
|
except:
|
||||||
|
self.plugin = get_plugin(plugin_name, reload=True)
|
||||||
|
|
||||||
self.url = resource
|
self.url = resource
|
||||||
return self.plugin.play(resource)
|
return self.plugin.play(resource)
|
||||||
|
|
Loading…
Reference in a new issue