mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 16:03:22 +01:00
Improve play-files.ps1 and play-mp3.ps1
This commit is contained in:
parent
d5d33dc2b1
commit
96596a7581
@ -1,14 +1,16 @@
|
||||
<#
|
||||
.SYNTAX play-files.ps1 [<file(s)>]
|
||||
.SYNTAX play-files.ps1 [<pattern>]
|
||||
.DESCRIPTION plays the given audio files (supporting MP3 and WAV format)
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
param($Files = "*")
|
||||
param($Pattern = "*")
|
||||
|
||||
try {
|
||||
foreach ($File in (get-childItem -path "$Files" -attributes !Directory)) {
|
||||
$Files = (get-childItem -path "$Pattern" -attributes !Directory)
|
||||
"Playing $($Files.Count) files ..."
|
||||
foreach ($File in $Files) {
|
||||
if ("$File" -like "*.mp3") {
|
||||
& "$PSScriptRoot/play-mp3.ps1" "$File"
|
||||
} elseif ("$File" -like "*.wav") {
|
||||
|
@ -23,9 +23,9 @@ try {
|
||||
|
||||
[int]$Minutes = $Milliseconds / 60000
|
||||
[int]$Seconds = ($Milliseconds / 1000) % 60
|
||||
"▶️Playing for $($Minutes.ToString('00')):$($Seconds.ToString('00')) sec.: 🎵$Filename ..."
|
||||
"▶️ Playing 🎵$Filename ($($Minutes.ToString('00')):$($Seconds.ToString('00')) sec.) ..."
|
||||
$PreviousTitle = $host.ui.RawUI.WindowTitle
|
||||
$host.ui.RawUI.WindowTitle = "▶️$Filename"
|
||||
$host.ui.RawUI.WindowTitle = "▶️ $Filename"
|
||||
$MediaPlayer.Volume = 1
|
||||
$MediaPlayer.play()
|
||||
start-sleep -milliseconds $Milliseconds
|
||||
|
Loading…
Reference in New Issue
Block a user