use MP3Decoder.open()
This commit is contained in:
parent
e8a2a77ac6
commit
b4f18f7d8f
1 changed files with 8 additions and 9 deletions
|
|
@ -256,17 +256,16 @@ class Peripherals:
|
||||||
self.wavfile.close()
|
self.wavfile.close()
|
||||||
|
|
||||||
def play_mp3_file(self, filename):
|
def play_mp3_file(self, filename):
|
||||||
with open(filename, "rb") as f:
|
if self._mp3_decoder is None:
|
||||||
if self._mp3_decoder is None:
|
from audiomp3 import MP3Decoder # noqa: PLC0415, import outside top-level
|
||||||
from audiomp3 import MP3Decoder # noqa: PLC0415, import outside top-level
|
|
||||||
|
|
||||||
self._mp3_decoder = MP3Decoder(f)
|
self._mp3_decoder = MP3Decoder(filename)
|
||||||
else:
|
else:
|
||||||
self._mp3_decoder.file = f
|
self._mp3_decoder.open(filename)
|
||||||
|
|
||||||
self.audio.play(self._mp3_decoder)
|
self.audio.play(self._mp3_decoder)
|
||||||
while self.audio.playing:
|
while self.audio.playing:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def stop_play(self):
|
def stop_play(self):
|
||||||
"""Stops playing a wav file."""
|
"""Stops playing a wav file."""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue