I had made a music player where I want to make a infinite loop which will play after song will end and the song is a random song(a song played from a selected folder) so I want to make loop on random_music(local variable). I had tried much but I can't make this loop.
Please help me to solve this problem
Here is my code
'''
#code
random_music = ''
mfile=''
def Play(event=None):
global random_music, mfile
if (shuffleUnshuffleBtn['text'] == ''):
mfile= MUSIC_FILE+'/../'
print("Shuffle")
print(mfile)
songs =os.listdir(mfile)
noOfSongs=len(songs)
ListOfSongsInDir = [i for i in range(1, noOfSongs)]
print(songs)
print(len(songs))
print(ListOfSongsInDir)
random_music = random.choice(songs)
while (progressbar_music_starttime==progressbar_music_startend):
print(random.choice(songs))
#random_music = random.choice(songs)
# sleep()
print(random_music)
c=(os.path.join(mfile, random_music))
# i+=1
mixer.init()
# ad=audiotrack.get()
mixer.music.load(c)
print(c)
progressbar_Ibl.place()
mixer.music.play()
progressbar_music_label.place()
song=MP3(mfile+random_music)
'''
Here MUSIC_FILE is a song that select by user
Aucun commentaire:
Enregistrer un commentaire