Can't play .mp3 file using winsound on windows The Next CEO of Stack OverflowPlaying mp3 song on pythonHow can I develop for iPhone using a Windows development machine?How can you find out which process is listening on a port on Windows?How do I check whether a file exists without exceptions?How do I copy a file in Python?Is there an equivalent of 'which' on the Windows command line?How do I list all files of a directory?How to read a file line-by-line into a list?How do I install pip on Windows?Delete a file or folderThreading, tkinter and winsound
How seriously should I take size and weight limits of hand luggage?
Incomplete cube
Avoiding the "not like other girls" trope?
Is it OK to decorate a log book cover?
Salesforce opportunity stages
How to find if SQL server backup is encrypted with TDE without restoring the backup
How to implement Comparable so it is consistent with identity-equality
Why did early computer designers eschew integers?
Finitely generated matrix groups whose eigenvalues are all algebraic
Why does freezing point matter when picking cooler ice packs?
Which acid/base does a strong base/acid react when added to a buffer solution?
pgfplots: How to draw a tangent graph below two others?
Airship steam engine room - problems and conflict
How can I separate the number from the unit in argument?
Could a dragon use its wings to swim?
Another proof that dividing by 0 does not exist -- is it right?
Raspberry pi 3 B with Ubuntu 18.04 server arm64: what pi version
What steps are necessary to read a Modern SSD in Medieval Europe?
Could you use a laser beam as a modulated carrier wave for radio signal?
How dangerous is XSS
Can Sri Krishna be called 'a person'?
How should I connect my cat5 cable to connectors having an orange-green line?
What did the word "leisure" mean in late 18th Century usage?
My boss doesn't want me to have a side project
Can't play .mp3 file using winsound on windows
The Next CEO of Stack OverflowPlaying mp3 song on pythonHow can I develop for iPhone using a Windows development machine?How can you find out which process is listening on a port on Windows?How do I check whether a file exists without exceptions?How do I copy a file in Python?Is there an equivalent of 'which' on the Windows command line?How do I list all files of a directory?How to read a file line-by-line into a list?How do I install pip on Windows?Delete a file or folderThreading, tkinter and winsound
I am trying to play an audio file but it only makes the windows alert sound when I open/run the code. How do I fix this?
EDIT: nothing on winsound works it just makes the windows alert noise (windows background.wav) right click on the sound button (bottom right), click sounds, click on the first one and press test. that's the noise.
code:
import winsound
winsound.PlaySound('music.mp3', winsound.SND_ASYNC)
python windows winsound
|
show 1 more comment
I am trying to play an audio file but it only makes the windows alert sound when I open/run the code. How do I fix this?
EDIT: nothing on winsound works it just makes the windows alert noise (windows background.wav) right click on the sound button (bottom right), click sounds, click on the first one and press test. that's the noise.
code:
import winsound
winsound.PlaySound('music.mp3', winsound.SND_ASYNC)
python windows winsound
To keep it playing, you must prevent the script from ending and use the both thewinsound.SND_ASYNC
andwinsound.SND_LOOP
flags (by combining them with|
). You can prevent the script from ending immediately by adding a call toinput()
at the end.
– martineau
Mar 8 at 19:35
@martineau it is in a game so the code doesn't end
– Glitchd
Mar 8 at 20:19
Please edit your question and add a Minimal, Complete, and Verifiable example that reproduces the problem. What is "windows background.wiv"?
– martineau
Mar 8 at 20:30
.wiv is an audio file so it's pretty obvious
– Glitchd
Mar 8 at 20:45
When debugging (especially without the real source code), even "obvious" things must be questioned and assumptions avoided, my friend.
– martineau
Mar 8 at 20:48
|
show 1 more comment
I am trying to play an audio file but it only makes the windows alert sound when I open/run the code. How do I fix this?
EDIT: nothing on winsound works it just makes the windows alert noise (windows background.wav) right click on the sound button (bottom right), click sounds, click on the first one and press test. that's the noise.
code:
import winsound
winsound.PlaySound('music.mp3', winsound.SND_ASYNC)
python windows winsound
I am trying to play an audio file but it only makes the windows alert sound when I open/run the code. How do I fix this?
EDIT: nothing on winsound works it just makes the windows alert noise (windows background.wav) right click on the sound button (bottom right), click sounds, click on the first one and press test. that's the noise.
code:
import winsound
winsound.PlaySound('music.mp3', winsound.SND_ASYNC)
python windows winsound
python windows winsound
edited Mar 8 at 21:08
martineau
70k1092186
70k1092186
asked Mar 8 at 19:09
GlitchdGlitchd
1128
1128
To keep it playing, you must prevent the script from ending and use the both thewinsound.SND_ASYNC
andwinsound.SND_LOOP
flags (by combining them with|
). You can prevent the script from ending immediately by adding a call toinput()
at the end.
– martineau
Mar 8 at 19:35
@martineau it is in a game so the code doesn't end
– Glitchd
Mar 8 at 20:19
Please edit your question and add a Minimal, Complete, and Verifiable example that reproduces the problem. What is "windows background.wiv"?
– martineau
Mar 8 at 20:30
.wiv is an audio file so it's pretty obvious
– Glitchd
Mar 8 at 20:45
When debugging (especially without the real source code), even "obvious" things must be questioned and assumptions avoided, my friend.
– martineau
Mar 8 at 20:48
|
show 1 more comment
To keep it playing, you must prevent the script from ending and use the both thewinsound.SND_ASYNC
andwinsound.SND_LOOP
flags (by combining them with|
). You can prevent the script from ending immediately by adding a call toinput()
at the end.
– martineau
Mar 8 at 19:35
@martineau it is in a game so the code doesn't end
– Glitchd
Mar 8 at 20:19
Please edit your question and add a Minimal, Complete, and Verifiable example that reproduces the problem. What is "windows background.wiv"?
– martineau
Mar 8 at 20:30
.wiv is an audio file so it's pretty obvious
– Glitchd
Mar 8 at 20:45
When debugging (especially without the real source code), even "obvious" things must be questioned and assumptions avoided, my friend.
– martineau
Mar 8 at 20:48
To keep it playing, you must prevent the script from ending and use the both the
winsound.SND_ASYNC
and winsound.SND_LOOP
flags (by combining them with |
). You can prevent the script from ending immediately by adding a call to input()
at the end.– martineau
Mar 8 at 19:35
To keep it playing, you must prevent the script from ending and use the both the
winsound.SND_ASYNC
and winsound.SND_LOOP
flags (by combining them with |
). You can prevent the script from ending immediately by adding a call to input()
at the end.– martineau
Mar 8 at 19:35
@martineau it is in a game so the code doesn't end
– Glitchd
Mar 8 at 20:19
@martineau it is in a game so the code doesn't end
– Glitchd
Mar 8 at 20:19
Please edit your question and add a Minimal, Complete, and Verifiable example that reproduces the problem. What is "windows background.wiv"?
– martineau
Mar 8 at 20:30
Please edit your question and add a Minimal, Complete, and Verifiable example that reproduces the problem. What is "windows background.wiv"?
– martineau
Mar 8 at 20:30
.wiv is an audio file so it's pretty obvious
– Glitchd
Mar 8 at 20:45
.wiv is an audio file so it's pretty obvious
– Glitchd
Mar 8 at 20:45
When debugging (especially without the real source code), even "obvious" things must be questioned and assumptions avoided, my friend.
– martineau
Mar 8 at 20:48
When debugging (especially without the real source code), even "obvious" things must be questioned and assumptions avoided, my friend.
– martineau
Mar 8 at 20:48
|
show 1 more comment
2 Answers
2
active
oldest
votes
The winsound.PlaySound()
function is just a thin wrapper around the PlaySound() Win32 API, which only plays waveform audios (WAV) and cannot recognize MP3 files.
If you're not willing to convert the file to WAV manually, you may use the MCI components.
The third-party playsound library provides a concise example for its usage, you can either install it or learn from its source code.
i have it as .wav and i still get the du daa noise
– Glitchd
Mar 8 at 20:18
@Glitchd: When I use something invalid as the first argument towinsound.PlaySound()
, like'c:/windows/media/not_there.wav'
, a beep sound is made (indicating an error I assume). The script keeps running though, and no exception is raised.
– martineau
Mar 8 at 20:46
1
@martineau This is intended behavior; see SND_FILENAME in my first link above.
– Arnie97
Mar 8 at 20:49
@Arnie97 how do i fix it?
– Glitchd
Mar 8 at 20:53
1
@Glitchd This makes no sense and won't turn your file into waveform audio. Search for "convert mp3 to wav" and use any one you like.
– Arnie97
Mar 8 at 21:05
|
show 3 more comments
by using pygame I found:
from pygame import mixer # Load the required library
mixer.init()
mixer.music.load('music.mp3')
mixer.music.play()
which works fine
Yep, that's in one of the 14 answers in the linked question.
– martineau
Mar 8 at 21:10
add a comment |
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55069520%2fcant-play-mp3-file-using-winsound-on-windows%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The winsound.PlaySound()
function is just a thin wrapper around the PlaySound() Win32 API, which only plays waveform audios (WAV) and cannot recognize MP3 files.
If you're not willing to convert the file to WAV manually, you may use the MCI components.
The third-party playsound library provides a concise example for its usage, you can either install it or learn from its source code.
i have it as .wav and i still get the du daa noise
– Glitchd
Mar 8 at 20:18
@Glitchd: When I use something invalid as the first argument towinsound.PlaySound()
, like'c:/windows/media/not_there.wav'
, a beep sound is made (indicating an error I assume). The script keeps running though, and no exception is raised.
– martineau
Mar 8 at 20:46
1
@martineau This is intended behavior; see SND_FILENAME in my first link above.
– Arnie97
Mar 8 at 20:49
@Arnie97 how do i fix it?
– Glitchd
Mar 8 at 20:53
1
@Glitchd This makes no sense and won't turn your file into waveform audio. Search for "convert mp3 to wav" and use any one you like.
– Arnie97
Mar 8 at 21:05
|
show 3 more comments
The winsound.PlaySound()
function is just a thin wrapper around the PlaySound() Win32 API, which only plays waveform audios (WAV) and cannot recognize MP3 files.
If you're not willing to convert the file to WAV manually, you may use the MCI components.
The third-party playsound library provides a concise example for its usage, you can either install it or learn from its source code.
i have it as .wav and i still get the du daa noise
– Glitchd
Mar 8 at 20:18
@Glitchd: When I use something invalid as the first argument towinsound.PlaySound()
, like'c:/windows/media/not_there.wav'
, a beep sound is made (indicating an error I assume). The script keeps running though, and no exception is raised.
– martineau
Mar 8 at 20:46
1
@martineau This is intended behavior; see SND_FILENAME in my first link above.
– Arnie97
Mar 8 at 20:49
@Arnie97 how do i fix it?
– Glitchd
Mar 8 at 20:53
1
@Glitchd This makes no sense and won't turn your file into waveform audio. Search for "convert mp3 to wav" and use any one you like.
– Arnie97
Mar 8 at 21:05
|
show 3 more comments
The winsound.PlaySound()
function is just a thin wrapper around the PlaySound() Win32 API, which only plays waveform audios (WAV) and cannot recognize MP3 files.
If you're not willing to convert the file to WAV manually, you may use the MCI components.
The third-party playsound library provides a concise example for its usage, you can either install it or learn from its source code.
The winsound.PlaySound()
function is just a thin wrapper around the PlaySound() Win32 API, which only plays waveform audios (WAV) and cannot recognize MP3 files.
If you're not willing to convert the file to WAV manually, you may use the MCI components.
The third-party playsound library provides a concise example for its usage, you can either install it or learn from its source code.
answered Mar 8 at 19:58
Arnie97Arnie97
43929
43929
i have it as .wav and i still get the du daa noise
– Glitchd
Mar 8 at 20:18
@Glitchd: When I use something invalid as the first argument towinsound.PlaySound()
, like'c:/windows/media/not_there.wav'
, a beep sound is made (indicating an error I assume). The script keeps running though, and no exception is raised.
– martineau
Mar 8 at 20:46
1
@martineau This is intended behavior; see SND_FILENAME in my first link above.
– Arnie97
Mar 8 at 20:49
@Arnie97 how do i fix it?
– Glitchd
Mar 8 at 20:53
1
@Glitchd This makes no sense and won't turn your file into waveform audio. Search for "convert mp3 to wav" and use any one you like.
– Arnie97
Mar 8 at 21:05
|
show 3 more comments
i have it as .wav and i still get the du daa noise
– Glitchd
Mar 8 at 20:18
@Glitchd: When I use something invalid as the first argument towinsound.PlaySound()
, like'c:/windows/media/not_there.wav'
, a beep sound is made (indicating an error I assume). The script keeps running though, and no exception is raised.
– martineau
Mar 8 at 20:46
1
@martineau This is intended behavior; see SND_FILENAME in my first link above.
– Arnie97
Mar 8 at 20:49
@Arnie97 how do i fix it?
– Glitchd
Mar 8 at 20:53
1
@Glitchd This makes no sense and won't turn your file into waveform audio. Search for "convert mp3 to wav" and use any one you like.
– Arnie97
Mar 8 at 21:05
i have it as .wav and i still get the du daa noise
– Glitchd
Mar 8 at 20:18
i have it as .wav and i still get the du daa noise
– Glitchd
Mar 8 at 20:18
@Glitchd: When I use something invalid as the first argument to
winsound.PlaySound()
, like 'c:/windows/media/not_there.wav'
, a beep sound is made (indicating an error I assume). The script keeps running though, and no exception is raised.– martineau
Mar 8 at 20:46
@Glitchd: When I use something invalid as the first argument to
winsound.PlaySound()
, like 'c:/windows/media/not_there.wav'
, a beep sound is made (indicating an error I assume). The script keeps running though, and no exception is raised.– martineau
Mar 8 at 20:46
1
1
@martineau This is intended behavior; see SND_FILENAME in my first link above.
– Arnie97
Mar 8 at 20:49
@martineau This is intended behavior; see SND_FILENAME in my first link above.
– Arnie97
Mar 8 at 20:49
@Arnie97 how do i fix it?
– Glitchd
Mar 8 at 20:53
@Arnie97 how do i fix it?
– Glitchd
Mar 8 at 20:53
1
1
@Glitchd This makes no sense and won't turn your file into waveform audio. Search for "convert mp3 to wav" and use any one you like.
– Arnie97
Mar 8 at 21:05
@Glitchd This makes no sense and won't turn your file into waveform audio. Search for "convert mp3 to wav" and use any one you like.
– Arnie97
Mar 8 at 21:05
|
show 3 more comments
by using pygame I found:
from pygame import mixer # Load the required library
mixer.init()
mixer.music.load('music.mp3')
mixer.music.play()
which works fine
Yep, that's in one of the 14 answers in the linked question.
– martineau
Mar 8 at 21:10
add a comment |
by using pygame I found:
from pygame import mixer # Load the required library
mixer.init()
mixer.music.load('music.mp3')
mixer.music.play()
which works fine
Yep, that's in one of the 14 answers in the linked question.
– martineau
Mar 8 at 21:10
add a comment |
by using pygame I found:
from pygame import mixer # Load the required library
mixer.init()
mixer.music.load('music.mp3')
mixer.music.play()
which works fine
by using pygame I found:
from pygame import mixer # Load the required library
mixer.init()
mixer.music.load('music.mp3')
mixer.music.play()
which works fine
answered Mar 8 at 21:09
GlitchdGlitchd
1128
1128
Yep, that's in one of the 14 answers in the linked question.
– martineau
Mar 8 at 21:10
add a comment |
Yep, that's in one of the 14 answers in the linked question.
– martineau
Mar 8 at 21:10
Yep, that's in one of the 14 answers in the linked question.
– martineau
Mar 8 at 21:10
Yep, that's in one of the 14 answers in the linked question.
– martineau
Mar 8 at 21:10
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55069520%2fcant-play-mp3-file-using-winsound-on-windows%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
To keep it playing, you must prevent the script from ending and use the both the
winsound.SND_ASYNC
andwinsound.SND_LOOP
flags (by combining them with|
). You can prevent the script from ending immediately by adding a call toinput()
at the end.– martineau
Mar 8 at 19:35
@martineau it is in a game so the code doesn't end
– Glitchd
Mar 8 at 20:19
Please edit your question and add a Minimal, Complete, and Verifiable example that reproduces the problem. What is "windows background.wiv"?
– martineau
Mar 8 at 20:30
.wiv is an audio file so it's pretty obvious
– Glitchd
Mar 8 at 20:45
When debugging (especially without the real source code), even "obvious" things must be questioned and assumptions avoided, my friend.
– martineau
Mar 8 at 20:48