I'd like to have an arbitrary function called when a sound ends. I
don't understand pyglet events extremely well, but from what I read,
it seems like following should work, but it doesn't. What am I
missing??? (You'll need to use a different sound file unless you're
on Leopard with the latest iLife)
import pyglet
w = pyglet.window.Window()
disconnect_sound = pyglet.media.load('/Library/Audio/Apple
Loops/Apple/iLife Sound Effects/Sci-Fi/Computer Data 05.aif',
streaming=False)
def some_function():
# This never, ever gets called.
print "The sound ended and the function fired!"
@w.event
def on_key_press(a, b):
player = pyglet.media.Player()
player.queue(disconnect_sound)
player.push_handlers(on_eos=some_function)
player.play()
while not w.has_exit:
w.dispatch_events()
pyglet.media.dispatch_events()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---