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.
This commit is contained in:
Ricardo Constantino 2016-11-24 02:45:25 +00:00
parent aad8e7db7e
commit ed357ef404
No known key found for this signature in database
GPG Key ID: EFD16019AE4FF531
2 changed files with 4 additions and 2 deletions

View File

@ -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'] 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_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 = ['--msg-level=all=error,cplayer=info,term-msg=info', '--input-terminal=no', '--input-file=/dev/stdin']
MPV_SLAVE_ARGS_NEW = ['--term-playing-msg=<SyncplayUpdateFile>\nANS_filename=${filename}\nANS_length=${=length}\nANS_path=${path}\n</SyncplayUpdateFile>', '--terminal=yes'] MPV_SLAVE_ARGS_NEW = ['--term-playing-msg=<SyncplayUpdateFile>\nANS_filename=${filename}\nANS_length=${=length:${=duration:0}}\nANS_path=${path}\n</SyncplayUpdateFile>', '--terminal=yes']
MPV_NEW_VERSION = False MPV_NEW_VERSION = False
VLC_SLAVE_ARGS = ['--extraintf=luaintf', '--lua-intf=syncplay', '--no-quiet', '--no-input-fast-seek', VLC_SLAVE_ARGS = ['--extraintf=luaintf', '--lua-intf=syncplay', '--no-quiet', '--no-input-fast-seek',
'--play-and-pause', '--start-time=0'] '--play-and-pause', '--start-time=0']

View File

@ -120,9 +120,11 @@ class NewMpvPlayer(OldMpvPlayer):
self.lastMPVPositionUpdate = time.time() self.lastMPVPositionUpdate = time.time()
def _getProperty(self, property_): def _getProperty(self, property_):
floatProperties = ['length','time-pos'] floatProperties = ['time-pos']
if property_ in floatProperties: if property_ in floatProperties:
propertyID = u"={}".format(property_) propertyID = u"={}".format(property_)
elif property_ == 'length':
propertyID = u'=length:${=duration:0}'
else: else:
propertyID = property_ propertyID = property_
self._listener.sendLine(u"print_text ""ANS_{}=${{{}}}""".format(property_, propertyID)) self._listener.sendLine(u"print_text ""ANS_{}=${{{}}}""".format(property_, propertyID))