async def set_artist_title(self, artist, title): self.counter += 1 self.metadata = { 'xesam:title': Variant('s', title), 'xesam:artist': Variant('as', [artist]), 'mpris:trackid': Variant('o', '/' + str(self.counter)), } self.emit_properties_changed({ 'Metadata': self.metadata, }) await self.ping()
async def clear_metadata(self): self.counter += 1 self.metadata = { 'mpris:trackid': Variant('o', '/' + str(self.counter)), } self.emit_properties_changed({ 'Metadata': self.metadata, }) await self.ping()
def Metadata(self) -> "a{sv}": # type: ignore """Return the metadata used by MPRIS players to display what is being played.""" cover_url = f'{self.hass_interface.http_endpoint}{self.data.get("entity_picture", None)}' duration = self.data.get("media_duration", 0) duration = int(duration) * 1_000_000 return { # we do not support playlists, so we don't care about track ids. "mpris:trackid": Variant("o", "/fi/iki/tpr/hassbridge/trackiddummy"), "mpris:artUrl": Variant("s", cover_url), "mpris:length": Variant("x", duration), "xesam:artist": Variant( "s", self.data.get("media_artist", "<unavailable artist>") ), "xesam:album": Variant( "s", self.data.get("media_album_name", "<unavailable album>") ), "xesam:title": Variant( "s", self.data.get("media_title", "<unavailable title>") ), }