Improved the scripts

This commit is contained in:
Markus Fleschutz 2021-02-20 12:08:05 +01:00
parent 9c606fbdd7
commit 8e384b6d67
2 changed files with 24 additions and 4 deletions

View File

@ -13,6 +13,7 @@ if ($Filename -eq "" ) {
}
try {
write-progress "Reading playlist '$Filename' ..."
$Lines = get-content $Filename
add-type -assemblyName presentationCore
@ -21,8 +22,17 @@ try {
for ([int]$i=0; $i -lt $Lines.Count; $i++) {
$Line = $Lines[$i]
if ($Line[0] -ne "#") {
$MediaPlayer.open("$Line")
write-output "Playing '$Line' ..."
$FullPath = (get-childItem "$Line").fullname
do {
$MediaPlayer.open("$Line")
$Duration = $MediaPlayer.NaturalDuration.TimeSpan.TotalMilliseconds
} until ($Duration)
$MediaPlayer.Volume = 1
$MediaPlayer.play()
start-sleep -milliseconds $Duration
$MediaPlayer.stop()
$MediaPlayer.close()
}
}
exit 0

View File

@ -13,10 +13,20 @@ if ($Filename -eq "" ) {
}
try {
add-type -assemblyName presentationCore
$MediaPlayer = new-object system.windows.media.mediaplayer
$MediaPlayer.open("$Filename")
add-type -assemblyName PresentationCore
$MediaPlayer = new-object System.Windows.Media.MediaPlayer
$FullPath = (get-childItem $Filename).fullname
do {
$MediaPlayer.open($FullPath)
$Duration = $MediaPlayer.NaturalDuration.TimeSpan.TotalMilliseconds
} until ($Duration)
write-progress "Playing $Filename ..."
$MediaPlayer.Volume = 1
$MediaPlayer.play()
start-sleep -milliseconds $Duration
$MediaPlayer.stop()
$MediaPlayer.close()
exit 0
} catch {