AudioFile::Info::MP4::Info - Perl extension to get info from MP4 files.


AudioFile-Info-MP4-Info documentation Contained in the AudioFile-Info-MP4-Info distribution.

Index


Code Index:

NAME

Top

AudioFile::Info::MP4::Info - Perl extension to get info from MP4 files.

DESCRIPTION

Top

Extracts data from an MP4 file using the CPAN module MP4::Info.

See AudioFile::Info for more details.

METHODS

Top

new

Creates a new object of class AudioFile::Info::MP4::Info. Usually called by AudioFile::Info::new.

AUTHOR

Top

Simon Wistow, <simon@thegestalt.org>

COPYRIGHT AND LICENSE

Top


AudioFile-Info-MP4-Info documentation Contained in the AudioFile-Info-MP4-Info distribution.
#
# $Id: $
#

package AudioFile::Info::MP4::Info;

use 5.006;
use strict;
use warnings;
use Carp;

use MP4::Info;

our $VERSION = "0.5";

my %data = (artist => ['ART',      'ARTIST'],
            title  => ['NAM',      'TITLE'],
            album  => ['ALB',      'ALBUM'],
            track  => ['TRACKNUM', 'TRKN'],
            year   => ['DATE',     'YEAR'],
            genre  => ['GNRE',     'GENRE']);

sub new {
  my $class = shift;
  my $file  = shift;
  my $obj   = get_mp4tag($file) || die "Couldn't get MP4 info for $file";
  bless { obj => $obj }, $class;
}

sub DESTROY {}

sub AUTOLOAD {
  our $AUTOLOAD;

  my ($pkg, $sub) = $AUTOLOAD =~ /(.*)::(\w+)/;

  die "Invalid attribute $sub" unless $data{$sub};
  foreach my $try (@{$data{$sub}}) {
    return $_[0]->{obj}->{$try} if defined $_[0]->{obj}->{$try};
  }
  return undef;
}


1;
__END__