0
import winsound
winsound.PlaySound('C:/Users/Computador/Music/Action!/som1.wav', winsound.SND_ASYNC)
When I run this script the file is not touched som1.wav
, but rather the Windows error sound. Why?
0
import winsound
winsound.PlaySound('C:/Users/Computador/Music/Action!/som1.wav', winsound.SND_ASYNC)
When I run this script the file is not touched som1.wav
, but rather the Windows error sound. Why?
3
The problem was missing the flag SND_NODEFAULT
and the directory was wrong.
import winsound
winsound.PlaySound('teste.wav', winsound.SND_FILENAME | winsound.SND_PURGE | winsound.SND_NODEFAULT)
I tested with mp3 files and it didn’t work, only with wav
is right - that’s what worked - the problem was just the file path and the lack of the SND_NODEFAULT
. If the question is edited to include this, it is no longer a question.
Browser other questions tagged python python-3.x
You are not signed in. Login or sign up in order to post.
That exclamation point "!" composes the URL?
– gato
Great chance to be the wrong file path. Try adding the flag
winsound.SND_NODEFAULT
- This flag determines that if you do not find the file, it is not to put the default sound in place. And make sure that yoursom1.wav
is not the same as Windows...– Bacco
Gave ''Failed to play sound'' with ''winsound.SND_NODEFAULT''
– MATA NEGRO
So we already know that the problem is in your audio. Could you confirm if the exclamation is part of the path of your file?
– Woss
Yes, she is part
– MATA NEGRO
And it is allowed to have this character in the path of a file on Windows?
– Woss
Even without the ''! '
– MATA NEGRO
To remove the doubt, put the sound in the same folder of the application, to see if the problem is in the file or in the path
– Bacco
winsound.SND_FILENAME
: The sound Parameter is the name of a WAV file. You wouldn’t have to use this flag?– Woss
I put in the same folder, I used the flag 'SND_FILENAME', I used another sound with mp3 format, but still plays the sound of windows
– MATA NEGRO
Tried to do all this with a same WAV file?
– Woss
Yeah, I tried with the WAV
– MATA NEGRO
@Tortaamolante tries going by variable the path, as in this example
– Tuxpilgrim
I managed to solve the problem, the script could not find the file and so played the default sound of windows, but I changed the flag and put another file and it worked.
– MATA NEGRO
Edit the answer with the troubleshooting if someone has the same problem ;)
– Tuxpilgrim
All right, I put it :)
– MATA NEGRO