Listening to MP3 Streams

MP3 files don’t have to be downloaded to your hard drive, necessarily. In many cases, you’ll be able to play them back in your favorite MP3 player directly from the server on which they’re located. As you’ll discover in Chapter 8, there are several ways in which MP3 webmasters can dish up files for “streaming.” As an end user, you won’t need to worry much about the particular streaming technique in use, though it’s interesting to know the difference. In some cases, you may have to tweak a few settings in your browser or player to make sure streamed files are handled by your operating system properly.

Types of Streaming

There are two primary ways in which MP3 files can be streamed to users without being downloaded: MP3-on-demand and MP3 broadcast.

MP3-on-demand

In this form of streaming, control of the download is in the hands of the MP3 player, rather than the browser. Because this capability is built into most MP3 players, users can choose at any time to listen to an MP3 file directly from a web server, without saving it to their hard drives first. Of course, this assumes that the user has sufficient bandwidth to listen to the file in real time without it skipping or halting, but we’ll get to bandwidth issues later. If you have a fast Internet connection, look around in your player’s menus for an option labeled something like “Open Location” or “Play URL” and enter the URL of any MP3 file on the web. The easiest way to get this information is to right-click a link to an MP3 file in your browser and choose “Copy Link Location” from the context menu, then paste the URL into the Open Location dialog in your player.

In addition, MP3-on-demand can be forced by the webmaster, so that clicking a link normally will cause MP3 files to be pulled down by the player and played directly, rather than saved to hard drive as with a normal download. To do this, the webmaster creates an “M3U” (MPEG URL) playlist file, which is a plain text document containing the full URL to an MP3 file (or list of files) on a web server. Because the text file is tiny, the browser can download the M3U file to the user’s hard drive nearly instantaneously. The web server sending the M3U file should (if it’s configured correctly) dish it up with the MIME type audio/x-mpegurl. This MIME type should, in turn, be associated in the user’s browser or operating system with a preferred MP3 player capable of handling MP3 streams.

Once the M3U file is downloaded, it’s launched in the preferred MP3 player, which reads URLs out of the file and takes over control of the actual download.

Note

Note the difference here: when you download an MP3 file normally, the browser itself handles the entire download, and users have to then launch the MP3 file in an MP3 player manually. The MP3 file is stored on the user’s hard drive for future use. With MP3-on-demand, the MP3 player handles the download, not the browser. The MP3 player plays the file as it’s being downloaded, not later on. And unlike a standard download, the MP3 file is not present on the user’s system after they’ve finished listening to the track.

The advantages of using the MP3-on-demand technique are:

  • The user does not have to wait for the download to complete before beginning to hear music.

  • The user has more control over playback than with real streaming (e.g., the user can skip around between songs or fast-forward through songs at will).

  • The webmaster has a degree of protection against MP3 files being stored permanently on the user’s system.

  • The publisher or webmaster does not have to set up any special MP3 serving software by having the MP3 player “suck” the file down. A plain vanilla web server running on any operating system is capable of serving up MP3-on-demand.

Because MP3-on-demand offers so much flexibility to both the webmaster and to the user, it may eventually become more popular than true MP3 streaming if and when all of us have lots of bandwidth. As long as our bandwidth is limited, however, true streaming solutions will continue to outweigh on-demand systems in popularity.

Note

An important aspect of the MP3-on-demand technique is that it’s “asynchronous,” or outside of time. In other words, it doesn’t matter what time of day the user accesses the file—he’ll hear it from the beginning. This is very different from TV, radio, or MP3 broadcast, where you get whatever is being broadcast at the moment in time when you tune in to the channel. For this reason, the MP3-on-demand technique is also sometimes referred to as "pseudo-streaming.”

A good example of MP3-on-demand can be found at MP3.com. Access any artist’s page and access one of the Hi-Fi or Low-Fi links. Rather than being prompted for a download location, your favorite MP3 player will be launched and the file should start playing immediately.

See Chapter 8 to learn how to set up your server for MP3-on-demand.

MP3 broadcast

In contrast to pseudo-streaming, MP3 broadcasting (or real streaming), is “synchronous,” and thus more akin to TV and radio broadcasting. In this case, the user tunes in to a channel or station which is playing an MP3-encoded bitstream much like a radio station, sometimes complete with live announcements and commercials. The person running the MP3 server is running the show in real time, and the listener only hears the portion of the show currently being dished up. When you tune in to an MP3 broadcast, you can’t just pick an arbitrary tune from the show, any more than you can with radio.

Running an MP3 broadcast station is a fairly complicated matter, and you’ll learn all about that in Chapter 8. As a user, however, listening to streamed MP3 is rarely more than a matter of point and click. To find MP3 broadcasts, check out sites such as http://www.shoutcast.com, http://www.icecast.org, http://www.radiospy.com, http://www.mycaster.com, http://www.greenwitch.com, or http://www.live365.comand you’ll find dozens—or hundreds—of ongoing broadcasts. If your system is configured properly, clicking a link to a stream in progress will cause your MP3 player to be launched and (after a short delay) for that stream to begin playing. If it doesn’t, see the following Section 4.6.2.

Note

Real MP3 streams are usually sent as .pls files (MIME type audio/x-scpls), rather than .M3U. The difference between these two playlist types is described earlier in this chapter.

The advantages to real-time MP3 streaming are:

  • Much greater control for the webcaster (voice, live mixing, etc.)

  • Webmaster can send a stream to many people without needing tons of bandwidth on the playback machine (though they still need access to a server with a fast connection)

  • Difficult for user to save MP3 bitstream to hard drive

  • Optimization of bitstream for various client bandwidths

Of bandwidth and buffers

To receive MP3 streams from MP3 broadcasts or pseudo-streams, your player must be capable of managing downloads and buffering streams over the Internet on its own. The vast majority of popular MP3 players are stream-enabled—even many of the command-line players for Unix/Linux.

The biggest concern for most users, of course, is the speed of their Internet connections. If you’re on a slow connection and the stream being served up (or pulled down) carries more bits per second than your modem is capable of delivering, you’ll experience choppy, halting playback.

This can be mediated somewhat by two solutions. On the client (user) side, a process called buffering can be used. In the buffering process, the MP3 player grabs a good chunk of data before it begins to play, and continues to read ahead in the stream. The music being played is thus delayed by a few seconds. The slower the connection, of course, the larger the buffer required. Theoretically, one could utilize a buffer so large that the entire song was downloaded before a second of music was played. This would guarantee perfect playback over even the slowest connections, but would undermine the advantage of listening to streams.

Most users, however, require more modest buffer settings. If you find that your MP3 streams are skipping or pausing as they’re played, dig around in your player’s options and preferences for something like “Streaming Preferences.” In WinAmp, tap Ctrl+P to bring up the preferences screen and navigate to Plugins Input NullSoft MPEG Audio Decoder. Click the Configure button and select the Streaming tab, where you’ll find an array of buffering options. Most likely, you’ll just want to change the numerical value for kilobytes of prebuffered audio (try increasing it by 25% or 50% for starters). You can also control how much of a track will be grabbed before a single byte is played.

On the server side, webmasters can do a number of things to make things easier for their modem-connected users, including downsampling MP3 files to lower frequencies, encoding files at lower bitrates, and sending mono, rather than stereo, streams over the Internet. All of these, of course, degrade sound quality, but are necessary to deliver acceptable streams to modem users. A sophisticated MP3 server will offer high-bandwidth and low-bandwidth options so users can select the best possible quality for their connection speed (such as the Hi-Fi and Low-Fi pseudo-streaming options found at MP3.com).

Note

Technically speaking, on-demand servers are capable of doing some of the things that broadcast servers do, such as downsampling MP3 audio on the fly. For the technically inclined, this would be a matter of creating a CGI interface that would invoke a downsampling program when the user accesses a link on the server, and sending the output of that program to the user rather than the actual file. This is really a CGI implementation, rather than an MP3 issue. While there aren’t many sites doing this currently, the technique would have certain advantages for some users, since it wouldn’t require the installation and configuration of special broadcast software. More on this in Chapter 8 .

Configuring Your System to Handle Streaming MP3

Regardless whether you’re accessing real MP3 broadcasts or pseudo-streams, the ideal is to have your browser, your operating system, and your MP3 player all configured to interoperate correctly so that accessing a link to an MP3 player automatically results in the right thing happening—your player gets launched and begins to play the stream with no further intervention on your part. In most cases, simply installing an MP3 player capable of handling MP3 streams is all it takes to set things up properly, but it’s possible for the necessary associations to become broken if you fiddle around with a lot of software or tweak your browser settings. In addition, you may at some point want a different player associated with MP3 streams.

The easiest way to create an appropriate association is to look in the options and preferences of the preferred player for something like “Make preferred for all types.” Better players will let you establish associations on a per-filetype basis so that you can, for example, make Sonique your preferred MP3 player for regular MP3 files, and WinAmp the preferred player for streamed .M3U and .pls files.

Note

If you have multiple MP3 players and browsers on your Windows system, the easiest way to establish associations may be to download the MP3Fix utility from http://help.mp3.com/help/diagnosis/. Although MP3Fix is packaged in a Windows InstallShield package, running it will not in fact install anything on your system. Rather, it will scour your system for known MP3 players and allow you to make one of them the preferred player for all browsers.

Netscape Navigator/Mozilla

If Netscape Navigator is your primary browser, you can tell the program exactly how to handle any incoming MIME type (file type) by pulling down Edit Preferences Applications (this may be slightly different in various versions of Navigator). Scroll through the list of known file types for something like MPEG Audio File or WinAmp Media File and click the Edit button. To change the associated MP3 player, click the Browse... button and navigate to the location of your preferred MP3 player. If you don’t find an entry in the list for the file type you want to associate, you can create a new one by clicking New Type... and filling in a description, file extension (e.g., MP3), a MIME type (e.g., audio/x-mpeg), and the path to an MP3 player.

Internet Explorer

If you use Internet Explorer as your browser, remember that Explorer is integrated into Windows itself. Therefore, it does not use a separate MIME association database. Instead, it uses the operating system’s FileTypes panel. To change an association manually, open Windows Explorer (not Internet Explorer) and pull down View Folder Options FileTypes. Navigate to the Playlist file type (which may be called, for instance, “WinAmp Playlist”), click Edit, and use the resulting dialog to change the description and program association. More details on this procedure can be found in Configuring the Default Handler for MP3 Files in Windows in Chapter 3.

Get MP3: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.