Skip to content

Commit

Permalink
support old mqtt-media-player
Browse files Browse the repository at this point in the history
  • Loading branch information
bkbilly committed Oct 3, 2024
1 parent 606d1af commit 9dc0bdd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lnxlink/modules/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,25 @@ def start_control(self, topic, data):
def get_info(self) -> dict:
"""Gather information from the system"""
self._current_volume = self._get_volume()
info = {
"title": "",
"artist": "",
"album": "",
"status": "idle",
"volume": self._current_volume,
"playing": False,
"position": None,
"duration": None,
}
if len(self.players) > 0:
player = self.players[0]
info["playing"] = True
info["title"] = player["title"]
info["album"] = player["album"]
info["artist"] = player["artist"]
info["status"] = player["status"].lower()
info["position"] = player["position"]
info["duration"] = player["duration"]
self.lnxlink.run_module(f"{self.name}/state", player["status"].lower())
self.lnxlink.run_module(f"{self.name}/volume", self._current_volume)
if self.prev_player != player:
Expand All @@ -116,6 +133,7 @@ def get_info(self) -> dict:
self.lnxlink.run_module(f"{self.name}/state", "off")
self.lnxlink.run_module(f"{self.name}/volume", self._current_volume)
self.lnxlink.run_module(f"{self.name}/albumart", "")
return info

def media_callback(self, players):
"""Callback function to update media information"""
Expand Down

0 comments on commit 9dc0bdd

Please sign in to comment.