0

I am trying to play a simple beat with the pygame.mixer.

import os
import pygame
import pygame.mixer

# Initialize the game
pygame.init()
pygame.mixer.init() # frequency, size, channels, buffersize
print(os.listdir())

# ... some other stuff....

try:
    sound = pygame.mixer.Sound("low_click.wav")
    print('low_click.wav')
    sound.play()
except pygame.error:
    pass

The program just prints

['metronom_quintenzirkel.py', 'low_click.wav', 'data']

, so an exception occured.

What has gone wrong?

Michael Currie
  • 13,721
  • 9
  • 42
  • 58
  • What's the exception and on what line? – martineau Aug 28 '15 at 22:13
  • 2
    OK, the except pygame.error: pass bit is not a good idea. Change it to except pygame.error as e: print e, and see what prints out. – user3757614 Aug 28 '15 at 22:51
  • Excuse me for the missing exception. It occurs in line sound = pygame.mixer.Sound("low_click.wav") pygame.error: Unable to open file 'low_click.wav' I checked the file 'low_click.wav'. It is just a simple beat and the file can be opened with a music player program – Alexander Tille Aug 31 '15 at 18:32

0 Answers0