Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playing sound with pyglet 1.4 #2

Closed
agricolab opened this issue Oct 28, 2019 · 1 comment
Closed

Playing sound with pyglet 1.4 #2

agricolab opened this issue Oct 28, 2019 · 1 comment

Comments

@agricolab
Copy link
Member

See pyglet/pyglet#81

def play_and_stop(sound):
    t0 = time.time()
    from threading import Timer
    player = sound.play()
    t = Timer(player.source.duration, player.delete)
    t.start()
    return player.source.duration + t0 -time.time()

def play_blocking(sound):
    rest = play_and_stop(sound)
    t0 = time.time()
    while (time.time()-t0) < rest:
        pass
    return 0

rest = play_blocking(get_sound())
print(rest)

rest = play_and_stop(get_sound())
print(rest)
@agricolab agricolab changed the title Playing sound with pyglet 1.4.4 Playing sound with pyglet 1.4 Oct 28, 2019
@agricolab
Copy link
Member Author

Fixed with abe3e68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant