Andy_de_jong
Posts: 2
Joined: Thu Dec 20, 2012 1:44 pm

Pygame movie.play-no sound

Fri Dec 21, 2012 6:22 am

Hello.

I get video but no sound when I play videos with the pygame play.movie command. If I use pygame to play an mp3 I do get sound.

My file is using the MPEG-1 Video Codec and the MP3 Audio Codec.

Can anyone point me to a file that they have successfully played? Is there something wrong in my code?

Code: Select all

import pygame
from time import sleep

pygame.init()
screen = pygame.display.set_mode((320,240))
movie=pygame.movie.Movie("o2.mpg")
pygame.mixer.quit()
if (movie.has_audio()):
    print ("movie has audio")
movie.set_volume (1.0)
movie.play()
I am using Python 2.7.3rc2 and 2012-10-28-wheezy-rasbian

Andy_de_jong
Posts: 2
Joined: Thu Dec 20, 2012 1:44 pm

Re: Pygame movie.play-no sound

Sun Dec 23, 2012 8:00 pm

There was something wrong in my code. I found the following example file which shows the correct method. /usr/share/pyshared/pygame/examples/movieplayer.py

pygame.mixer.quit () needed to be before movie=pygame.movie.Movie ("o2.mpg")

Return to “Python”