TaylorSMarks / playsound

Pure Python, cross platform, single function module with no dependencies for playing sounds.
Other
501 stars 118 forks source link

Playsound can't play several mp3 #151

Open PeterBan11 opened 5 months ago

PeterBan11 commented 5 months ago

I can't play next mp3 file after another: from playsound import playsound

playsound("first.mp3") playsound("second.mp3")

spatbord commented 4 months ago

With playsound 1.3.0 I'm also having trouble. The following example works fine with playsound 1.2.2. Example:

from playsound import playsound
playsound(r'F:\OneDrive\Python\sounds\Ring02.wav')

This will play the sound, and then give:

  Error 305 for command:
    close "F:\OneDrive\Python\sounds\Ring02.wav"
  Cannot specify extra characters after a string enclosed in quotation marks.
Failed to close the file: "F:\OneDrive\Python\sounds\Ring02.wav"

When I try to play it again, using: playsound(r'F:\OneDrive\Python\sounds\Ring02.wav') it doesn't play, but gives this error:

Error 305 for command:
    open "F:\OneDrive\Python\sounds\Ring02.wav"
  Cannot specify extra characters after a string enclosed in quotation marks.
  Error 305 for command:
    close "F:\OneDrive\Python\sounds\Ring02.wav"
  Cannot specify extra characters after a string enclosed in quotation marks.
Failed to close the file: "F:\OneDrive\Python\sounds\Ring02.wav"
Traceback (most recent call last):
 File "C:\Program Files\JetBrains\PyCharm Community Edition 2023.3.2\plugins\python-ce\helpers\pydev\pydevconsole.py", line 364, in runcode
  coro = func()
      ^^^^^^
 File "<input>", line 1, in <module>
 File "C:\Users\michi\PycharmProjects\SmartBetaTest\venv\Lib\site-packages\playsound.py", line 72, in _playsoundWin
  winCommand(u'open {}'.format(sound))
 File "C:\Users\michi\PycharmProjects\SmartBetaTest\venv\Lib\site-packages\playsound.py", line 64, in winCommand
  raise PlaysoundException(exceptionMessage)
playsound.PlaysoundException: 
  Error 305 for command:
    open "F:\OneDrive\Python\sounds\Ring02.wav"
  Cannot specify extra characters after a string enclosed in quotation marks.
EphDoering commented 3 months ago

I believe this issue was fixed three years ago, but was never released to pip. The issue is/was caused by the buffer passed to the dll not being null terminated so if a shorter command was passed after a longer command then there would be unintentional data in the buffer that would be read by the dll. This was fixed by switching to automatically converted arguments.

TaylorSMarks commented 3 months ago

IIRC, there’s never been a test case (or suite) that showed a reliable improvement. Bugs like this occurred both with and without any “fixes”.Any PRs to “fix” stuff should include tests that fail without the fix and pass with it. Ideally the test should work on Windows Server, but regrettably Windows Server lacks the media components which makes running the test on Travis…TaylorSent from my iPhoneOn Mar 30, 2024, at 07:00, Gweneph @.***> wrote: I believe this issue was fixed three years ago, but was never released to pip. The issue is/was caused by the buffer passed to the dll not being null terminated so if a shorter command was passed after a longer command then there would be unintentional data in the buffer that would be read by the dll. This was fixed by switching to automatically converted arguments.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

sjmikler commented 2 months ago

@PeterBan11 @spatbord I had similar problems with Failed to close the file.

You might want to see my fork that fixes them for me: https://github.com/sjmikler/playsound3. It is available on pip as playsound3.