Added play-mp3.ps1

This commit is contained in:
Markus Fleschutz
2021-02-16 20:03:32 +01:00
parent 24b2cd5800
commit ea19ee6769
3 changed files with 25 additions and 0 deletions

23
Scripts/play-mp3.ps1 Executable file
View File

@ -0,0 +1,23 @@
#!/bin/powershell
<#
.SYNTAX ./play-mp3.ps1 [<MP3-file>]
.DESCRIPTION plays the given MP3 sound file
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($Filename = "")
try {
if ($Filename -eq "" ) {
$Filename = read-host "Enter MP3 filename"
}
Add-Type -AssemblyName presentationCore
$mediaPlayer = New-Object system.windows.media.mediaplayer
$mediaPlayer.open("$Filename")
$mediaPlayer.play()
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}