mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-22 09:58:19 +02:00
Added play-mp3.ps1
This commit is contained in:
parent
24b2cd5800
commit
ea19ee6769
@ -68,6 +68,7 @@ open-calculator.ps1, starts the calculator program
|
|||||||
open-email-client.ps1, starts the default email client
|
open-email-client.ps1, starts the default email client
|
||||||
play-beep.ps1, plays a beep sound
|
play-beep.ps1, plays a beep sound
|
||||||
play-mission-impossible.ps1, plays the Mission Impossible theme
|
play-mission-impossible.ps1, plays the Mission Impossible theme
|
||||||
|
play-mp3.ps1, plays the given MP3 sound file
|
||||||
play-super-mario.ps1, plays the Super Mario Intro
|
play-super-mario.ps1, plays the Super Mario Intro
|
||||||
play-the-imperial-march.ps1, plays the Imperial March (Star Wars)
|
play-the-imperial-march.ps1, plays the Imperial March (Star Wars)
|
||||||
poweroff.ps1, halts the local computer (requires admin rights)
|
poweroff.ps1, halts the local computer (requires admin rights)
|
||||||
|
|
@ -73,6 +73,7 @@ Table of Contents
|
|||||||
* [open-email-client.ps1](Scripts/open-browser.ps1) - starts the default email client
|
* [open-email-client.ps1](Scripts/open-browser.ps1) - starts the default email client
|
||||||
* [play-beep.ps1](Scripts/play-beep.ps1) - plays a beep sound
|
* [play-beep.ps1](Scripts/play-beep.ps1) - plays a beep sound
|
||||||
* [play-mission-impossible.ps1](Scripts/play-mission-impossible.ps1) - plays the Mission Impossible theme
|
* [play-mission-impossible.ps1](Scripts/play-mission-impossible.ps1) - plays the Mission Impossible theme
|
||||||
|
* [play-mp3.ps1](Scripts/play-mp3.ps1) - plays the given MP3 sound file
|
||||||
* [play-super-mario.ps1](Scripts/play-super-mario.ps1) - plays the Super Mario Intro
|
* [play-super-mario.ps1](Scripts/play-super-mario.ps1) - plays the Super Mario Intro
|
||||||
* [play-the-imperial-march.ps1](Scripts/play-the-imperial-march.ps1) - plays the Imperial March (Star Wars)
|
* [play-the-imperial-march.ps1](Scripts/play-the-imperial-march.ps1) - plays the Imperial March (Star Wars)
|
||||||
* [poweroff.ps1](Scripts/poweroff.ps1) - halts the local computer (requires admin rights)
|
* [poweroff.ps1](Scripts/poweroff.ps1) - halts the local computer (requires admin rights)
|
||||||
|
23
Scripts/play-mp3.ps1
Executable file
23
Scripts/play-mp3.ps1
Executable 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user