Apache::MP3::Sorted - Generate sorted streamable directories of MP3 files
# httpd.conf or srm.conf AddType audio/mpeg mp3 MP3 # httpd.conf or access.conf <Location /songs> SetHandler perl-script PerlHandler Apache::MP3::Sorted PerlSetVar SortFields Album,Title,-Duration PerlSetVar Fields Title,Artist,Album,Duration </Location>
Apache::MP3::Sorted subclasses Apache::MP3 to allow for sorting of MP3 listings by various criteria. See Apache::MP3 for details on installing and using.
This class adds one new Apache configuration variable, SortFields. This is a list of the names of the fields to sort by default when the MP3 file listing is first displayed, after which the user can change the sort field by clicking on the column headers.
The value of SortFields may contain the names of any of the fields in the listing, such as Title, or Album Duration. By default, the sort direction will be alphabetically or numerically ascending. Reverse this by placing a "-" in front of the field name (for symmetry, you can also prepend a "+" to signify normal ascending order). After the initial sort, the user can change the sort order by clicking on the column headings of the file listing table.
PerlSetVar SortFields Album,Title # sort ascending by album, then title PerlSetVar SortFields +Artist,-Kbps # sort ascending by artist, descending by kbps
When constructing a playlist from a recursive directory listing, sorting will be global across all directories. If no sort order is specified, then the module reverts to sorting by file and directory name. A good value for SortFields is to sort by Artist,Album and track:
PerlSetVar SortFields Artist,Album,Track
Alternatively, you might want to sort by Description, which effectively sorts by title, artist and album.
The following are valid fields:
Field Description album The album artist The artist bitrate Streaming rate of song in kbps comment The comment field description Description, as controlled by DescriptionFormat duration Duration of the song in hour, minute, second format filename The physical name of the .mp3 file genre The genre samplerate Sample rate, in KHz seconds Duration of the song in seconds title The title of the song track The track number
Field names are case insensitive.
Apache::MP3::Sorted overrides the following methods:
sort_mp3s() mp3_table_header() mp3_list_bottom()
It adds one new method:
Returns a list of the names of the fields to sort on by default.
Let me know.
Copyright 2000, Lincoln Stein <email@example.com>.
This module is distributed under the same terms as Perl itself. Feel free to use, modify and redistribute it as long as you retain the correct attribution.
Tim Ayers <firstname.lastname@example.org> conceived and implemented the multiple field sorting system.