Build a Streaming MP3 Player

David Battino
Mar. 16, 2005 12:35 PM
Permalink

URL: http://digitalmedia.oreilly.com/2005/02/23/mp3_embed.html...
After reading my article “Build a Simple MP3 Player for Your Site,” a visitor asked if it were possible to use the technique to create a streaming media player on the fly.
It is. The technique in the article simply pops open a window with an embedded media player when someone clicks a special JavaScript link. You can embed whatever you want in the window. To play formats like RealAudio, you may need to change the embedding code in the external JavaScript file. There’s some sample code here that may be useful.
But I just tried the current code, using an m3u file instead of an MP3, and it worked fine. (An m3u file is simply a text file containing the URL of the MP3 and the extension .m3u.) In fact, using an m3u link even cleared up the stuttering problem I had experienced with some MP3 files on the Mac.
If you do decide to stream MP3s, though, you should probably provide low-bandwidth versions for dial-up visitors. In “The Real Secret of Streaming MP3s,” Emmy-nominated sound editor Skip Adams recommends using 16kbps, 11kHz mono files.
David Battino
is the audio editor for O’Reilly’s Digital Media site, the co-author of The Art of Digital Music, and on the steering committee for the Interactive Audio Special Interest Group (IASIG). He also writes, publishes, and performs Japanese kamishibai storycards.
Return to weblogs.oreilly.com.
Weblog authors are solely responsible for the content
and accuracy of their weblogs, including opinions they
express, and O'Reilly Media, Inc., disclaims any and
all liabililty for that content, its accuracy, and
opinions it may contain.
This work is licensed under a
Creative Commons License.
|
However, this created trouble for non-embedded .m3u files. I run an on-demand site that uses Apache::MP3, a module that creates .m3u files on the fly to stream mp3s. Normally the .m3u files are downloaded and opened using a default appliction, iTunes, WinAmp, RealPlayer, whatever. After registering QuickTime as the handler of the mime type however, the plugin attempted to play these files within the browser. Unfortunately it failed to do so. I had the same result attempting to listen to an Internet radio station, Radio Paradise. Many Internet radio streams use .pls files instead of .m3u so the mime type change doesn't affect them but for me it's a killer. Ideally embedded .m3u files would be handled by a plugin and the rest by a helper app.