Mercurial > pyntnclick
view gamelib/sound.py @ 127:9646e7c8bb97
Size detail window based on the Scene background image.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Tue, 24 Aug 2010 18:11:53 +0200 |
parents | 3b293e3b8829 |
children | d2f94f42edf3 |
line wrap: on
line source
# Sound management for Suspended Sentence # This re-implements some of the albow.resource code to # a) work around an annoying bugs # b) add some missing functionality (disable_sound) import os import pygame from albow.resource import _resource_path, dummy_sound sound_cache = {} def get_sound(*names): if sound_cache is None: return dummy_sound path = _resource_path("sounds", names) sound = sound_cache.get(path) if not sound: if not os.path.isfile(path): missing_sound("File does not exist", path) return dummy_sound try: from pygame.mixer import Sound except ImportError, e: no_sound(e) return dummy_sound try: sound = Sound(path) except pygame.error, e: missing_sound(e, path) return dummy_sound sound_cache[path] = sound return sound def no_sound(e): global sound_cache print "get_sound: %s" % e print "get_sound: Sound not available, continuing without it" sound_cache = None def disable_sound(): global sound_cache sound_cache = None def missing_sound(e, name): print "albow.resource.get_sound: %s: %s" % (name, e)