Resolved it by myself:

while time.time() - startT < source.duration:
        pyglet.clock.tick() # This is the key, but I don't know why...
        win.dispatch_events()
        win.dispatch_event('on_draw')
        win.flip()

在 2016年12月31日星期六 UTC+8下午3:08:39,杨金骉写道:
>
> import pyglet
> import time
>
> win = pyglet.window.Window()
> win.switch_to()
>
> player = pyglet.media.Player()
> source = pyglet.media.load('data/demo.mpg')
>
> player.queue(source)
> player.play()
>
> @win.event
> def on_draw():
>     win.clear()
>     if source and source.video_format:
>         player.get_texture().blit(100,200)
>
> startT = time.time()
> while time.time() - startT < source.duration:
>     win.dispatch_events()
>     time.sleep(0.01)
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to