Skip to main content
 首页 » 编程设计

python之pygame 播放很多电影

2025年05月04日752php

我正在尝试播放一些视频。 并得到错误:

python2.6: ../../src/xcb_io.c:183: process_responses: Assertion `!(req && current_request && !(((long) (req->sequence) - (long) (current_request)) <= 0))' failed.

我认为线程和 pygame 电影播放器​​中存在一些错误。

在 pygame 的文档中写道:

The video overlay planes are drawn on top of everything in the display window. To draw the movie as normal graphics into the display window, create an offscreen Surface and set that as the movie target. Then once per frame blit that surface to the screen

有人可以给我举个例子吗?

pygame.init() 
screen = pygame.display.set_mode((1024, 768)) 
background = pygame.Surface((1024, 768)) 
 
screen.blit(background, (0, 0)) 
pygame.display.update() 
 
movie = pygame.movie.Movie('media/video.mpg') 
mrect = pygame.Rect(0,0,140,113) 
movie.set_display(screen, mrect.move(65, 150)) 
movie.set_volume(0) 
movie.play() 
 
mrect2 = pygame.Rect(0,0,140,113) 
movie2 = pygame.movie.Movie('media/video2.mpg') 
movie2.set_display(screen, mrect2.move(350, 150)) 
movie2.set_volume(0) 
movie2.play() 

请您参考如下方法:

您将两个视频设置在同一屏幕上,这可能是导致多线程错误的原因。尝试为每部电影定义新的 Surfaces 并将它们显示在屏幕上