From 84f55a10be5bd29319b437e0e1ba4709f0ec6a71 Mon Sep 17 00:00:00 2001 From: Aditya Mehra Date: Fri, 20 Aug 2021 19:55:06 +0930 Subject: [PATCH 1/4] Add radio type and fixed mime type support and theme support --- plugin_playback_guiplayer/__init__.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/plugin_playback_guiplayer/__init__.py b/plugin_playback_guiplayer/__init__.py index b956f04..2dce2f0 100644 --- a/plugin_playback_guiplayer/__init__.py +++ b/plugin_playback_guiplayer/__init__.py @@ -37,6 +37,7 @@ def __init__(self, config, bus=None, name='guiplayer'): self.track_lock = Lock() self.track_meta_from_player = None self.track_meta_from_cps = None + self.supports_mime_hints = True self.bus.on('GuiPlayerServicePlay', self._play) self.bus.on( @@ -64,17 +65,29 @@ def _get_track(self, track_data): track = track_data[0] mime = track_data[1] mime = mime.split('/') + theme = track_data[2] + + if "type" in mime[0] and "video" in mime[1]: + mime = ["video", "type"] + + if "type" in mime[0] and "audio" in mime[1]: + mime = ["audio", "type"] + + if "type" in mime[0] and "radio" in mime[1]: + mime = ["radio", "type"] + else: # Assume string track = track_data mime = self.find_mime(track) - return track, mime + theme = None + return track, mime, theme def _play(self, message): """ Handle _play call from play signal. """ repeat = message.data.get("repeat", False) with self.track_lock: if len(self.tracks) > self.index: - track, mime = self._get_track(self.tracks[self.index]) + track, mime, theme = self._get_track(self.tracks[self.index]) else: return @@ -82,10 +95,16 @@ def _play(self, message): if self._track_start_callback: self._track_start_callback(track) + if theme: + self.bus.emit(Message("playback.display.set.player.theme", {"theme": theme})) + try: if 'video' in mime[0]: LOG.debug("Sending Video Type") self.bus.emit(Message("playback.display.video.type")) + elif 'radio' in mime[0]: + LOG.info("Sending Radio Type") + self.bus.emit(Message("playback.display.radio.type")) else: LOG.debug("Sending Audio Type") self.bus.emit(Message("playback.display.audio.type")) From 0dbda29e369084dab6632caa9ffbb8e05eb146cb Mon Sep 17 00:00:00 2001 From: Aditya Mehra Date: Fri, 11 Mar 2022 17:19:43 +1030 Subject: [PATCH 2/4] only add theme if its available --- plugin_playback_guiplayer/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugin_playback_guiplayer/__init__.py b/plugin_playback_guiplayer/__init__.py index 2dce2f0..26a2970 100644 --- a/plugin_playback_guiplayer/__init__.py +++ b/plugin_playback_guiplayer/__init__.py @@ -65,7 +65,13 @@ def _get_track(self, track_data): track = track_data[0] mime = track_data[1] mime = mime.split('/') - theme = track_data[2] + + # Assume track_data[3] is the theme + # Check if its available + if len(track_data) > 2: + theme = track_data[3] + else: + theme = None if "type" in mime[0] and "video" in mime[1]: mime = ["video", "type"] From a14bb7dda1604be8236d23b2d2100b1c103cb4fb Mon Sep 17 00:00:00 2001 From: Aditya Mehra Date: Fri, 11 Mar 2022 17:21:42 +1030 Subject: [PATCH 3/4] only add theme if its available --- plugin_playback_guiplayer/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin_playback_guiplayer/__init__.py b/plugin_playback_guiplayer/__init__.py index 26a2970..b319426 100644 --- a/plugin_playback_guiplayer/__init__.py +++ b/plugin_playback_guiplayer/__init__.py @@ -69,7 +69,7 @@ def _get_track(self, track_data): # Assume track_data[3] is the theme # Check if its available if len(track_data) > 2: - theme = track_data[3] + theme = track_data[2] else: theme = None From 187fd7a0d98e77dfb70d5d687db42cb000c9c5ab Mon Sep 17 00:00:00 2001 From: Aditya Mehra Date: Fri, 11 Mar 2022 17:23:15 +1030 Subject: [PATCH 4/4] fix comment --- plugin_playback_guiplayer/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin_playback_guiplayer/__init__.py b/plugin_playback_guiplayer/__init__.py index b319426..d98ed55 100644 --- a/plugin_playback_guiplayer/__init__.py +++ b/plugin_playback_guiplayer/__init__.py @@ -66,7 +66,7 @@ def _get_track(self, track_data): mime = track_data[1] mime = mime.split('/') - # Assume track_data[3] is the theme + # Assume track_data[2] is the theme # Check if its available if len(track_data) > 2: theme = track_data[2]