Thursday, October 11, 2007

Play PLS stream files in Windows Media Player (no need to install Winamp)

Winamp is a really very nice clean software. No Arguments there. But, I don't want to install it on my business laptop. I want to here all shoutcast streams and other radio stations in my Windows Media Player. So I made a little script myself (and I blogged it HERE).

Follow the steps to play PLS file in Windows Media Player:

1. Copy and Paste the following script into Notepad and save it as "PlayPLS.VBS". NOTE: While saving the script from Notepad, You NEED to type the vbscriptname.vbs in QUTOES. e.g., "PlayPLS.vbs". Otherwise it will save as PlayPLS.vbs.txt

'*****************************************************************************
'*****************************************************************************
'*********                       PlayPLS.vbs                        **********
'********* Parameters: PLS file name                                **********
'*********                                                          **********
'********* This script plays .PLS files in Windows Media Player     **********
'*********                                                          **********
'********* Usage: PlayPLS.vbs Sample.PLS                            **********
'*********                                                          **********
'********* Written By: Anand Venkatachalapathy                      **********
'*****************************************************************************
'*****************************************************************************

Set WshShell = WScript.CreateObject("WScript.Shell")
Set oArg = WScript.Arguments
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")

If oArg.Count = 0 Then
    WshShell.Popup "Invalid Arguments...Please provide the PLS file name.", _
7, "Play PLS in WMP",0
    WScript.Quit
End If

sPLSFileName = oArg(0)
Set f = fso.OpenTextFile(sPLSFileName, ForReading)

Do While NOT f.AtEndOfStream
    sText =  f.ReadLine
    If InStr(UCase(sText),"FILE") > 0 Then
        sURLText =  Split(sText,"=")
        sURL = """" & sURLText(1) & """"
        sCmd = "WMPlayer " & sURL
        WshShell.Run sCmd
        Exit Do
    End If
Loop

f.close
Set fso = Nothing
Set oArg = Nothing
Set WshShell = Nothing

2. Copy and Paste the following text into Notepad and save it as PlayPLS.cmd. NOTE: Use the "double quotes" when saving the name in Notepad.

C:\PathOfTheFolder\PlayPLS.vbs %1

3. Open your favorite radio station (mine is http://www.shoutcast.com), right click on PLS file link (or PLAY button) and save it on your desktop.

4. Open the file properties of PLS file (by right clicking on the PLS on the desktop and select properties), Click "Change" button next to the "Opens With:" text. Select the PlayPLS.cmd file by browsing to the corresponding folder and select the cmd file.

5. You are done. Go to your favorite radio web site again and click on "Play" Link. See it open in Windows Media Player.

14 comments:

Unknown said...

Hat mich gefreut und funktioniert super.
Danke

AnixasObscura said...

Wow! thanks so much - I'm trying not to bog down my Vista with software - I too favor shoutcast - copied your scripts tonight and they worked great!!

SUP said...

can you still get track lists up from the .pls if you play it in windows media player?

Unknown said...

Hi; I Doesn't Play On My Wm ... I Did What You Posted .. Anything i Did Wrong ?

Unknown said...

Try make PlayPls.bat instead of PlatPls.cmd in step 4.

Anand

Unknown said...

To Lesbian Seduction: I don't think that's possible. It's WMP that don't want to grab the song and broadcaster details.

Unknown said...

To Michael: Thanks.

Anonymous said...

using the .bat extension worked for me. Thanks!

Anonymous said...

Good Morning... I copied your script into notepad and tried the following with the double quotes -"PlayPls.cmd" "PlayPls.bat", "PlayPls.vbs" and saved (deleted)to the desktop each time and none worked... I am so new to this and I am running Vista Home Premium... I doing something wrong...http://candyrandyradio.com/ <<< that is the site I am trying to listen to...

DSP said...

Thank you very much sir, I was looking for a way to listen to my Internet radio at the office but since I can't install anything on the system... You kind of save my life :).

For the others, these two little scripts are working fine if you replace the ".cmd" for a ".bat" like ArmandPV said.

Well, thanks to both of you!

Spotted Elephant said...

Thanks for this. Like you say, winamp is nice and all... but on this latest install, I just didnt feel like managing all the additional software. If we ever meet, I will buy you a beer.

Unknown said...

Thanks TomW. I feel great.

Anonymous said...

It works perfectly! (Windows XP)
Thank you!!

Anonymous said...

Awesome! I switched the cmd for a bat as recommended, and it worked on the first try. I'm running the latest version of WMP on a Win7 x64 machine. Now I can access my Shoutcast stations without having a browser window open all the time. Thanks, Anand!