cheofusi / just_playback

A small library for playing audio files in python, with essential playback functionality.
MIT License
70 stars 7 forks source link

Error when playing sound second time #9

Closed penguin-number-123 closed 3 years ago

penguin-number-123 commented 3 years ago

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.

cheofusi commented 3 years ago

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?

penguin-number-123 commented 3 years ago

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?

cheofusi commented 3 years ago

I apologize for the delay.

0.1.6 fixes this issue

penguin-number-123 commented 3 years ago

Thanks!