From ecf3173d2d02068164722c8035ec6d1c43c68212 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Sun, 28 Nov 2021 08:46:48 +0200 Subject: [PATCH] tentative fix for issue#229 See: https://github.com/shlomif/PySolFC/issues/229 pygame2 compat. --- pysollib/app.py | 8 ++++---- pysollib/pysolaudio.py | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pysollib/app.py b/pysollib/app.py index cf71787b..af895919 100644 --- a/pysollib/app.py +++ b/pysollib/app.py @@ -1252,9 +1252,9 @@ class Application: self.initResource(manager, dirs, ext_re, Sample) def initMusic(self): - manager = self.music_manager + music_manager = self.music_manager # find all available music songs - dirs = manager.getSearchDirs(self, "music-*", "PYSOL_MUSIC") - # print dirs + dirs = music_manager.getSearchDirs(self, "music-*", "PYSOL_MUSIC") + # print('dirs =', dirs) ext_re = re.compile(self.audio.EXTENSIONS) - self.initResource(manager, dirs, ext_re, Music) + self.initResource(music_manager, dirs, ext_re, Music) diff --git a/pysollib/pysolaudio.py b/pysollib/pysolaudio.py index 009cbf3d..43187158 100644 --- a/pysollib/pysolaudio.py +++ b/pysollib/pysolaudio.py @@ -502,6 +502,7 @@ class PyGameAudioClient(AbstractAudioClient): def __init__(self): AbstractAudioClient.__init__(self) import pygame.mixer + import pygame.mixer_music import pygame.time if os.name == 'nt': # for py2exe @@ -510,7 +511,8 @@ class PyGameAudioClient(AbstractAudioClient): import pygame.mixer_music self.mixer = pygame.mixer self.time = pygame.time - self.music = self.mixer.music + self.mixer_music = pygame.mixer_music + self.music = self.mixer_music self.audiodev = self.mixer self.sound = None self.sound_channel = None @@ -561,7 +563,7 @@ class PyGameAudioClient(AbstractAudioClient): self.sound_channel = None def _playMusicLoop(self): - # print '_playMusicLoop' + # print('_playMusicLoop') music_list = self.music_list if not music_list: return @@ -604,14 +606,14 @@ class PyGameAudioClient(AbstractAudioClient): th.start() def updateSettings(self): - if (not self.app.opt.sound or not self.app.opt.music or - self.app.opt.sound_music_volume == 0): + if (not ((self.app.opt.sound or self.app.opt.music) and + self.app.opt.sound_music_volume > 0)): if self.music: self.music.stop() self.music = None else: if not self.music: - self.music = self.mixer.music + self.music = self.mixer_music th = Thread(target=self._playMusicLoop) th.start() else: