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










-1















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)









share|improve this question
























  • 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











  • 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















-1















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)









share|improve this question
























  • 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











  • 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













-1












-1








-1








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)









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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











  • 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












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












2 Answers
2






active

oldest

votes


















0














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.






share|improve this answer























  • 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







  • 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


















0














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






share|improve this answer























  • Yep, that's in one of the 14 answers in the linked question.

    – martineau
    Mar 8 at 21:10











Your Answer






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
);



);













draft saved

draft discarded


















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









0














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.






share|improve this answer























  • 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







  • 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















0














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.






share|improve this answer























  • 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







  • 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













0












0








0







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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





    @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











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





    @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













0














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






share|improve this answer























  • Yep, that's in one of the 14 answers in the linked question.

    – martineau
    Mar 8 at 21:10















0














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






share|improve this answer























  • Yep, that's in one of the 14 answers in the linked question.

    – martineau
    Mar 8 at 21:10













0












0








0







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






share|improve this answer













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







share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme