Advertisement
metalx1000

Player/Stream MP3 media file

Jun 25th, 2014
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. PowerShell -ExecutionPolicy Bypass <script.ps1> -musicFile <file/url>
  3. #>
  4. param([string]$musicFile = "http://static.echonest.com/audio2/1353978910554/06%20What%20If%20We%20Could%20.mp3")
  5. Add-Type -AssemblyName presentationCore
  6. $mediaPlayer = New-Object system.windows.media.mediaplayer
  7.  
  8.  
  9.  
  10. $mediaPlayer.open($musicFile)
  11. $mediaPlayer.Play()
  12. Start-Sleep -seconds 2 # need to wait for mediaPlayer to determine file duration
  13. Start-Sleep -seconds $mediaPlayer.NaturalDuration.TimeSpan.TotalSeconds
  14. $mediaPlayer.Stop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement