Future-proof mpv _getProperty

This commit is contained in:
Et0h 2015-02-16 23:07:45 +00:00
parent 19a22b9105
commit 1bdea76397
2 changed files with 9 additions and 1 deletions

View File

@ -149,7 +149,7 @@ class MplayerPlayer(BasePlayer):
def lineReceived(self, line):
if line:
self._client.ui.showDebugMessage("player << {}".format(line))
if "Failed to get value of property" in line:
if "Failed to get value of property" in line or "=(unavailable)" in line:
if "filename" in line:
self._getFilename()
elif "length" in line:

View File

@ -101,6 +101,14 @@ class OldMpvPlayer(MpvPlayer):
class NewMpvPlayer(OldMpvPlayer):
lastResetTime = None
def _getProperty(self, property_):
floatProperties = ['length','time-pos']
if property_ in floatProperties:
propertyID = u"={}".format(property_)
else:
propertyID = property_
self._listener.sendLine(u"print_text ""ANS_{}=${{{}}}""".format(property_, propertyID))
def _storePosition(self, value):
if self._recentlyReset():
self._position = 0