2
我使用隊列功能試過,但如何安排的音頻文件中的第一個歌曲結束後在pygame的自動播放?
pygame.mixer.music.queue(filename)
似乎並不奏效。
下面是我用它來運行我的mp3文件中的代碼:
def playmusic(self):
pygame.mixer.init()
pygame.mixer.music.load(self.music_link+self.files[self.file_index])
pygame.mixer.music.play()
self.pausedmusic = 0
self.file_index = self.fileindex + 1
pygame.mixer.music.queue(self.music_link+self.files[self.file_index])
我試圖用事件,但沒有得到來自它的解決辦法。
如果我使用此代碼,
while(pygame.mixer.music.get_busy()):
continue
self.playmusic()
的Tkinter的GUI沒有響應,但歌曲不斷玩,它會自動播放下一首歌曲,也讓我的球員沒有反應,直到所有歌曲。
我使用Python 3.6。
我推薦使用ogg文件而不是mp3,因爲pygame有mp3格式的問題,它也是專有格式,這意味着您可以被迫支付許可證費用。 – skrx