0
votes

I have some simple code to play a sound using PyGame in Python 3.4.

import pygame
file = 'Henesys.ogg' # this file exists in current directory
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load(file)
pygame.mixer.music.play(0)
pygame.event.wait()

However, when I run it, it doesn't work. When running in IDLE, the interpreter shell is no longer reactive (as intended) but there is no sound playing. I'm not sure why. I searched around the internet and found that people could run this code without any problems. I can't determine where the issue might be.

Can someone tell me what I'm doing wrong?

For reference, my OS is Windows 7 64bit, installed Python 3.4.3 and Pygame (installed from wheel: pygame-1.9.2a0-cp34-none-32.whl).

Also for reference, platform.architecture() returns ('32bit', 'WindowsPE').

Thank you.

1

1 Answers

0
votes

The first thing you can try is changing the

pygame.mixer.music.play(0)

line to

pygame.mixer.music.play(0, 0.0)

as I found on the PyGame site, the "pygame.mixer.music.play()" has two parameters.

The second thing you can try is changing the

pygame.mixer.music.load(file)

to

pygame.mixer.music.load("Henesys.ogg")