Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add radio type and fixed mime type support and theme support #3

Merged
merged 4 commits into from
Mar 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions plugin_playback_guiplayer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -64,28 +65,52 @@ def _get_track(self, track_data):
track = track_data[0]
mime = track_data[1]
mime = mime.split('/')

# Assume track_data[2] is the theme
# Check if its available
if len(track_data) > 2:
theme = track_data[2]
else:
theme = None

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

# Indicate to audio service which track is being played
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"))
Expand Down