From ed357ef40484ef152c0fbfddb8b8fafe59ee2a0e Mon Sep 17 00:00:00 2001 From: Ricardo Constantino Date: Thu, 24 Nov 2016 02:45:25 +0000 Subject: [PATCH] mpv: use property expansion fallbacks for deprecated length This allows using both length and duration. mpv will fallback to duration if length isn't available. If neither are available, it falls back to 0 which doesn't break Syncplay and happens to add support for livestreams. --- syncplay/constants.py | 2 +- syncplay/players/mpv.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/syncplay/constants.py b/syncplay/constants.py index 544f585..2332f81 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -157,7 +157,7 @@ USERLIST_GUI_FILENAME_COLUMN = 3 MPLAYER_SLAVE_ARGS = ['-slave', '--hr-seek=always', '-nomsgcolor', '-msglevel', 'all=1:global=4:cplayer=4', '-af-add', 'scaletempo'] MPV_ARGS = ['--force-window', '--idle', '--hr-seek=always', '--keep-open'] MPV_SLAVE_ARGS = ['--msg-level=all=error,cplayer=info,term-msg=info', '--input-terminal=no', '--input-file=/dev/stdin'] -MPV_SLAVE_ARGS_NEW = ['--term-playing-msg=\nANS_filename=${filename}\nANS_length=${=length}\nANS_path=${path}\n', '--terminal=yes'] +MPV_SLAVE_ARGS_NEW = ['--term-playing-msg=\nANS_filename=${filename}\nANS_length=${=length:${=duration:0}}\nANS_path=${path}\n', '--terminal=yes'] MPV_NEW_VERSION = False VLC_SLAVE_ARGS = ['--extraintf=luaintf', '--lua-intf=syncplay', '--no-quiet', '--no-input-fast-seek', '--play-and-pause', '--start-time=0'] diff --git a/syncplay/players/mpv.py b/syncplay/players/mpv.py index d207db2..0278876 100644 --- a/syncplay/players/mpv.py +++ b/syncplay/players/mpv.py @@ -120,9 +120,11 @@ class NewMpvPlayer(OldMpvPlayer): self.lastMPVPositionUpdate = time.time() def _getProperty(self, property_): - floatProperties = ['length','time-pos'] + floatProperties = ['time-pos'] if property_ in floatProperties: propertyID = u"={}".format(property_) + elif property_ == 'length': + propertyID = u'=length:${=duration:0}' else: propertyID = property_ self._listener.sendLine(u"print_text ""ANS_{}=${{{}}}""".format(property_, propertyID))