From 8a72bc37bd09d52363306c7696608e130a76beda Mon Sep 17 00:00:00 2001 From: NeonJarbas <59943014+NeonJarbas@users.noreply.github.com> Date: Wed, 7 Feb 2024 19:15:12 +0000 Subject: [PATCH] feat/track_meta (#211) Co-authored-by: JarbasAi --- ovos_plugin_manager/templates/media.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/ovos_plugin_manager/templates/media.py b/ovos_plugin_manager/templates/media.py index bd1c385a..8d94132a 100644 --- a/ovos_plugin_manager/templates/media.py +++ b/ovos_plugin_manager/templates/media.py @@ -23,6 +23,7 @@ def __init__(self, config=None, bus=None): self.supports_mime_hints = False self.config = config or {} self.bus = bus or FakeBus() + self.meta = {} def set_track_start_callback(self, callback_func): """Register callback on track start. @@ -31,8 +32,9 @@ def set_track_start_callback(self, callback_func): """ self._track_start_callback = callback_func - def load_track(self, uri): + def load_track(self, uri: str, metadata: dict = None): self._now_playing = uri + self.meta.update(metadata or {}) LOG.debug(f"queuing for {self.__class__.__name__} playback: {uri}") self.bus.emit(Message("ovos.common_play.media.state", {"state": MediaState.LOADED_MEDIA})) @@ -188,11 +190,7 @@ def track_info(self): Returns: dict: Track info containing atleast the keys artist and album. """ - ret = {} - ret['artist'] = '' - ret['album'] = '' - ret['title'] = self._now_playing - return ret + return self.meta def shutdown(self): """Perform clean shutdown. @@ -205,8 +203,8 @@ def shutdown(self): class AudioPlayerBackend(MediaBackend): """ for audio""" - def load_track(self, uri): - super().load_track(uri) + def load_track(self, uri, metadata: dict = None): + super().load_track(uri, metadata) self.bus.emit(Message("ovos.common_play.track.state", {"state": TrackState.QUEUED_AUDIO})) @@ -229,8 +227,8 @@ class RemoteAudioPlayerBackend(AudioPlayerBackend): class VideoPlayerBackend(MediaBackend): """ for video""" - def load_track(self, uri): - super().load_track(uri) + def load_track(self, uri, metadata: dict = None): + super().load_track(uri, metadata) self.bus.emit(Message("ovos.common_play.track.state", {"state": TrackState.QUEUED_VIDEO})) @@ -254,8 +252,8 @@ class RemoteVideoPlayerBackend(VideoPlayerBackend): class WebPlayerBackend(MediaBackend): """ for web pages""" - def load_track(self, uri): - super().load_track(uri) + def load_track(self, uri, metadata: dict = None): + super().load_track(uri, metadata) self.bus.emit(Message("ovos.common_play.track.state", {"state": TrackState.QUEUED_WEBVIEW}))