Skip to content

Commit

Permalink
Restore server-side playlist on reconnect (#567) (#590)
Browse files Browse the repository at this point in the history
* Restore server-side playlist on reconnect (#567)

* Restore server-side playlist on reconnect (v2)
  • Loading branch information
Et0h authored Feb 28, 2023
1 parent e0dd0cf commit 807886c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions syncplay/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,19 @@ def savePlaylistToFile(self, path):
self._ui.showMessage("Playlist saved as {}".format(path)) # TODO: Move to messages_en


def playlistNeedsRestoring(self, files, username):
return self._client.sharedPlaylistIsEnabled() and self._playlist != None and files == [] and username == None and not self._playlistBufferIsFromOldRoom(self._client.userlist.currentUser.room)

def playlistNeedsRestoring(self, files, username):
return self._client.sharedPlaylistIsEnabled() and len(self._playlist) > 0 and not files and username == None and (self._previousPlaylistRoom == None or self._previousPlaylistRoom == self._client.userlist.currentUser.room)

def changePlaylist(self, files, username=None, resetIndex=False):
if self.playlistNeedsRestoring(files, username):
self._ui.showDebugMessage("Restoring playlist on reconnect...")
files = self._playlist.copy()
self._client._protocol.setPlaylist(files)
self._client._protocol.setPlaylistIndex(self._playlistIndex)
return
self.queuedIndexFilename = None
if self._playlist == files:
if self._playlistIndex != 0 and resetIndex:
Expand Down

0 comments on commit 807886c

Please sign in to comment.