Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.