Pygame电影播放器​​只显示黑屏

时间:2013-12-02 19:27:19

标签: python pygame movie

我想用Pygame的电影模块播放.mpg视频。 我的问题是,我从显示窗口看到的唯一的东西是标准的黑屏。声音效果很好,显示也是如此,但它是空白的。

我使用的代码。

import sys
import os

if sys.platform == 'win32' and sys.getwindowsversion()[0] >= 5: # condi. and
    # On NT like Windows versions smpeg video needs windb.
    os.environ['SDL_VIDEODRIVER'] = 'windib'

import pygame
from pygame.locals import *

try:
    from cStringIO import StringIO as BytesIO
except ImportError:
    from io import BytesIO
from pygame.compat import unicode_

QUIT_CHAR = unicode_('q')

pygame.init()
pygame.mixer.quit()
pygame.display.init()

f = BytesIO(open("C:\Python33_vol2\ecstacy_of_gold.mpg", 'rb').read())
movie = pygame.movie.Movie(f)
w, h = movie.get_size()
w = int(w * 1.3 + 0.5)
h = int(h * 1.3 + 0.5)
wsize = (w+10, h+10)
msize = (w, h)
screen = pygame.display.set_mode(wsize)
movie.set_display(screen, Rect((5, 5), msize))

pygame.event.set_allowed((QUIT, KEYDOWN))
pygame.time.set_timer(USEREVENT, 1000)
movie.play()
while movie.get_busy():
    evt = pygame.event.wait()
    if evt.type == QUIT:
        break
    if evt.type == KEYDOWN and evt.unicode == QUIT_CHAR:
        break
if movie.get_busy():
    movie.stop()
pygame.time.set_timer(USEREVENT, 0)
while 1:
    ev = pygame.event.poll() 
    if ev.type == pygame.QUIT:
        pygame.quit()

0 个答案:

没有答案
相关问题