Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created October 28, 2020 10:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save coderofsalvation/02029fd90b106835fd6981b854cca62e to your computer and use it in GitHub Desktop.
Save coderofsalvation/02029fd90b106835fd6981b854cca62e to your computer and use it in GitHub Desktop.
hasslefree playing mp3 wav audio in Windows 10 WSL
#!/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -noexit
# Play a single file
# Usage:
# LINUX: timeout 5 ./playaudio.ps1 "c:\Users\Leon\Downloads\bensound-allthat.mp3" &>/dev/null &
# CMD.EXE: powershell.exe -noexit ./playaudio.ps1 "c:\Users\Leon\Downloads\bensound-allthat.mp3"
Add-Type -AssemblyName presentationCore
$mediaPlayer = New-Object system.windows.media.mediaplayer
$mediaPlayer.open( $args[0] )
$mediaPlayer.Play()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment