from naja.widgets.selector import SelectorWidget
from naja.widgets.text import TextWidget
from naja.widgets.image_box import ImageBox
+from naja.sound import sound
class MenuScene(Scene):
selector.add(quit)
self.konami = []
+ if not sound.playing_music:
+ sound.play_music('scape.ogg', 0.25)
def scene_callback(self, scene_class):
return lambda event: SceneChangeEvent.post(scene_class)
class DummySound(object):
def init(self):
- pass
+ self.playing_music = False
def play_sound(self, name, volume=DEFAULT_SOUND_VOLUME, foreground=False):
pass
class PygameSound(object):
def __init__(self):
self._sounds = {}
+ self.playing_music = False
def init(self):
mixer.init(FREQ, BITSIZE, CHANNELS, BUFFER)
mixer.music.load(track_name)
mixer.music.set_volume(volume)
mixer.music.play(-1) # loop sound
+ self.playing_music = True
def pause_music(self):
mixer.music.pause()
+ self.playing_music = False
def unpause_music(self):
mixer.music.unpause()
+ self.playing_music = True
def stop(self):
mixer.fadeout(1000)
mixer.music.stop()
+ self.playing_music = False
class SoundProxy(object):