Playlist update instead of refresh, time/skip sync
- Playlist destroys and creates members on the fly - Updates time live, and ensures skips aren't detected twice Im sure there are still bugs, but ill find them as i go I am also still going to refactor this, so it''s not going to be merged into main for a while
This commit is contained in:
parent
f064183b9a
commit
87687506b1
3 changed files with 102 additions and 16 deletions
|
|
@ -90,21 +90,22 @@ def getSongInfo(song):
|
|||
|
||||
# this is a loop that plays the songs and checks for playlist changes, skips, ect.
|
||||
counter = 0
|
||||
isPlaying = False
|
||||
def playQueuedSongs():
|
||||
global skipNow
|
||||
global songNext
|
||||
global partyMode
|
||||
global counter
|
||||
global isPlaying
|
||||
while True:
|
||||
with playlistLock:
|
||||
counter+=1
|
||||
if(counter > 10):
|
||||
if(counter > 2):
|
||||
playingState = str(player.get_state()) == "State.Playing"
|
||||
socketio.emit('timeUpdate',{"elapsedTime":player.get_time()/1000,"playingState":playingState})
|
||||
counter = 0
|
||||
playerState = str(player.get_state())
|
||||
endStates = ["State.Ended","State.Stopped","State.NothingSpecial"]
|
||||
if playerState == "State.Ended":
|
||||
socketio.emit("skipSong",None)
|
||||
if playlist and (playerState in endStates or skipNow == True):
|
||||
# New song is in the queue and (the previous song is over or skip has been pressed)
|
||||
player.stop()
|
||||
|
|
@ -113,7 +114,12 @@ def playQueuedSongs():
|
|||
media = vlcInstance.media_new(soundLocation+songNext)
|
||||
player.set_media(media)
|
||||
player.play()
|
||||
isPlaying = True
|
||||
socketio.emit("skipSong",None)
|
||||
elif (skipNow==True or (playerState in endStates)):
|
||||
if(isPlaying):
|
||||
socketio.emit("skipSong",None)
|
||||
isPlaying = False
|
||||
# print(playerState)
|
||||
# skip was pressed and there are no new songs
|
||||
skipNow=False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue