Wrote the function of alternate playback of audio files and added it to a separate stream. When the program starts, the function is executed once, as evidenced by the output to the console of the word "Busy" once. Why is that? What's my mistake?
def queue(self, index): if self.busy(): print("Busy") else: if index == len(self.playlist)-1: index = 0 else: index +=1 time.sleep(5) self.play_music(index) time.sleep(1) def play_music(self, index=0): if self.paused: mixer.music.unpause() self.statusBar['text'] = 'Music Resumed' self.paused = False else: try: self.stop_music() time.sleep(1) self.play_song = self.playlist[index] mixer.music.load(self.play_song) mixer.music.play() self.show_details(self.play_song) self.statusBar['text'] = os.path.basename(self.play_song) t2 = threading.Thread(target=self.queue, args=(index,)) t2.start() except: messagebox.showerror('File not found!', 'Music Player couldn\'t find the file. Please, check again!')
Busyoutput. - iksuy 1:21 pm