Hi all, I've got a problem with the appended script using a channel in pygame.mixer While it runs correctly with Python2.6 I get an error with Python 3.1 which, I think, indicates a bug in the pygame port to 3.1 How should I deal with this? - Did I make an error? - Does someone know a workaround? - Can i expect a bugfix in the near future? - Or should I stick with using Sound objects and their play method only? Regards, Gregor
""" playSound.py demonstrates playing an ogg sound on demand """ import pygame pygame.init() pygame.mixer.init() def main(): screen = pygame.display.set_mode((640, 480)) pygame.display.set_caption("play sound") #create background background = pygame.Surface(screen.get_size()) background = background.convert() background.fill((255, 255, 0)) #create label myFont = pygame.font.SysFont("Comic Sans MS", 30) label = myFont.render("Press SPACE to hear a sound", 1, (0, 0, 255)) #create sound sound = pygame.mixer.Sound("someSound.ogg") c0 = pygame.mixer.Channel(0) keepGoing = True clock = pygame.time.Clock() while keepGoing: for event in pygame.event.get(): if event.type == pygame.QUIT: keepGoing = False elif event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: c0.play(sound) screen.blit(background, (0, 0)) screen.blit(label, (100, 100)) pygame.display.flip() if __name__ == "__main__": main()
Attachment:
someSound.ogg
Description: Binary data