Skip to content

Instantly share code, notes, and snippets.

@randomvariable
Last active August 29, 2015 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randomvariable/7e0ce3330faf9dc1dae8 to your computer and use it in GitHub Desktop.
Save randomvariable/7e0ce3330faf9dc1dae8 to your computer and use it in GitHub Desktop.
New-PivotKlaxon
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