O'Reilly Network    


 Published on The O'Reilly Network (http://www.oreillynet.com/)
 http://www.oreillynet.com/pub/wlg/6704

Build a Streaming MP3 Player

by David Battino
Mar. 16, 2005
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.

oreillynet.com Copyright © 2006 O'Reilly Media, Inc.