Question

I'm new to pyglet and i have a problem with video.. I'm trying to play a video using pyglet .. but instead of playing the video in the window it just exits immediately and terminates .. do you guys have any solution for this problem how can i hold the window to play vedio?? i use windows vista 64x with python 2.5 please help

and here is the code :

vidPath="vid.avi"
widnow = pyglet.window.Window()
source = pyglet.media.StreamingSource()
MediaLoad = pyglet.media.load(vidPath)
player = pyglet.media.Player()
player.queue(MediaLoad)
player.play()

@window.event
...def on_draw():
... player.get_texture.blit(0,0)

thank u very much for your time

Was it helpful?

Solution

I think calling "pyglet.app.run()" is missing.

OTHER TIPS

This might be a tad bit late and ironically if you dig around enough in the media_player.py piglet documentation you can piece this all together, but for those of us that spent hours trying to get pygame to play a movie on windows, and hopelessly tried to get pymedia to interface with pygame correctly and get the audio to sync with the video and decided to give up and switch to piglet, here is a barebones minimum example that will get a movie playing that fixes the problems in the code above.

import pyglet
vidPath="TE5.mpg"
window = pyglet.window.Window()
player = pyglet.media.Player()
source = pyglet.media.StreamingSource()
MediaLoad = pyglet.media.load(vidPath)

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)

pyglet.app.run()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top