Add Volume control and OpenUri support
- Implement MPRIS Volume property (readwrite) with 0-10 mapping for Winamp - Implement MPRIS OpenUri method using the discovered /url?p& endpoint - Add Volume to PropertiesChanged signal notifications - Update D-Bus XML interface definition
This commit is contained in:
@@ -70,7 +70,9 @@ class WinampMPRIS:
|
||||
<property name="Position" type="x" access="read">
|
||||
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
|
||||
</property>
|
||||
<property name="Volume" type="d" access="read" />
|
||||
<property name="Volume" type="d" access="readwrite">
|
||||
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
|
||||
</property>
|
||||
</interface>
|
||||
</node>
|
||||
"""
|
||||
@@ -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&<url> 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
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user