Lincoln D. Stein > Apache-MP3 > Apache::MP3::Sorted

Download:
Apache-MP3-4.00.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  0
View/Report Bugs
Module Version: 2.02   Source  

NAME ^

Apache::MP3::Sorted - Generate sorted streamable directories of MP3 files

SYNOPSIS ^

 # 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>

DESCRIPTION ^

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.

CUSTOMIZING ^

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.

SortFields field

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.

Examples:

  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.

METHODS ^

Apache::MP3::Sorted overrides the following methods:

 sort_mp3s()  mp3_table_header()   mp3_list_bottom()

It adds one new method:

$field = $mp3->sort_fields

Returns a list of the names of the fields to sort on by default.

BUGS ^

Let me know.

AUTHOR ^

Copyright 2000, Lincoln Stein <lstein@cshl.org>.

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.

ACKNOWLEDGEMENTS ^

Tim Ayers <tayers@bridge.com> conceived and implemented the multiple field sorting system.

SEE ALSO ^

Apache::MP3, MP3::Info, Apache

syntax highlighting: