Skip to content

Instantly share code, notes, and snippets.

@nbonfire
Created December 5, 2014 06:20
Show Gist options
  • Save nbonfire/4761ff23a9d7acd50aaf to your computer and use it in GitHub Desktop.
Save nbonfire/4761ff23a9d7acd50aaf to your computer and use it in GitHub Desktop.
pyglet example showing increasing delay loading a video to restart
import pyglet
from pyglet.window import key
vidPath="dog.mp4"
MediaLoad = pyglet.media.load(vidPath)
#window = pyglet.window.Window((MediaLoad.video_format.width,MediaLoad.video_format.height))
window = pyglet.window.Window(resizable=True)
player = pyglet.media.Player()
player.queue(MediaLoad)
player.play()
@window.event
def on_draw():
window.clear()
if player.source and player.source.video_format:
player.get_texture().blit(0,0)
@window.event
def on_key_press(symbol, modifiers):
if symbol == key.SPACE:
vidPath="dog.mp4"
newload=pyglet.media.load(vidPath)
player.queue(newload)
player.next_source()
pyglet.app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment