Files
Super-HUGS-Revolution-98/audio.py

25 lines
613 B
Python
Raw 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:
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()