mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-15 10:06:43 +02:00
Use seconds for seek, make TrackId optional
This commit is contained in:
parent
0853c7c701
commit
880ed00604
3 changed files with 15 additions and 15 deletions
|
@ -389,14 +389,14 @@ class MPDWrapper(object):
|
||||||
elif command == 'Stop':
|
elif command == 'Stop':
|
||||||
self.stop()
|
self.stop()
|
||||||
elif command == 'SetPosition':
|
elif command == 'SetPosition':
|
||||||
trackid = params['TrackId']
|
position = float(params['Position'])
|
||||||
trackid = trackid.rsplit('/', 1)[1]
|
if 'TrackId' in params:
|
||||||
position = params['Position']
|
trackid = params['TrackId'].rsplit('/', 1)[1]
|
||||||
position = int(position) / 1000000
|
|
||||||
self.seekid(int(trackid), position)
|
self.seekid(int(trackid), position)
|
||||||
|
else:
|
||||||
|
self.seekcur(position)
|
||||||
elif command == 'Seek':
|
elif command == 'Seek':
|
||||||
offset = params['Offset']
|
offset = float(params['Offset'])
|
||||||
offset = int(offset) / 1000000
|
|
||||||
strOffset = str(offset)
|
strOffset = str(offset)
|
||||||
if offset >= 0:
|
if offset >= 0:
|
||||||
strOffset = "+" + strOffset
|
strOffset = "+" + strOffset
|
||||||
|
|
|
@ -329,7 +329,7 @@ class SnapcastWrapper(object):
|
||||||
f"Can't cast value {value} to {tag_mapping[key][1]}")
|
f"Can't cast value {value} to {tag_mapping[key][1]}")
|
||||||
|
|
||||||
if not 'mpris:artUrl' in self._metadata:
|
if not 'mpris:artUrl' in self._metadata:
|
||||||
self._metadata['mpris:artUrl'] = f'http://{self._params["host"]}:{self._params["port"]}/launcher-icon.png'
|
self._metadata['mpris:artUrl'] = f'http://{self._params["host"]}:{self._params["port"]}/snapcast-512.png'
|
||||||
|
|
||||||
logger.info(f'mpris meta: {self._metadata}')
|
logger.info(f'mpris meta: {self._metadata}')
|
||||||
|
|
||||||
|
@ -926,7 +926,7 @@ class MPRISInterface(dbus.service.Object):
|
||||||
@ dbus.service.method(__player_interface, in_signature='x', out_signature='')
|
@ dbus.service.method(__player_interface, in_signature='x', out_signature='')
|
||||||
def Seek(self, offset):
|
def Seek(self, offset):
|
||||||
logger.debug(f'Seek {offset}')
|
logger.debug(f'Seek {offset}')
|
||||||
snapcast_wrapper.control("Seek", {"Offset": offset})
|
snapcast_wrapper.control("Seek", {"Offset": float(offset) / 1000000})
|
||||||
# status = mpd_wrapper.status()
|
# status = mpd_wrapper.status()
|
||||||
# current, end = status['time'].split(':')
|
# current, end = status['time'].split(':')
|
||||||
# current = int(current)
|
# current = int(current)
|
||||||
|
@ -944,7 +944,7 @@ class MPRISInterface(dbus.service.Object):
|
||||||
def SetPosition(self, trackid, position):
|
def SetPosition(self, trackid, position):
|
||||||
logger.debug(f'SetPosition TrackId: {trackid}, Position: {position}')
|
logger.debug(f'SetPosition TrackId: {trackid}, Position: {position}')
|
||||||
snapcast_wrapper.control(
|
snapcast_wrapper.control(
|
||||||
"SetPosition", {"TrackId": trackid, "Position": position})
|
"SetPosition", {"TrackId": trackid, "Position": float(position) / 1000000})
|
||||||
self.Seeked(position)
|
self.Seeked(position)
|
||||||
|
|
||||||
# song = mpd_wrapper.last_currentsong()
|
# song = mpd_wrapper.last_currentsong()
|
||||||
|
|
|
@ -387,8 +387,8 @@ void PcmStream::control(const jsonrpcpp::Request& request, const StreamControl::
|
||||||
std::string command = request.params().get("command");
|
std::string command = request.params().get("command");
|
||||||
if (command == "SetPosition")
|
if (command == "SetPosition")
|
||||||
{
|
{
|
||||||
if (!request.params().has("params") || !request.params().get("params").contains("Position") || !request.params().get("params").contains("TrackId"))
|
if (!request.params().has("params") || !request.params().get("params").contains("Position"))
|
||||||
throw SnapException("SetPosition requires parameters 'Position' and 'TrackId'");
|
throw SnapException("SetPosition requires parameters 'Position' and optionally 'TrackId'");
|
||||||
if (!properties_.can_seek)
|
if (!properties_.can_seek)
|
||||||
throw SnapException("CanSeek is false");
|
throw SnapException("CanSeek is false");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue