pyglet版本-1.4.2。
Python-3.6.6
Ubuntu-18.04
fileSelectedHandler = (event) => {
console.log(event.target.files[0]);
this.setState({
selectedFile: event.target.files[0]
}, () => this.fileUploadHandler());
};
代码是根据documentation编写的:
import pyglet
import time
pyglet.options['audio'] = ('openal', 'pulse', 'directsound', 'silent')
source = pyglet.media.StaticSource(pyglet.media.load('explosion.wav'))
def my_playlist():
while True:
print(time.time())
print(1)
yield source
player = pyglet.media.Player()
player.queue(my_playlist())
player.play()
pyglet.app.run()
音频应与发生器返回的声音一起循环播放。
音频只播放一次。
我在这里做错了什么以及如何获得预期的结果?
答案 0 :(得分:2)
不知道是否要尝试完成更多工作,但是如果循环需要的只是循环声音,则实际上不应使用任何类型的loop
。而是使用指定的EOS_LOOP标志/触发器。
import pyglet
import time
pyglet.options['audio'] = ('openal', 'pulse', 'directsound', 'silent')
source = pyglet.media.StaticSource(pyglet.media.load('explosion.wav'))
player = pyglet.media.Player()
player.queue(source)
player.EOS_LOOP = 'loop'
player.play()
pyglet.app.run()
由于不建议使用它,因此您应该转而使用设置了循环标志的SourceGroup。