I am redesigning a program that basically plays sound on command. I am trying to find a way to shuffle a list of songs. I have the basic idea of what should happen but i can't seem so find a way for it to work.
I have tried stuff like 'time.sleep(1)' and '.after(miliseconds, function)'.
songlist = [["SongName","SongFileName",{length of song in miliseconds}],
["SongName2","SongFileName2",{length of song in miliseconds}]]
def shuffle():
shuffle=True
while shuffle == True:
song=random.choice(songlist)
song2 =random.choice(songlist)
while song==song2:
song2=random.choice(songlist)
label2.config(text=song[0])
winsound.PlaySound(song[1], winsound.SND_ASYNC)
window.after(song[2])
What i want to happen is for it to play random songs from the song list until the "stop" button is pressed (Stop button not shown in code)