Added sound and music.
This commit is contained in:
21
audio.py
21
audio.py
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user