1
我試圖通過pyglet播放Python 3中的歌曲。我可以播放和停止一首歌曲,但是當我嘗試播放下一首歌曲時,它會產生一個錯誤。 I followed these instructions.我會在tkinter中完成這個程序。Pyglet,播放器,下一首歌
我的代碼:
import pyglet
import glob
from tkinter import Tk, Button
songs=glob.glob("*.mp3")
player=pyglet.media.Player()
def play_song():
global player
for i in range(len(songs)):
source=pyglet.resource.media(songs[i])
player.queue(source)
player.play()
def pause_song():
player.pause()
def next_song():
player.next()
window=Tk()
play_=Button(text="play", command=play_song)
play_.pack()
pause_=Button(text="pause", command=pause_song)
pause_.pack()
next_=Button(text="next", command=next_song)
next_.pack()
window.mainloop()
錯誤:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1442, in __call__
return self.func(*args)
File "C:\Documents and Settings\Fany\Dokumenty\Hudba\Sabaton\2012 - Carolus Rex\py.py", line 15, in next_song
player.next()
AttributeError: 'Player' object has no attribute 'next'
64位版本? – 2013-03-14 01:28:39
不,32位版本 – user2062624 2013-03-14 15:08:47
你知道了嗎?我有一個類似的問題,暫停() – 2014-09-12 03:13:11