Powershell script on startup stopping .mp3

前端 未结 2 1832
轮回少年
轮回少年 2021-01-29 04:51

I\'m running into an issue when I boot my PC the .mp3 file stops once the system speech is completed. I\'d like it to run a little longer. Syntax below.

\'Add-Ty         


        
2条回答
  •  误落风尘
    2021-01-29 05:21

    Untested, but you probably could insert a wait loop after starting to play the mp3, to see if the music has finished or not. Something like:

    $mediaPlayer = New-Object system.windows.media.mediaplayer
    $mediaPlayer.open('C:\Users\avery\Videos\01 - Highway To Hell.mp3')
    $mediaPlayer.Play()
    while (!($mediaPlayer.MediaEnded)) {
        Start-Sleep -Milliseconds 500
    }
    $mediaPlayer.Close()
    

提交回复
热议问题