Link Your Stream [Technical]

This forum will contain various articles contributed by the team and other invited guest.
Post Reply
User avatar
Jay
Will work for food (Administrator)
Posts: 3020
Joined: Mon Jan 14, 2002 12:48 am
Location: Next Door
Contact:

Link Your Stream [Technical]

Post by Jay »

Why the heck would I need to link my stream?
Simple, so people can easily get to it. The idea of directly linking an audio stream to a webpage was started back before I was on the net :). But it really took off when real networks used it to get people to their client's streams easily and without knowing all those crazy numbers I keep referring to called IP numbers. As you know most who use SHOUTcast host it on their own system, so they do not have a fancy domain name to link to, it usually ends up being http://123.45.67.89:8000, which is very cumbersome to the average internet user who has trouble remembering a telephone number. Believe it or not it takes a couple of passes to remember those large numbers, and when you are a fan of several streams remembering all that is just not rational and can drive your listeners up the wall. Most users are very aware of clicking through, and they can easily do that from your web page because they have already stumbled across it or have memorized it's nice address.

So give me the skinny, how does it work?
Quite simple, the user visits your webpage, they find a link that says "Click here for my polka fav's" so in the spirit of the internet they click there, what immediately happens next is that they are served a Playlist file with the *.PLS extension, more commonly. What this file does it it tells the system that it is going to download a file called whatever.pls, when the user installed Winamp, Real Player or whatever, the player told the system that it was in charge of handling those files, so the browser will use that file type association to open the Playlist file in that player, after that the player reads through that file for a Location tag, when it finds that it automatically loads that into the player and begins playing the stream. So in essence you are actually going to link to a playlist file containing the URL to your station's server. Do not link directly to the stream, this will provide a most undesirable effect, and will not allow them to truly listen to your stream.

OK great, how can I do it?
Well the simplest method is using your SHOUTcast servers built in Web server, this feature has a listen link already built in with all the correct information. So all you have to do is link to it from an outside source. How do you do that, quite simple, just use this HTML code:

Code: Select all

<a href="http://myserverip:port/listen.pls">Click Here to Listen</a>
that is the easy way, and it will get you the results you are looking for, another method is to actually host the PLS file on your website, this makes the link look all fancy and allows you to hide the IP address from the user, fairly effectively. To do this method you must place a file on your server, call it whatever you like, but make sure it has a PLS extension after it. Edit the file so that it says:

Code: Select all

[playlist]
Numberofentries=1
File1=http://myserverip:port/
Title1=My Title
Length1=-1
Version=2
So now your probably asking yourself, "What does all that stuff mean?", well I am going to tell you :)

[playlist] <-- Serves as a Category for the rest of the entries, this *is* case sensitive

Numberofentries=1 <-- this tells the player how many files it will expect to find referenced by the file. This is case sensitive

File1=http://myserverip:port/ <-- This tells the player that the first item located in the playlist is located at http://myserverip:port

Title1=My Title <-- this tells the server what to display as the file's name in the Winamp Playlist (not all players support this feature.

Length=-1 <-- this tells the player how long the file is in seconds, in our case it is a stream, so the stream is indefinate, so -1 will make the player display nothing.

Version=2 <-- this tells the player what version format the PLS file is in, older PLS formats did not include the title tag.

As you might expect you can fit more entries into the file by writing the file like so:

Code: Select all

[playlist]
Numberofentries=2
File1=http://myserverip:port/
Title1=My Title
Length1=-1
File2=http://my2ndserverip:port/
Title2=My 2nd Title
Length2=-1
Version=2
In this example there was a use of two Playlist slots, allowing you to put more than one server in or even a static file, you could put extra files into someone's playlist to listen to like say a promo or intro file. This is also great for back up's. Say for example your first server fails and they do not connect, well most players will move on the the next item in the list, so the user would in essence be redirected to a mirror server this way. Got the idea?

Golly gee thanks, so if I can use the PLS file, why can't I use the standard Playlist file M3U?
You can, in fact it is perfectly fine to use either file, it's just that the shoutcast website has made extensive use of this file format, but as Icecast users know, it is not the standard, M3U's come in real handy when you have large playlist, PLS seem to lack any real ability beyond this simple task. M3U files also support title tags in the Winamp Player, so in essence you will get more bang out of using M3U files . But PLS files have been used extensively, and I promote their use for the simplicity and the fact that you have probably seen them more often in this streaming medium.

I tried hosting PLS files with my web host and it didn't work, the files just got displayed as text files, why did this happen?
Simply because your web servers MIME types were not setup properly to handle PLS files, in this case you must add them to your MIME types file. The proper entry is:

Code: Select all

audio/x-scpls           pls
or if
you are using M3U files

Code: Select all

audio/x-mpegurl       m3u
If your web host does not allow you to access your mime types, you can request that it be added or, if your web host supports it, you can use the .htaccess file to add the mime type to the server. If you see an .htaccess file already in your base www directory, add this line to the bottom of the file: (WARNING: If you are uncomfortable with configuring a server or do not fully understand what you are doing, you can cause your website to cease functioning by deleting parts of the .htaccess file unknowingly)

Code: Select all

AddType  audio/x-scpls  pls
This method will effectively tell the server how to handle the file correctly from the directory of the .htaccess file and all subdirectories of it.

Well my IP address changes everytime I logon to the Internet, what can I do?
Well you could get into a service like no-ip.com, they give you a static name on the internet so people can find your station with ease, you could also use YP Lister in association with our Website and grab the link generated by your account, this provides a quick easy way to find your stream and also when used with the On-Air Light functions we provide, you can display your station status.

Feel free to leave a comment if you feel that I have missed something. Do not reply with questions. Questions should go in the Audio Streaming forum. Questions will be split from this thread and moved to appropriate forums.
Last edited by Jay on Wed Jun 09, 2004 1:25 pm, edited 2 times in total.
Mintymoke
Posts: 1
Joined: Mon Feb 17, 2003 7:03 am
Contact:

Post by Mintymoke »

Not sure if this is quite what you after but you can embed most players in to a web page. If your just interested in audio then..

The code below is for Windows Media Player 6.4 - (code ref... classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">) only the transport/control bar is displayed, so you could design a radio interface using html and paste the code below into a table sorrounded by ur design or whatever - to test-paste the code below in to the <body> of ur page - i'm pretty sure that you can point to a .pls file as well as the .m3u in this example. And if you go to w3c website http://www.w3.org/ and go to the media section -i'm pretty sure you can get the classid info for other players.

Code: Select all

<object
classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
<param name="FileName" value="whereveryoursourceisat/slyfm.m3u" />
</object>
Hope this helps.
Mintymoke
phantombluefan
Posts: 1
Joined: Sun May 18, 2003 8:14 am
Location: southern california
Contact:

direct audio stream linking

Post by phantombluefan »

I am glad there is direct audio stream linking because on my puter when I try to click on a station even if I choose winamp to play it, real player will jump right in and grab the feed. this even happens if it is a media that can only be played on winamp such as videos and then as a result you dont get to see the videos. so with this direct audio stream linking you can outsmart real player. I learned the easiest thing to do is highlight and copy the stream number configuration then click the add button, choose location, paste the addy in, hit open, and if that dont get it playing click on the stream in the playlist, then push play. once its playing, bookmark it and there it is. aint that hard is it? stay cool peace
Dave pbf
banksy_w
Posts: 8
Joined: Fri May 30, 2003 5:39 pm

Post by banksy_w »

Cheers,
this article has solved all my problems and even inspired me to create a little intro jingle for my stream
nice
User avatar
Sc-Pro
Stream Host
Posts: 16
Joined: Tue Nov 08, 2005 3:55 pm
Location: va
Contact:

Post by Sc-Pro »

I have a player link to my stream its on my site if u need the code let me kno ill get u it .. Itz kinda nice to have ppl who visit can hear whats going with out opening any more processes..
Post Reply