|
6 | 6 | # Authors: Michael Scott Asato Cuthbert |
7 | 7 | # (from an idea by Joe "Codeswell") |
8 | 8 | # |
9 | | -# Copyright: Copyright © 2012 Michael Scott Asato Cuthbert |
| 9 | +# Copyright: Copyright © 2012-25 Michael Scott Asato Cuthbert |
10 | 10 | # License: BSD, see license.txt |
11 | 11 | # ------------------------------------------------------------------------------ |
12 | 12 | ''' |
|
18 | 18 |
|
19 | 19 | https://stackoverflow.com/questions/10983462/how-can-i-produce-real-time-audio-output-from-music-made-with-music21 |
20 | 20 |
|
21 | | -Requires pygame: pip3 install pygame |
| 21 | +Requires pygame 2 (or 1.9) install with: pip3 install pygame |
22 | 22 | ''' |
23 | 23 | from __future__ import annotations |
24 | 24 |
|
@@ -87,9 +87,6 @@ def __init__( |
87 | 87 | # noinspection PyPackageRequirements |
88 | 88 | import pygame # type: ignore |
89 | 89 | self.pygame = pygame |
90 | | - # noinspection PyPackageRequirements |
91 | | - import pygame.exceptions # type: ignore |
92 | | - self.pygame_exceptions = pygame.exceptions # type: ignore # pylint: disable=no-member |
93 | 90 | except ImportError: |
94 | 91 | raise StreamPlayerException('StreamPlayer requires pygame. Install first') |
95 | 92 | if self.mixerInitialized is False or reinitMixer: |
@@ -152,10 +149,9 @@ def playStringIOFile(self, stringIOFile, busyFunction=None, busyArgs=None, |
152 | 149 | pygameClock = self.pygame.time.Clock() |
153 | 150 | try: |
154 | 151 | self.pygame.mixer.music.load(stringIOFile) |
155 | | - except self.pygame_exceptions.PygameError as pge: |
| 152 | + except self.pygame.error as pge: |
156 | 153 | raise StreamPlayerException( |
157 | | - f'Could not play music file {stringIOFile} because: ' |
158 | | - + f'{self.pygame_exceptions.get_error()}' |
| 154 | + f'Could not play music file {stringIOFile} because: {pge}' |
159 | 155 | ) from pge |
160 | 156 | self.pygame.mixer.music.play() |
161 | 157 | if not blocked: |
|
0 commit comments