Re: Audio wrapper for Python
Well, seems unload may not be implemented like it says in the documentation, or maybe thats for Pygame2? No matter. You can leave that out and just load a new song when you want to play something different. You may also want to move pygame.display.update() up to put it under your while loop.
import pygame
from pygame import mixer
import glob
##from mutagen.mp3 import MP3
import sys
def play(): pygame.init() mixer.init() pencere = pygame.display.set_mode([640,480]) song = ("test1.mp3") rong = ("test2.mp3") mixer.music.load(song) #audio = MP3(song) #length = audio.info.length while True: for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: mixer.music.play() if event.key == pygame.K_RIGHT: if mixer.get_busy: mixer.music.set_pos((mixer.music.get_pos()/1000.0)+60) if event.key == pygame.K_RETURN: mixer.music.stop() mixer.music.load(rong) if event.key == pygame.K_ESCAPE: mixer.music.stop() ## pygame.mixer.music.unload pygame.quit() sys.exit(0) #Update window pygame.display.update() play()
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector