Improve output of play-m3u.ps1

This commit is contained in:
Markus Fleschutz 2021-04-21 10:33:38 +02:00
parent 94455bb7c5
commit 59a7e492fe

View File

@ -18,15 +18,17 @@ try {
for ([int]$i=0; $i -lt $Lines.Count; $i++) {
$Line = $Lines[$i]
if ($Line[0] -ne "#") {
"▶️ Playing 🎵$Line ..."
$FullPath = (get-childItem "$Line").fullname
do {
$MediaPlayer.open($FullPath)
$Duration = $MediaPlayer.NaturalDuration.TimeSpan.TotalMilliseconds
} until ($Duration)
$Milliseconds = $MediaPlayer.NaturalDuration.TimeSpan.TotalMilliseconds
} until ($Milliseconds)
[int]$Minutes = $Milliseconds / 60000
[int]$Seconds = ($Milliseconds / 1000) % 60
"Playing 🎵$Line ($($Minutes):$Seconds) ..."
$MediaPlayer.Volume = 1
$MediaPlayer.play()
start-sleep -milliseconds $Duration
start-sleep -milliseconds $Milliseconds
$MediaPlayer.stop()
$MediaPlayer.close()
}