diff --git a/winamp_mpris.py b/winamp_mpris.py index d11f7ce..eef0076 100755 --- a/winamp_mpris.py +++ b/winamp_mpris.py @@ -70,7 +70,9 @@ class WinampMPRIS: - + + + """ @@ -89,6 +91,7 @@ class WinampMPRIS: self._last_update_ts = time.time() self._shuffle = False self._loop_status = "None" + self._volume = 1.0 def _request(self, endpoint): print(f"COMMAND RECEIVED: {endpoint}") @@ -112,7 +115,9 @@ class WinampMPRIS: def Stop(self): self._request("stop") def Seek(self, offset): pass def SetPosition(self, track_id, position): pass - def OpenUri(self, uri): pass + def OpenUri(self, uri): + # Found /url?p& in source code - plays immediately + self._request(f"url?p&{uri}") # --- Root Properties --- @property @@ -185,7 +190,13 @@ class WinampMPRIS: return self._last_position_us @property - def Volume(self): return 1.0 + def Volume(self): return self._volume + @Volume.setter + def Volume(self, value): + self._volume = max(0.0, min(1.0, value)) + # Plugin source shows /vol?volume= accepts 0-10 + vol_10 = int(self._volume * 10) + self._request(f"vol?volume={vol_10}") @property def Metadata(self): @@ -380,7 +391,8 @@ def update_loop(player): "PlaybackStatus": player.PlaybackStatus, "Metadata": player.Metadata, "Shuffle": player.Shuffle, - "LoopStatus": player.LoopStatus + "LoopStatus": player.LoopStatus, + "Volume": player.Volume }, [] )