Added sound and music.

This commit is contained in:
2013-01-23 22:30:40 -04:30
parent b800e46d29
commit 298e9c9df4
9 changed files with 95 additions and 15 deletions

View File

@@ -1,3 +1,24 @@
############################################
# Created on 1-23-2013. Miguel Angel Astor #
############################################
import pygame
try:
import pygame.mixer as mixer
except ImportError:
import android_mixer as mixer
class CachedAudioManager:
def __init__(self):
self.cache = {}
def load_sound(self, path):
if path not in self.cache:
self.cache[path] = mixer.Sound(path)
def play_sound(self, path):
if path not in self.cache:
self.load_sound(path)
self.cache[path].play()
cached_audio_manager = CachedAudioManager()