Files

25 lines
613 B
Python
Raw Permalink Normal View History

############################################
# Created on 1-23-2013. Miguel Angel Astor #
############################################
2013-01-23 22:30:40 -04:30
import pygame
try:
import pygame.mixer as mixer
except ImportError:
2013-01-23 22:48:51 -04:30
import android.mixer as mixer
2013-01-23 22:30:40 -04:30
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()