[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] movie flip/update



mike@zcentric.com wrote:
Here is my little test app. If I move the window around I lose video. If I
uncomment the flip() I lose video. I have not clue if I could even rendor
mplayer which is opened in a popen to a surface. You guys can just tell me
this is a pipe dream in pygame and I'll move on.
i tried it out. with your version i could move the window around fine and the video didn't get lost. i was also able to add some graphics to the bottom edge of the display. here's the version i did, not much in the line of changes.

this seems like it would work for me, but i'm sure all mplayer setups are a little different.
import pygame
from pygame.locals import *
import popen2
import os
import commands
import sys



def main():

	pygame.init()
	screen = pygame.display.set_mode((640, 480))
	pygame.display.set_caption('Test App')


	# getting the window ID
	windId = commands.getoutput("xwininfo -tree -name \"Test App\" | grep 640x480 | awk {\' print $1 \'}")
	print windId

	pygame.mixer.quit()
	mplayer_cmd = 'mplayer -vo xv -really-quiet -slave -wid %s halflife2_e3demo.avi' % (windId)
	mplayer_cmd = mplayer_cmd.encode ('iso-8859-15')

	mplayer = popen2.Popen3(mplayer_cmd)

        c = 0

	while 1:
		for event in pygame.event.get():
			if event.type == QUIT:
				sys.exit(2)
			if event.type == KEYDOWN:
				print "OMG keydown!"
			if event.type == MOUSEBUTTONDOWN:
				print "we got a mouse button down!"

                c = (c+1) % 250
                clr = c, 50, c
                r = screen.fill(clr, (0, 460, 640, 20))
                pygame.display.update(r)

                pygame.time.wait(10)


if __name__ == '__main__': main()