0

I made an app recently that I'm proud of. It's an alarm that plays music at a designated time. I use the Windows Command Prompt to play the .mp3 file. I'm using C, so I've been trying to use the system() method. However, I've realized that this won't work on computers that have Windows 11, as they got rid of Windows Media Player being installed with Win11. I also have Win11, but it worked on my computer because I installed it.

Win11's media player is called "Media Player," and I can't find a way to play mp3 files through the command line with it. I've tried "fmedia," "wmplayer," "start," and others but none of them work.

So how can I play an mp3 file on Windows 11 using the Command Prompt without installing extra software?

MSalters
  • 173,980
  • 10
  • 155
  • 350
Margorp13
  • 47
  • 7
  • *So how can I play an mp3 file on Windows 11 using the Command Prompt without installing extra software?* - why are you sure it is even possible? Sure there are command line players out there, but you do need to install them. – Eugene Sh. Jan 30 '23 at 19:35
  • So then how can someone play an mp3 file in C without installing extra software other than C packages? – Margorp13 Jan 30 '23 at 19:38
  • They write an actual MP3 player in C. And yes, among the "C packages" might be a library that helps writing such a player. – Eugene Sh. Jan 30 '23 at 19:40
  • 3
    Why do you want to use the command line? Windows has `PlaySound(filename, NULL, SND_FILENAME)`. – MSalters Jan 30 '23 at 19:41
  • @MSalters Are you sure it works with anything other than `wav`? Upd: To an extent: https://stackoverflow.com/questions/2049825/simplest-way-to-play-mp3-from-visual-c – Eugene Sh. Jan 30 '23 at 19:43
  • 1
    FWIW, you can enable Windows Media Player via the *Windows Features*. That said, you should probably just use the legacy Win32 API ``PlaySound`` instead of relying on a specific app and it would be most portable if you didn't rely on a 3rd party media format like `MP3`. Just use a `WAV` with PCM data. Media Foundation is *not* present on "N" editions of Windows (i.e. Europe) by default. See [this blog post](https://walbourn.github.io/who-moved-my-windows-media-cheese/). – Chuck Walbourn Jan 30 '23 at 19:43
  • Have a look at [mpg123 audio player](http://mpg123.org), which can be called from a console program. Not tried on Windows 11, though there was a 2022 release. – Weather Vane Jan 30 '23 at 19:45
  • 1
    I would advise that you do not ever force your preferred software on any user. If they have chosen a particular software for .mp3 files and/or do not want the abysmal Windows Media Player to run, then you should not override their preference. It's their computer, not yours! – Compo Jan 30 '23 at 20:03
  • You can always write your own mp3 player, it would be a good coding exercise – iggy12345 Jan 30 '23 at 22:16
  • Does this answer your question? [How to play audio file on windows from command line?](https://stackoverflow.com/questions/1569765/how-to-play-audio-file-on-windows-from-command-line) –  Feb 08 '23 at 14:58

0 Answers0