Mercurial > touhou
comparison pytouhou/ui/music.py @ 369:f305cdd6f6c5
Fix crash with the demo version of Touhou 6
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Wed, 11 Jul 2012 15:38:15 +0200 |
parents | 94fdb6c782c1 |
children | 70e2ed71b09c |
comparison
equal
deleted
inserted
replaced
368:71cd4461bb7f | 369:f305cdd6f6c5 |
---|---|
15 | 15 |
16 from os.path import join | 16 from os.path import join |
17 | 17 |
18 from pyglet.media import AudioData, AudioFormat, StaticSource, Player | 18 from pyglet.media import AudioData, AudioFormat, StaticSource, Player |
19 from pyglet.media.riff import WaveSource | 19 from pyglet.media.riff import WaveSource |
20 | |
21 | |
22 from pytouhou.utils.helpers import get_logger | |
23 | |
24 logger = get_logger(__name__) | |
20 | 25 |
21 | 26 |
22 class InfiniteWaveSource(WaveSource): | 27 class InfiniteWaveSource(WaveSource): |
23 def __init__(self, filename, start, end, file=None): | 28 def __init__(self, filename, start, end, file=None): |
24 WaveSource.__init__(self, filename, file) | 29 WaveSource.__init__(self, filename, file) |
87 for bgm in bgms: | 92 for bgm in bgms: |
88 if not bgm: | 93 if not bgm: |
89 self.bgms.append(None) | 94 self.bgms.append(None) |
90 continue | 95 continue |
91 posname = bgm[1].replace('bgm/', '').replace('.mid', '.pos') | 96 posname = bgm[1].replace('bgm/', '').replace('.mid', '.pos') |
92 track = resource_loader.get_track(posname) | 97 try: |
98 track = resource_loader.get_track(posname) | |
99 except KeyError: | |
100 self.bgms.append(None) | |
101 logger.warn('Music description not found: %s', posname) | |
102 continue | |
93 wavname = join(resource_loader.game_dir, bgm[1].replace('.mid', '.wav')) | 103 wavname = join(resource_loader.game_dir, bgm[1].replace('.mid', '.wav')) |
94 try: | 104 try: |
95 source = InfiniteWaveSource(wavname, track.start, track.end) | 105 source = InfiniteWaveSource(wavname, track.start, track.end) |
96 except IOError: | 106 except IOError: |
97 source = None | 107 source = None |