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

Re: [pygame] scissors paper rock crash



That part of the documentation is outdated. The movie module works fine on Windows and is included in Pygame 1.8.0. Here is a simple movie player:

import pygame
from pygame.locals import *

def main(filepath):
   pygame.init()
   pygame.mixer.quit()
movie = pygame.movie.Movie(filepath)
   screen = pygame.display.set_mode(movie.get_size())
   movie.set_display(screen)

   pygame.event.set_allowed((QUIT, KEYDOWN))
   movie.play()
   while movie.get_busy():
       evt = pygame.event.wait()
       if evt.type == QUIT:
           break
       if evt.type == KEYDOWN and evt.unicode == u'q':
           break
   if movie.get_busy():
       movie.stop()

if __name__ == '__main__':
   import sys
   main(sys.argv[1])


It still works when an extra set_mode() call is added before "movie = ...".

Lenard


Jason M. Marshall wrote:
Nick,

That error message tells me that you're using Windows,
not Linux. With the recent versions of Pygame for
Windows, even if your code is correct, the movie will
not be played. (See
http://www.pygame.org/docs/ref/movie.html for more
info.)

A brute force solution would be to save each of your
movies' frames as a common image file. Then, to
animate, blit each frame to the screen at the right
time.
Jason

--- Nick.Treloar@xxxxxxxxxxxxxxxxxxxx wrote:

Hey i used this code as suggested for my scissors
paper rock movie

def movieu(self):
        mov_name = "video.mpg"
        pygame.mixer.quit()
        screen = pygame.display.set_mode((320, 240))
        video = pygame.movie.Movie(mov_name)
        screen =
pygame.display.set_mode(video.get_size())
        video.play()
        while video.get_busy():
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    break
        pygame.quit() #uninitializes pygame modules.
        sys.exit() #you should usually call this
after pygame.quit() so the program quits. Otherwise
errors can occur :O
python.exe has encountered a problem and needs to
close.  We are sorry for the inconvenience
is this the code or python or th computer