Jun-27-2021, 01:40 PM
Hi,
I need to know how to get the value of the first item in the listbox?
I think this will only make the selection of the first item. I need to play music of playlist. after reaching the end of the list I need to move the path to the first item so it can replay from start again.
the second statement is working since i am not reaching the end of the playlist it will go to the next item in the list.
Thanks
I need to know how to get the value of the first item in the listbox?
1 |
song_box.select_set( 0 ) |
1 2 3 4 5 6 7 |
last_value = song_box.get( "end" ) if song = = last_value and converted_current_time = = converted_song_length: thefirst = song_box.select_set( 0 ) pygame.mixer.music.load(thefirst) pygame.mixer.music.play(loops = 0 ) elif song ! = last_value and converted_current_time = = converted_song_length: next_song() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
def next_song(): global paused if paused = = True : paused = False play() #get current file in the list next_one = song_box.curselection() # get next file in the list next_one = next_one[ 0 ] + 1 #assign the next file in the list song = song_box.get(next_one) #load and play the file pygame.mixer.music.load(song) pygame.mixer.music.play(loops = 0 ) # clear active bar in play list song_box.select_clear( 0 , END) # activate bar in play list song_box.activate(next_one) # set the active bar to next file song_box.selection_set(next_one,last = None ) |