声音没有完全播放?

时间:2015-08-03 21:28:21

标签: python pyglet

问题是当我播放声音时,它会在播放前停止/剪切。 (声音低于1秒)

import pyglet
#from time import sleep

window = pyglet.window.Window()

# i use this for my code.
#pyglet.resource.path = ['/resources']
#pyglet.resource.reindex()
#bullet_sound = pyglet.resource.media("bullet.wav", streaming=False)
                                            ## streaming fix's an error message

bullet_sound = pyglet.media.load("/resources/bullet.wav", streaming=False)

@window.event
def on_key_press(symbol, modifiers):
    # sound only plays for a millisecond 
    bullet_sound.play()

    # this lets the sound complete
    #sleep(1)

    # also tried this with 'update()'
    #player.queue(bullet_sound)

#def update(dt):
#    player.play()
#pyglet.clock.schedule_interval(update, 1/120.0)

pyglet.app.run()

谷歌搜索时似乎无法找到任何相关信息。睡觉使声音结束,所以我想它与它过早地降低声音有关。但是如何让它不这样做?

我甚至尝试过使用播放器,将其放入更新功能并将其从事件中排队,但这并没有改变任何内容。

1 个答案:

答案 0 :(得分:0)

分段错误,声音切割,太大异常,Linux上的声音相关问题可能是由Linux / PulseAudio引起的,修复是使用OpanAL,安装(可能是预装在薄荷上)然后添加一行来使用它导入pyglet之后:

pyglet.options['audio'] = ('openal', 'silent')