Does anyone know how to get the MediaEnded Event of the WindowsMediaPlayer Class to fire? The event is registered, but it's not firing. It's not an issue of the action, as I have tried outputting results using Out-file. I can use the Register-ObjectEvent command to fire events from Start-Job, but for some reason, MediaPlayer does not want to fire events.
cls
Unregister-Event *
Add-Type -AssemblyName PresentationCore
$Player = [System.Windows.Media.MediaPlayer]::new()
$path = "D:\MineSweeper\Sound\Sounds\Bomb.wav"
$file = (Get-Item $path)
$Player.Open($file.FullName)
$player.Play()
$null = Register-ObjectEvent -InputObject $Player -EventName MediaEnded -Action {write-host "$(Get-Date)"}
Get-EventSubscriber