Apache-MP3
view release on metacpan or search on metacpan
For the purposes of faster startup and memory efficiency, you may load
the MP3::Info module at server startup time. If you have a mod_perl
"startup" file, enter these lines:
use MP3::Info;
use Apache::MP3;
=item 6. Set up MP3 directory
Create a directory in the web server document tree that will contain
the MP3 files to be served. The module recognizes and handles
subdirectories appropriately. I suggest organizing directories
hierarchically by artist and/or album name.
If you place a file named "cover.jpg" in any of the directories, that
image will be displayed at the top of the directory listing. You can
use this to display cover art.
If you place a list of .mp3 file names in a file with the .m3u
extension, it will be treated as a playlist and displayed to the user
with a distinctive icon. Selecting the playlist icon will download
the playlist and stream its contents. The playlist must contain
relative file names, but may refer to subdirectories, as in this
example:
# file: folk_favorites.m3u
Never_a_Moment_s_Thought_v2.mp3
Peter Paul & Mary - Leaving On A Jet Plane.mp3
Simon and Garfunkel/Simon And Garfunkel - April Come She Will.mp3
Likewise, if you place a list of shoutcast URLs into a file with the
pls extension, it will be treated as a playlist and displayed to the
user with a distinctive icon. Selecting the playlist icon will
contact the shoutcast servers in the playlist and stream their
contents. The playlist syntax is as in this example:
[playlist]
numberofentries=2
File1=http://205.188.245.132:8038
Title1=Monkey Radio: Grooving. Sexy. Beats.
Length1=-1
File2=http://205.188.234.67:8052
Title2=SmoothJazz
Length2=-1
Version=2
Example shoutcast files can be downloaded from http://www.shoutcast.com
You can find a lot of good MP3 broadcasts there, most of them
commercial-free.
Apache::MP3 permits you to directly use CDDB data without embedding it
in ID3 tags. To take advantage of this feature, your MP3 files should
have file names of this form: track-XX.mp3. Then, place a CDDB index
file in the same directory as the tracks and name it INDEX. For
example, you might execute this command
cddbcmd cddb read soundtrack cb115c11 > INDEX
to create an INDEX file for the Mulholland Drive soundtrack. The
32-bit disc ID can be obtained with a program such as cd-discid.
=item 8. Set up an information cache directory (optional)
In order to generate its MP3 listing, Apache::MP3 must open each sound
file, extract its header information, and close it. This is time
consuming, particularly when recursively generating playlists across
multiple directories. To speed up this process, Apache::MP3 has the
ability cache MP3 file information in a separate directory area.
To configure this, choose a directory that the Web server has write
access for, such as /usr/tmp. Then add a configuration variable like
the following to the <Location> directive:
PerlSetVar CacheDir /usr/tmp/mp3_cache
If the designated directory does not exist, Apache::MP3 will attempt
to create it, limited of course by the Web server's privileges. You
may need to create the mp3_cache directory yourself if /usr/tmp is not
world writable.
=back
Open up the MP3 URL in your favorite browser. You should be able to
see directory listings, and download and stream your songs. If things
don't seem to be working, checking the server error log for messages.
=head1 CUSTOMIZING
Apache::MP3 can be customized in three ways: (1) by changing
per-directory variables; (2) changing settings in the Apache::MP3
cascading stylesheet; and (3) subclassing Apache::MP3 or
Apache::MP3::Sorted.
=head2 Per-directory configuration variables
Per-directory variables are set by I<PerlSetVar> directives in the
Apache::MP3 E<lt>LocationE<gt> or E<lt>DirectoryE<gt> section. For
example, to change the icon displayed next to subdirectories of MP3s,
you would use I<PerlSetVar> to change the I<DirectoryIcon> variable:
PerlSetVar DirectoryIcon big_cd.gif
This following table summarizes the configuration variables. A more
detailed explanation of each follows in the subsequent sections.
Table 1: Configuration Variables
Name Value Default
---- ----- -------
GENERAL OPTIONS
AllowDownload yes|no yes
AllowStream yes|no yes
AllowPlayLocally yes|no yes
CheckStreamClient yes|no no
ReadMP3Info yes|no yes
StreamTimeout integer 0
DIRECTORY OPTIONS
BaseDir URL /apache_mp3
CacheDir path -none-
( run in 0.834 second using v1.01-cache-2.11-cpan-2398b32b56e )