Mercurial > boomslang
comparison gamelib/sound.py @ 154:d2f94f42edf3
Monkey patch albow
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Tue, 24 Aug 2010 23:42:07 +0200 |
parents | 3b293e3b8829 |
children | aebd4fd5b561 |
comparison
equal
deleted
inserted
replaced
153:05ceed06ab5a | 154:d2f94f42edf3 |
---|---|
5 # b) add some missing functionality (disable_sound) | 5 # b) add some missing functionality (disable_sound) |
6 | 6 |
7 import os | 7 import os |
8 | 8 |
9 import pygame | 9 import pygame |
10 from pygame.mixer import music | |
10 from albow.resource import _resource_path, dummy_sound | 11 from albow.resource import _resource_path, dummy_sound |
12 import albow.music | |
11 | 13 |
12 sound_cache = {} | 14 sound_cache = {} |
13 | 15 |
14 def get_sound(*names): | 16 def get_sound(*names): |
15 if sound_cache is None: | 17 if sound_cache is None: |
41 sound_cache = None | 43 sound_cache = None |
42 | 44 |
43 def disable_sound(): | 45 def disable_sound(): |
44 global sound_cache | 46 global sound_cache |
45 sound_cache = None | 47 sound_cache = None |
48 albow.music.music_enabled = False | |
46 | 49 |
47 def missing_sound(e, name): | 50 def missing_sound(e, name): |
48 print "albow.resource.get_sound: %s: %s" % (name, e) | 51 print "albow.resource.get_sound: %s: %s" % (name, e) |
49 | 52 |
53 | |
54 def start_next_music(): | |
55 """Start playing the next item from the current playlist immediately.""" | |
56 if albow.music.music_enabled and albow.music.current_playlist: | |
57 next_music = albow.music.current_playlist.next() | |
58 if next_music: | |
59 #print "albow.music: loading", repr(next_music) | |
60 music.load(next_music) | |
61 music.play() | |
62 albow.music.next_change_delay = albow.music.change_delay | |
63 albow.music.current_music = next_music | |
64 | |
65 # Monkey patch | |
66 albow.music.start_next_music = start_next_music |