You aren't dispatching events for the player. If you call the play
method of a source you get a
managed sound player which will be handled by
pyglet.media.dispatch_events, normal players don't do this (in 1.0,
1.1 is changing things a little). At any rate, try this:
...
@w.event
def on_key_press(a, b):
player = disconnect_sound.play()
player.push_handler(on_eos=some_function)
...
Chard
On Jun 18, 11:07 pm, Nathan <[EMAIL PROTECTED]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---