mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-24 10:58:16 +02:00
Added play-m3u.ps1
This commit is contained in:
parent
8ce2414aa4
commit
5bf98fb120
@ -69,7 +69,8 @@ open-calculator.ps1, starts the calculator program
|
|||||||
open-email-client.ps1, starts the default email client
|
open-email-client.ps1, starts the default email client
|
||||||
play-beep.ps1, plays a beep sound
|
play-beep.ps1, plays a beep sound
|
||||||
play-mission-impossible.ps1, plays the Mission Impossible theme
|
play-mission-impossible.ps1, plays the Mission Impossible theme
|
||||||
play-mp3.ps1, plays the given MP3 sound file
|
play-m3u.ps1, plays the given playlist (M3U file format)
|
||||||
|
play-mp3.ps1, plays the given sound file (MP3 file format)
|
||||||
play-super-mario.ps1, plays the Super Mario Intro
|
play-super-mario.ps1, plays the Super Mario Intro
|
||||||
play-the-imperial-march.ps1, plays the Imperial March (Star Wars)
|
play-the-imperial-march.ps1, plays the Imperial March (Star Wars)
|
||||||
poweroff.ps1, halts the local computer (requires admin rights)
|
poweroff.ps1, halts the local computer (requires admin rights)
|
||||||
|
|
@ -74,7 +74,8 @@ Table of Contents
|
|||||||
* [open-email-client.ps1](Scripts/open-browser.ps1) - starts the default email client
|
* [open-email-client.ps1](Scripts/open-browser.ps1) - starts the default email client
|
||||||
* [play-beep.ps1](Scripts/play-beep.ps1) - plays a beep sound
|
* [play-beep.ps1](Scripts/play-beep.ps1) - plays a beep sound
|
||||||
* [play-mission-impossible.ps1](Scripts/play-mission-impossible.ps1) - plays the Mission Impossible theme
|
* [play-mission-impossible.ps1](Scripts/play-mission-impossible.ps1) - plays the Mission Impossible theme
|
||||||
* [play-mp3.ps1](Scripts/play-mp3.ps1) - plays the given MP3 sound file
|
* [play-m3u.ps1](Scripts/play-m3u.ps1) - plays the given playlist (M3U file format)
|
||||||
|
* [play-mp3.ps1](Scripts/play-mp3.ps1) - plays the given sound file (MP3 file format)
|
||||||
* [play-super-mario.ps1](Scripts/play-super-mario.ps1) - plays the Super Mario Intro
|
* [play-super-mario.ps1](Scripts/play-super-mario.ps1) - plays the Super Mario Intro
|
||||||
* [play-the-imperial-march.ps1](Scripts/play-the-imperial-march.ps1) - plays the Imperial March (Star Wars)
|
* [play-the-imperial-march.ps1](Scripts/play-the-imperial-march.ps1) - plays the Imperial March (Star Wars)
|
||||||
* [poweroff.ps1](Scripts/poweroff.ps1) - halts the local computer (requires admin rights)
|
* [poweroff.ps1](Scripts/poweroff.ps1) - halts the local computer (requires admin rights)
|
||||||
|
31
Scripts/play-m3u.ps1
Normal file
31
Scripts/play-m3u.ps1
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/powershell
|
||||||
|
<#
|
||||||
|
.SYNTAX ./play-m3u.ps1 [<playlist-file>]
|
||||||
|
.DESCRIPTION plays the given playlist (M3U file format)
|
||||||
|
.LINK https://github.com/fleschutz/PowerShell
|
||||||
|
.NOTES Author: Markus Fleschutz / License: CC0
|
||||||
|
#>
|
||||||
|
|
||||||
|
param($Filename = "")
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($Filename -eq "" ) {
|
||||||
|
$Filename = read-host "Enter the M3U playlist filename"
|
||||||
|
}
|
||||||
|
$Lines = get-content $Filename
|
||||||
|
|
||||||
|
add-type -assemblyName presentationCore
|
||||||
|
$MediaPlayer = new-object system.windows.media.mediaplayer
|
||||||
|
|
||||||
|
for ([int]$i=0; $i -lt $Lines.Count; $i++) {
|
||||||
|
$Line = $Lines[$i]
|
||||||
|
if ($Line[0] -ne "#") {
|
||||||
|
$MediaPlayer.open("$Line")
|
||||||
|
$MediaPlayer.play()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
} catch {
|
||||||
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
exit 1
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/powershell
|
#!/bin/powershell
|
||||||
<#
|
<#
|
||||||
.SYNTAX ./play-mp3.ps1 [<MP3-file>]
|
.SYNTAX ./play-mp3.ps1 [<MP3-file>]
|
||||||
.DESCRIPTION plays the given MP3 sound file
|
.DESCRIPTION plays the given sound file (MP3 file format)
|
||||||
.LINK https://github.com/fleschutz/PowerShell
|
.LINK https://github.com/fleschutz/PowerShell
|
||||||
.NOTES Author: Markus Fleschutz / License: CC0
|
.NOTES Author: Markus Fleschutz / License: CC0
|
||||||
#>
|
#>
|
||||||
@ -10,12 +10,13 @@ param($Filename = "")
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if ($Filename -eq "" ) {
|
if ($Filename -eq "" ) {
|
||||||
$Filename = read-host "Enter MP3 filename"
|
$Filename = read-host "Enter the MP3 filename"
|
||||||
}
|
}
|
||||||
Add-Type -AssemblyName presentationCore
|
add-type -assemblyName presentationCore
|
||||||
$mediaPlayer = New-Object system.windows.media.mediaplayer
|
$MediaPlayer = new-object system.windows.media.mediaplayer
|
||||||
$mediaPlayer.open("$Filename")
|
$MediaPlayer.open("$Filename")
|
||||||
$mediaPlayer.play()
|
$MediaPlayer.play()
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user