comparison gamelib/sound.py @ 363:e23637457aa4

Prevent error stopping music when sound not initialized
author David Fraser <davidf@sjsoft.com>
date Tue, 08 Sep 2009 06:35:14 +0000
parents 41db9f3ba29e
children 03d5cb669298
comparison
equal deleted inserted replaced
362:d1ff514fb6d4 363:e23637457aa4
33 CURRENT_MUSIC_FILE = None 33 CURRENT_MUSIC_FILE = None
34 34
35 def stop_background_music(): 35 def stop_background_music():
36 """stops any playing background music""" 36 """stops any playing background music"""
37 global CURRENT_MUSIC_FILE 37 global CURRENT_MUSIC_FILE
38 if not SOUND_INITIALIZED:
39 return
38 CURRENT_MUSIC_FILE = None 40 CURRENT_MUSIC_FILE = None
39 # TODO: fadeout in a background thread 41 # TODO: fadeout in a background thread
40 pygame.mixer.music.stop() 42 pygame.mixer.music.stop()
41 43
42 def background_music(filename): 44 def background_music(filename):