How do I play mp3 with Powershell?
What I tried:
powershell -c (New-Object Media.SoundPlayer "Track.mp3").Play();
You can play an mp3 from powershell, you just need to use
system.windows.media.mediaplayer
instead of
System.Media.SoundPlayer
It works in Windows 10
I followed a snipped from http://eddiejackson.net/wp/?p=9268
# Play a single file
Add-Type -AssemblyName presentationCore
$mediaPlayer = New-Object system.windows.media.mediaplayer
$mediaPlayer.open('C:\sounds\bike.mp3')
$mediaPlayer.Play()
This is an old question but I just went through this so if anyone is interested in learning or knowing how to do this in a more simple manner use the following answer.
As long as you have a media player that has good command line switches such as VLC and other similar types of versatile players (perhaps media player classic) you CAN make a one line command to run a MP3 file. Here is my example, enjoy! :)
& 'C:\Program Files\VideoLAN\VLC\vlc.exe' --qt-start-minimized --play-and-exit --qt-notification=0 "D:\SystemSettings\51Hz.mp3"
This would run 51Hz.mp3 file with neither notifications to take place nor any other user interaction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With