Skip to content

Commit

Permalink
feat/track_meta (#211)
Browse files Browse the repository at this point in the history
Co-authored-by: JarbasAi <[email protected]>
  • Loading branch information
NeonJarbas and JarbasAl authored Feb 7, 2024
1 parent 36b67e9 commit 8a72bc3
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions ovos_plugin_manager/templates/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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}))
Expand Down Expand Up @@ -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.
Expand All @@ -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}))

Expand All @@ -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}))

Expand All @@ -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}))

Expand Down

0 comments on commit 8a72bc3

Please sign in to comment.