Re: Help me about audio stream...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, December 4, 2006 1:37 am, Le Phuoc Canh wrote:
> Dears,
> I want to make a web app about music online. But i don't know how to
> use
> streaming in PHP to load a music file for playing. Please help me for
> the
> best direction.
> Thanks alot and best regard.

You are making this too complicated.

Fortunately, I've had to explain this to many many musicians in other
forums, and can simplify it:

Step #1.
Create your MP3 somehow with a CD-ripper/encoder or whatever.

Step #2.
Upload the MP3 to your website, just like an HTML page, but be sure it
uploads as "BINARY" and not "ASCII"

Step #3.
Test the uploaded file as a download.
Just make a link to the MP3, the same way you'd link to an HTML page,
only it will have somethine like "somesong.mp3" in it.
That should do a download for your MP3 player.
If not, and it prompts you to save it as an "unknown" type, or shows a
bunch of gibberish on the browser window, then you have to figure out
how to convince your web-server that the correct mime-type for that
file ending in .mp3 is:  audio/mpeg

Step #4.
Copy/paste the URL to the MP3 into a plain text file.
Not MS Word, nor even FrontPage nor DreamWeaver, but just plain old
Notepad (SimpleText on the Mac).
Save the file as "somesong.m3u"
The .m3u is crucial for the file type.

Step #5.
Upload that .m3u file to your webserver, and make a link to THAT URL,
just like you do for HTML files and just like you did in Step#2, only
with the .m3u URL instead.

Step #6.
Test the .m3u link, and it should be a streaming audio file for your
MP3 player.
Again, if not, you have to convince your web-server that the correct
mime-type for an .m3u file is:  audio/mpeg-url


That's it.  You now have streaming audio on your server.

None of this has anything to do with PHP, really, so some obligatory
PHP comments are in order. :-)

You can use a script like "sample" to sort of funnel requests for the
MP3s and have that be a PHP script which keeps a log who played what,
or it can do something fun like prepend the ID3 tags to the MP3
stream, so that your ID3 data can easily be changed without dinking
around with monstrous MP3 files to edit them.

Here is a sample script for that purpose, and more:
http://uncommonground.com/sample.phps

This script also has some stuff in it to upload the MP3 from a second
tier server into a caching system, which you can mostly ignore.  Or
steal, as you see fit.

YMMV

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux