When creating a game in Pygame, the trick to getting a video with sound to play is to place pygame.mixer.quit() right after pygame.init(). This is because pygame.mixer doesn’t play well with pygame.movie. For example:
Here is what that looks like in the context of a larger block of code:
import pygame FPS = 60 pygame.init() pygame.mixer.quit() clock = pygame.time.Clock() movie = pygame.movie.Movie(r'C:\Python27\video\test-mpeg.mpg') screen = pygame.display.set_mode(movie.get_size()) movie_screen = pygame.Surface(movie.get_size()).convert() movie.set_display(movie_screen) movie.play() playing = True while playing: for event in pygame.event.get(): if event.type == pygame.QUIT: movie.stop() playing = False screen.blit(movie_screen,(0,0)) pygame.display.update() clock.tick(FPS) pygame.quit()
Here is what the Pygame documentation says about pygame.mixer.quit():
uninitialize the mixer
quit() -> None
This will uninitialize pygame.mixer pygame module for loading and playing sounds. All playback will stop and any loaded Sound objects may not be compatible with the mixer if it is reinitialized later.
More information is available in the Pygame documentation: