On Thu, Jun 19, 2008 at 4:38 PM, Alex Holkner <[EMAIL PROTECTED]> wrote:
>
> On 6/20/08, Nathan <[EMAIL PROTECTED]> wrote:
>>
>>  On Thu, Jun 19, 2008 at 4:01 PM, Alex Holkner <[EMAIL PROTECTED]> wrote:
>>
>>  > ManagedSoundPlayer does not dispatch on_eos events (just noticed this
>>  > isn't documented; will fix).
>>  >
>>  > In order to receive events on an ordinary Player (in pyglet 1.0), you
>>  > need to call dispatch_events on the player (not pyglet.media, which is
>>  > only for when you have ManagedSoundPlayers).
>>
>>
>> Ah, there's the key.  Though I'm using the latest pyglet svn, I'm
>>  handling my own loop the 1.0 way (my real app coiterates with
>>  Twisted), which means that I've got to call the player's
>>  dispatch_events manually.
>>
>>  This works:
>>
>>  import pyglet
>>
>>
>>  disconnect_sound = pyglet.media.load('/Library/Audio/Apple
>>  Loops/Apple/iLife Sound Effects/Sci-Fi/Computer Data 05.aif',
>>  streaming=False)
>>
>>  def some_function():
>>
>>    print "The sound ended and the function fired!"
>>
>>
>> class W(pyglet.window.Window):
>>    def __init__(self, *args, **kwargs):
>>       pyglet.window.Window.__init__(self, *args, **kwargs)
>>       self.player = pyglet.media.Player()
>>       self.player.push_handlers(on_eos=some_function)
>>
>>    def on_key_press(self, a, b):
>>       self.player.queue(disconnect_sound)
>>       self.player.play()
>>
>>  w = W()
>>
>>
>>  while not w.has_exit:
>>    w.dispatch_events()
>>
>>    w.player.dispatch_events()
>>    pyglet.media.dispatch_events()
>
> In pyglet 1.1 the dispatch_events() will also be called automatically
> if you have a pyglet.clock.tick() in your runloop.

I has already created a clock.Clock() (used for a ClockDisplay) that I
tick in the runloop, but apparently that's not enough...

~ Nathan

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to