Improve mpv newfile handling
This commit is contained in:
parent
c559fcd5fa
commit
ad7c21024f
@ -50,6 +50,7 @@ RECONNECT_RETRIES = 10
|
|||||||
SERVER_STATE_INTERVAL = 1
|
SERVER_STATE_INTERVAL = 1
|
||||||
WARNING_OSD_MESSAGES_LOOP_INTERVAL = 1
|
WARNING_OSD_MESSAGES_LOOP_INTERVAL = 1
|
||||||
AUTOPLAY_DELAY = 3.0
|
AUTOPLAY_DELAY = 3.0
|
||||||
|
DO_NOT_RESET_POSITION_THRESHOLD = 1.0
|
||||||
SYNC_ON_PAUSE = True # Client seek to global position - subtitles may disappear on some media players
|
SYNC_ON_PAUSE = True # Client seek to global position - subtitles may disappear on some media players
|
||||||
|
|
||||||
# Options for the File Switch feature:
|
# Options for the File Switch feature:
|
||||||
|
|||||||
@ -156,7 +156,7 @@ class NewMpvPlayer(OldMpvPlayer):
|
|||||||
if self._recentlyReset():
|
if self._recentlyReset():
|
||||||
self._client.ui.showDebugMessage("Recently reset, so storing position as 0")
|
self._client.ui.showDebugMessage("Recently reset, so storing position as 0")
|
||||||
self._position = 0
|
self._position = 0
|
||||||
elif self._fileIsLoaded():
|
elif self._fileIsLoaded() or (value < constants.MPV_NEWFILE_IGNORE_TIME and self._fileIsLoaded(ignoreDelay=True)):
|
||||||
self._position = max(value,0)
|
self._position = max(value,0)
|
||||||
else:
|
else:
|
||||||
self._client.ui.showDebugMessage("No file loaded so storing position as GlobalPosition ({})".format(self._client.getGlobalPosition()))
|
self._client.ui.showDebugMessage("No file loaded so storing position as GlobalPosition ({})".format(self._client.getGlobalPosition()))
|
||||||
@ -198,6 +198,9 @@ class NewMpvPlayer(OldMpvPlayer):
|
|||||||
self._listener.sendLine(u'loadfile {}'.format(self._quoteArg(filePath)), notReadyAfterThis=True)
|
self._listener.sendLine(u'loadfile {}'.format(self._quoteArg(filePath)), notReadyAfterThis=True)
|
||||||
|
|
||||||
def setPosition(self, value):
|
def setPosition(self, value):
|
||||||
|
if value < constants.DO_NOT_RESET_POSITION_THRESHOLD and self._recentlyReset():
|
||||||
|
self._client.ui.showDebugMessage("Did not seek as recently reset and {} below 'do not reset position' threshold".format(value))
|
||||||
|
return
|
||||||
super(self.__class__, self).setPosition(value)
|
super(self.__class__, self).setPosition(value)
|
||||||
self.lastMPVPositionUpdate = time.time()
|
self.lastMPVPositionUpdate = time.time()
|
||||||
|
|
||||||
@ -209,7 +212,9 @@ class NewMpvPlayer(OldMpvPlayer):
|
|||||||
self.lastResetTime += constants.STREAM_ADDITIONAL_IGNORE_TIME
|
self.lastResetTime += constants.STREAM_ADDITIONAL_IGNORE_TIME
|
||||||
self._loadFile(filePath)
|
self._loadFile(filePath)
|
||||||
if self._paused != self._client.getGlobalPaused():
|
if self._paused != self._client.getGlobalPaused():
|
||||||
self.setPaused(self._client.getGlobalPaused())
|
self._client.ui.showDebugMessage("Want to set paused to {}".format(self._client.getGlobalPaused()))
|
||||||
|
else:
|
||||||
|
self._client.ui.showDebugMessage("Don't want to set paused to {}".format(self._client.getGlobalPaused()))
|
||||||
if resetPosition == False:
|
if resetPosition == False:
|
||||||
self.setPosition(self._client.getGlobalPosition())
|
self.setPosition(self._client.getGlobalPosition())
|
||||||
else:
|
else:
|
||||||
@ -246,7 +251,11 @@ class NewMpvPlayer(OldMpvPlayer):
|
|||||||
if self._paused != self._client.getGlobalPaused():
|
if self._paused != self._client.getGlobalPaused():
|
||||||
self.reactor.callFromThread(self._client.getGlobalPaused)
|
self.reactor.callFromThread(self._client.getGlobalPaused)
|
||||||
|
|
||||||
def _fileIsLoaded(self):
|
def _fileIsLoaded(self, ignoreDelay=False):
|
||||||
|
if ignoreDelay:
|
||||||
|
self._client.ui.showDebugMessage("Ignoring _fileIsLoaded MPV_NEWFILE delay")
|
||||||
|
return True if self.fileLoaded else False
|
||||||
|
|
||||||
if self.fileLoaded == True and self.lastLoadedTime != None and time.time() > (self.lastLoadedTime + constants.MPV_NEWFILE_IGNORE_TIME):
|
if self.fileLoaded == True and self.lastLoadedTime != None and time.time() > (self.lastLoadedTime + constants.MPV_NEWFILE_IGNORE_TIME):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user