Skip to content

Instantly share code, notes, and snippets.

@niittymaa
Forked from coderofsalvation/playaudio.ps1
Created March 16, 2023 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niittymaa/b7dbcce743d46d4c96ac78b396440c29 to your computer and use it in GitHub Desktop.
Save niittymaa/b7dbcce743d46d4c96ac78b396440c29 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