cheofusi/just_playback

Error when playing sound second time

Closed this issue · 4 comments

Error

Traceback (most recent call last):
File "d:/Mumuji/Desktop/test/langtestv1.py", line 58, in
pb.play()
File "C:\Users\Mumuji\AppData\Roaming\Python\Python38\site-packages\just_playback\playback.py", line 78, in play
self.__bind(lib.stop_audio_stream(self.__ma_attrs))
File "C:\Users\Mumuji\AppData\Roaming\Python\Python38\site-packages\just_playback\playback.py", line 223, in __bind
raise MiniaudioError(MA_RESULT_STR[ma_res])
just_playback.ma_result.MiniaudioError: MA_INVALID_OPERATION

Desc

I have a simple image recognition, everything works fine, it plays the sound, however, the next time i try to do it this error is raised. I have to restart the pygame window for it to work.
It seems that it has something to do with miniaudio.

HI @penguin-number-123

Could you post a minimal script which without Pygame, makes a sequence of calls on the Playback object that reproduces the error?

from just_playback import Playback
from time import sleep
pb = Playback()
pb.load_file("sound76.mp3")
pb.play()
sleep(3)
pb.load_file("sound77.mp3")
pb.play()
Context:
There are two files called sound76.mp3 and sound77.mp3. They both play fine. It appears the error is from here:

            if self.__ma_attrs.audio_stream_ended_naturally:
                self.__bind(lib.stop_audio_stream(self.__ma_attrs)<----- here)
                self.__ma_attrs.audio_stream_ended_naturally = False

I don't see vscode highlight it, maybe missing import?

I apologize for the delay.

0.1.6 fixes this issue