notes/PlayerStream MP3 media file-3ZCvfgH3.sh
<#
PowerShell -ExecutionPolicy Bypass <script.ps1> -musicFile <file/url>
#>
param([string]$musicFile = "http://static.echonest.com/audio2/1353978910554/06%20What%20If%20We%20Could%20.mp3")
Add-Type -AssemblyName presentationCore
$mediaPlayer = New-Object system.windows.media.mediaplayer
$mediaPlayer.open($musicFile)
$mediaPlayer.Play()
Start-Sleep -seconds 2 # need to wait for mediaPlayer to determine file duration
Start-Sleep -seconds $mediaPlayer.NaturalDuration.TimeSpan.TotalSeconds
$mediaPlayer.Stop()
syntax highlighted by Code2HTML, v. 0.9.1