Last active
August 29, 2015 14:06
-
-
Save randomvariable/7e0ce3330faf9dc1dae8 to your computer and use it in GitHub Desktop.
New-PivotKlaxon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function New-PivotKlaxon | |
{ | |
Add-Type -AssemblyName PresentationCore | |
$song = [uri](Join-Path (Split-Path -parent $PSCommandPath) "klaxon.mp3") | |
$MediaPlayer = New-Object System.Windows.Media.MediaPlayer | |
$voice = new-object -com SAPI.SpVoice | |
$MediaPlayer.Open($song) | |
while( $MediaPlayer.NaturalDuration.TimeSpan.TotalMilliseconds -eq $null) | |
{ | |
start-sleep -milliseconds 100 | |
} | |
$songDuration = $MediaPlayer.NaturalDuration.TimeSpan.TotalMilliseconds | |
$MediaPlayer.Volume = 255 | |
$MediaPlayer.Play() | |
$voice.Speak("Sound the Pivot Klaxon") | |
Start-Sleep -Milliseconds $songDuration | |
$MediaPlayer.Stop() | |
$MediaPlayer.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment