2016-02-20 60 views
0

我真的很希望能夠在使用pygame.mixer.music模塊MIDI文件某個地方開始播放,但我得到了以下錯誤:設置回放位置

error: Position not implemented for music type 

(這是與pygame 1.9.1。)

我看不到任何其他庫,有這種類型的MIDI音頻合成,我可以使用。有什麼建議麼?

回答

0

我pygame 1.9.1 python 2.7.x上。我能夠模擬AttributeError: 'module' object has no attribute 'set_pos'錯誤。
按照附帶安裝的版本,這是在C:\Python27\Lib\site-packages\pygame\docs

1)首先選擇文檔:
pygame的版本1.9.2起先後pygame.mixer.music.set_pos功能。因此,您可能想嘗試並將pygame升級到1.9.2
pygame網站上的官方文檔是1.9.2,我們都指的是。
Here is a link官方1.9.2 pygame的文檔

2)第二選擇:
接下來,當前的版本,你可以嘗試使用 pygame.mixer.music.play(loop= ?, start=?)參數,但只適用於MP3和OGG。 因此,您需要將現有的MIDI文件轉換爲MP3/OGG才能使用此選項。

最佳和更容易的選擇將是pygame的官方文檔1.9.1升級到1.9.2

複製/粘貼

pygame.mixer.music.play Start the playback of the music stream

pygame.mixer.music.play(loops=0, start=0.0): return None
This will play the loaded music stream. If the music is already playing it will be restarted.

The loops argument controls the number of repeats a music will play. play(5) will cause the music to played once, then repeated five times, for a total of six. If the loops is -1 then the music will repeat indefinitely.

The starting position argument controls where in the music the song starts playing. The starting position is dependent on the format of music playing. MP3 and OGG use the position as time (in seconds). MOD music it is the pattern order number. Passing a startpos will raise a NotImplementedError if it cannot set the start position