Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playsound can't play several mp3 #151

Open
PeterBan11 opened this issue Jan 19, 2024 · 4 comments
Open

Playsound can't play several mp3 #151

PeterBan11 opened this issue Jan 19, 2024 · 4 comments

Comments

@PeterBan11
Copy link

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

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

@spatbord
Copy link

spatbord commented Feb 15, 2024

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
Copy link

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
Copy link
Owner

TaylorSMarks commented Mar 30, 2024 via email

@sjmikler
Copy link

sjmikler commented May 7, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants