mirror of
https://github.com/Syncplay/syncplay
synced 2024-12-15 19:35:07 +00:00
Hopefully fix double playlist advance bug
This commit is contained in:
parent
571f671ce2
commit
09907a0041
@ -188,7 +188,7 @@ class SyncplayClient(object):
|
||||
currentLength = self.userlist.currentUser.file["duration"] if self.userlist.currentUser.file else 0
|
||||
if pauseChange and paused and currentLength > constants.PLAYLIST_LOAD_NEXT_FILE_MINIMUM_LENGTH\
|
||||
and abs(position - currentLength ) < constants.PLAYLIST_LOAD_NEXT_FILE_TIME_FROM_END_THRESHOLD:
|
||||
self.playlist.loadNextFileInPlaylist()
|
||||
self.playlist.advancePlaylistCheck()
|
||||
elif pauseChange and utils.meetsMinVersion(self.serverVersion, constants.USER_READY_MIN_VERSION):
|
||||
pauseChange = self._toggleReady(pauseChange, paused)
|
||||
|
||||
@ -395,6 +395,9 @@ class SyncplayClient(object):
|
||||
position += diff
|
||||
return position
|
||||
|
||||
def getStoredPlayerPosition(self):
|
||||
return self._playerPosition if self._playerPosition is not None else None
|
||||
|
||||
def getPlayerPaused(self):
|
||||
if not self._lastPlayerUpdate:
|
||||
if self._lastGlobalUpdate:
|
||||
@ -1314,6 +1317,7 @@ class SyncplayPlaylist():
|
||||
self._playlist = []
|
||||
self._playlistIndex = None
|
||||
self.addedChangeListCallback = False
|
||||
self._lastPlaylistIndexChange = time.time()
|
||||
|
||||
def needsSharedPlaylistsEnabled(f): # @NoSelf
|
||||
@wraps(f)
|
||||
@ -1339,6 +1343,7 @@ class SyncplayPlaylist():
|
||||
return
|
||||
if username is None and not self._client.sharedPlaylistIsEnabled():
|
||||
return
|
||||
self._lastPlaylistIndexChange = time.time()
|
||||
if self._client.playerIsNotReady():
|
||||
if not self.addedChangeListCallback:
|
||||
self.addedChangeListCallback = True
|
||||
@ -1364,6 +1369,7 @@ class SyncplayPlaylist():
|
||||
|
||||
@needsSharedPlaylistsEnabled
|
||||
def switchToNewPlaylistIndex(self, index, resetPosition=False):
|
||||
self._lastPlaylistIndexChange = time.time()
|
||||
if self._client.playerIsNotReady():
|
||||
self._client.addPlayerReadyCallback(lambda x: self.switchToNewPlaylistIndex(index, resetPosition))
|
||||
return
|
||||
@ -1461,6 +1467,19 @@ class SyncplayPlaylist():
|
||||
if self._notPlayingCurrentIndex():
|
||||
self.switchToNewPlaylistIndex(self._playlistIndex)
|
||||
|
||||
@needsSharedPlaylistsEnabled
|
||||
def advancePlaylistCheck(self):
|
||||
position = self._client.getStoredPlayerPosition()
|
||||
currentLength = self._client.userlist.currentUser.file["duration"] if self._client.userlist.currentUser.file else 0
|
||||
if currentLength > constants.PLAYLIST_LOAD_NEXT_FILE_MINIMUM_LENGTH\
|
||||
and abs(position - currentLength ) < constants.PLAYLIST_LOAD_NEXT_FILE_TIME_FROM_END_THRESHOLD\
|
||||
and self._notJustChangedPlaylist():
|
||||
self.loadNextFileInPlaylist()
|
||||
|
||||
def _notJustChangedPlaylist(self):
|
||||
secondsSinceLastChange = time.time() - self._lastPlaylistIndexChange
|
||||
return secondsSinceLastChange > constants.PLAYLIST_LOAD_NEXT_FILE_TIME_FROM_END_THRESHOLD
|
||||
|
||||
@needsSharedPlaylistsEnabled
|
||||
def loadNextFileInPlaylist(self):
|
||||
if self._notPlayingCurrentIndex():
|
||||
|
Loading…
Reference in New Issue
Block a user