Fix resetPosition for streams on mpv (hopefully)

This commit is contained in:
Et0h 2015-10-02 12:01:37 +01:00
parent a81a4ceb16
commit 48a2ad65d6
2 changed files with 13 additions and 1 deletions

View File

@ -116,6 +116,7 @@ MPC_RETRY_WAIT_TIME = 0.01
MPC_MAX_RETRIES = 30
MPC_PAUSE_TOGGLE_DELAY = 0.05
MPV_NEWFILE_IGNORE_TIME = 1
STREAM_ADDITIONAL_IGNORE_TIME = 10
MPV_LOCK_WAIT_TIME = 0.2
VLC_OPEN_MAX_WAIT_TIME = 15
VLC_MIN_PORT = 10000

View File

@ -3,6 +3,7 @@ import subprocess
from syncplay.players.mplayer import MplayerPlayer
from syncplay.messages import getMessage
from syncplay import constants
from syncplay.utils import isURL
import os, sys, time
class MpvPlayer(MplayerPlayer):
@ -129,7 +130,12 @@ class NewMpvPlayer(OldMpvPlayer):
if self.lastMPVPositionUpdate is None:
return self._client.getGlobalPosition()
if self._recentlyReset:
return self._position
diff = time.time() - self.lastMPVPositionUpdate
if diff > constants.MPV_UNRESPONSIVE_THRESHOLD:
self.reactor.callFromThread(self._client.ui.showErrorMessage, getMessage("mpv-unresponsive-error").format(int(diff)), True)
self.drop()
@ -184,10 +190,15 @@ class NewMpvPlayer(OldMpvPlayer):
def openFile(self, filePath, resetPosition=False):
if resetPosition:
self.lastResetTime = time.time()
if isURL(filePath):
self.lastResetTime += constants.STREAM_ADDITIONAL_IGNORE_TIME
self._loadFile(filePath)
if self._paused != self._client.getGlobalPaused():
self.setPaused(self._client.getGlobalPaused())
self.setPosition(self._client.getGlobalPosition())
if resetPosition == False:
self.setPosition(self._client.getGlobalPosition())
else:
self._storePosition(0)
def _handleUnknownLine(self, line):
self.mpvVersionErrorCheck(line)