Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Music Media

MP3 Streaming on Demand? 14

Joe asks: "I've checked freshmeat a number of times, but I can't seem to find any software that will stream mp3 files 'on demand'. Most software for mp3 streaming (be it windows or unix) is based on the broadcast model (shoutcast/icecast), where a fixed or growing playlist keeps playing at all times. What I want is something that works on the 'play samples' model, where a sample of the tune is played automatically through a streaming protocol, rather than downloaded and played once downloaded. Any such beast exist? If not, why not?"

"I suppose with enough fidgetting, one could write a cgi program (even as a /bin/sh script) that would start a new icecast process on a particular port, start the shout stream, and return to the browser the "playlist" that would signal the browser to start winamp/xmms on the appropriate port; the "start the shout stream" process would wait play silence for a few seconds before shouting the desired mp3 in order to give time to the player...but that seems rather kluge-like."

This discussion has been archived. No new comments can be posted.

MP3 Streaming on Demand?

Comments Filter:
  • by billcopc ( 196330 ) <vrillco@yahoo.com> on Monday July 17, 2000 @02:38PM (#926363) Homepage
    You stepped right over the solution without noticing it. Just make a CGI that will stream the MP3 directly to the player. Just make a normal playlist that points to your CGI (probably with a parameter for the desired soundfile). The playlist will be passed on to the mp3 player, which will then HTTP open the CGI, where you can start feeding the music data requested. Piece of cake.
  • icecast can do it. if you drop files into the static_dir, you can get them from http://icecast-server.whatever.com:8000/file/some. mp3 icecast isn't built for on demand streaming, since apache does that job quite nicely. just get an m3u file, and link to the mp3 on the web server. it works quite nicely. try this [icecast.org] for details.
  • People have correctly pointed out that most "decent" mp3 players have had this functionality for a while. Winamp actually didn't have it at first if I recall. Other than that though, the ability to stream MP3 has been around -- and been done the same way -- since the very first MP3 player, WinPlay3. Winamp's method was more or less copied WP3's.

    Anyway, if you enter a URL in the Play Location: window of Winamp (ctrl-click on the eject button, or Ctrl-L), it will stream an MP3 at that location.

    The bitch is that most web browsers will preempt streaming, waiting for the file to be fully downloaded before it passes it onto any helper app. This is in theory safer, but ya oughtta be able to turn off the deferral.

    The answer of streaming from web links is to use M3U playlists for the file(s) you want to stream. The playlist contains the URL of the streamworthy file, and the web browser is none the wiser -- it passes the very small M3U onto the player, which then takes over the downloading of the file listed inside, streaming it in the meantime.

    I suppose therefore you might want a script on your server that will generate M3U output on the fly for your online music collection. Such a script would be very simple -- in theory it only needs to output text data consisting of a URL to the actual file.

    However, I usually just use "Copy Link Location" or "Copy Shortcut" from the right-click-over-link menu, and then paste it into the Winamp "Play Location" window. And there you have it, instant streaming on demand. :)
    --
  • Quick answer : just look at MP3.Com and see how they did it.. a CGI that spits out M3U (or is it PLS) playlists.
  • by angry old man ( 211217 ) on Monday July 17, 2000 @06:13PM (#926367)
    bagh. Back in my day we didn't have fancy schmancy streaming digital audio.

    If we wanted to listen to something on our computer, we plopped a music CD in the CDROM tray. If we wanted to listen to something in a different part of our house, we didn't stream it to the computer in that room, we turned the volume up in the other room.

    Nowadays, all you kids with your stream this, or rip that attitudes are causing those hard working record industry executives to get there panties in a bundle. The recording industry barely gets by on its razor thin profit margins, and any of this digital streaming might cause them to to go bust! If you weren't such lazy hooligans, you'd carry around your store bought CD around with you and listen to that.



  • http://www.lyra.org/greg/edna

    It's a standalone http mp3 server. In one
    python script. It sends .m3u to your player
    so that the mp3s are streamed. It can also
    shuffle and play recursively.

    Highly recommended.

    Stephen.

    (for the other end of things 'jack' is an
    excellent ripper/encoder btw.)

  • As long as you are not looking for neato features like direct seek and realtime "live audio" streaming, http is a fine protocol for streaming mp3. Most decent mp3 players (xmms, mpg123 -b, sonique, winamp) buffer the input stream to handle bumps in the stream. Icecast streams through the http protocol -- it's designed to provide content using the broadcast model instead of pointcast. Apache is a good platform for individual streams.
  • I've had a solution like this for about 6 months now. XMMS (and Winamp, and I think a few people have used Real* stuff with it too) supports streaming via HTTP. I just set up an apache virtualhost pointing to my MP3 shares, and another pointing to index pages. To make the index pages I just created playlists of the files and threw them through a perl script that spit out the HTML complete with lists and such (I usually did one each time I had a bunch to add an customized them greatly for the task, but I could probably dig one out if it'd help). The links they created were basically the filename with characters escaped and the hostname prepended, and thrown after a m3u creating cgi (basically returned a text listing of whatever addresses were passed). This allowed me to have it request entire categories as long as the cgi could sort it.

    The two virtualhosts were on the same machine, and could be setup on one if needed - I split them for easy of use, maintenance, and security (I set it up while at school, so I wanted the thing restricted so I didn't become the biggest bandwidth user on campus).

    As for speed and such. When I click on a link the song is usually started before my finger is lifted off the mouse button (both at home on 100Mbps LAN and at school on the 10Mbps LAN). The response time is basically a factor of how fast the server is, how fast your browser can get the address to the player, and how fast the player can parse and request the address.
  • And see how they do it. They send you a playlist, which causes your browser to open your MP3 player (if your browser is configured correctly) which starts to stream the file requested.

    Look at a typical MP3.com URL:
    http://chooser.mp3.com/cgi-bin/play/play.cgi/[sn ip session id]/electronic.m3u

    Probably a simple CGI which stores the session data (things like IP, browser, OS etc.) and serves you the MP3 trough the playlist.

    bBob

    --

  • Streaming an MP3 file out of a CGI works fine, but if you're concerned about bandwidth, you should be sure to rate-limit it: don't send the data much faster than the bitrate of the file.
  • You should be able to get it from any Perl respository. It makes your Apache server treat directoryname.pls as a playlist, and returns a list of streaming mp3 links suitable for WinAmp or your favorite player. Not fancy, but works well.
  • I found edna about 2 days after i submitted the question, and it seemed to do the job well.

    In addition, I got the apache system to work well enough for my needs (though i need to fitz with LAME to get smaller files -- 44/128s would kill my bitrate quota). the trick was to add the "audio/x-mpegurl m3u" line to the server mime.types file (it isn't there by default).

    If you are using someone else's server (you can't change conf info), you can also do it by puting the line "AddType audio/x-mpegurl .m3u" in the .htaccess file for the directory containing the m3us. to minimize constant .htaccess accessing (apache will look it up for every load in that path), you might consider putting all the .m3u files in a single directory by themselves.

    Thanks for the pointers...

  • By the way, mpg123 for linux/unix will also accept an http URL on the command line and will stream.
    --
  • how?
    .oO0Oo.

"When the going gets tough, the tough get empirical." -- Jon Carroll

Working...