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

Re: [pygame] movie playing



On Mon, 2006-04-24 at 14:54 +0300, Äzzet Aykut KOÃAK wrote:
> I am trying to play short movies with pygame but below codes hangs and 
> can not be terminated with ctrl-c and has to be killed. Any suggestions?
> 
> import pygame,time
> 
> if __name__=='__main__':
>     ret=pygame.init()
>     print ret
>     d=pygame.display.set_mode((640,480))
>     m=pygame.movie.Movie('test.mpg')
>     m.set_display(d)
>     m.play()
>     while m.get_busy():
>         print time.time()
>         time.sleep(1)
>     pygame.quit()

What platform are you running this on? On a unix type system ctrl-c is
good at stopping pygame.

You definitely want to add a pygame.event.pump() call to your inner
loop. You could also at least test for a QUIT event. That will allow
closing the display window to stop the program.

    while m.get_busy():
        print time.time()
        time.sleep(1)
        for e in pygame.event.get():
            if e.type == pygame.QUIT:
                import sys
                sys.exit()