package ID3FS::AudioFile;

use strict;
use warnings;
use ID3FS::AudioFile::Mp3;
use ID3FS::AudioFile::Ogg;
use ID3FS::AudioFile::Flac;

sub new
{
    my $proto=shift;
    my $class=ref($proto) || $proto;
    my $self={};
    bless($self,$class);

    my $path=shift;
    my $ext=($path=~/.*\.(.*)/)[0];
    return undef unless($ext);
    $ext=lc($ext);
    if($ext eq "mp3")
    {
	$self->{audiofile}=ID3FS::AudioFile::Mp3->new($path);
    }
    elsif($ext eq "ogg")
    {
	$self->{audiofile}=ID3FS::AudioFile::Ogg->new($path);
    }
    elsif($ext eq "flac")
    {
	$self->{audiofile}=ID3FS::AudioFile::Flac->new($path);
    }
    else
    {
	print("Unknown extension: $ext\n");
	return undef;
    }
}

sub artist
{
    return shift->{audiofile}->artist(@_);
}
sub album
{
    return shift->{audiofile}->album(@_);
}
sub audiotype
{
    return shift->{audiofile}->audiotype(@_);
}
sub haspic
{
    return shift->{audiofile}->haspic(@_);
}
sub v1genre
{
    return shift->{audiofile}->v1genre(@_);
}
sub year
{
    return shift->{audiofile}->year(@_);
}
sub tags
{
    return shift->{audiofile}->tags(@_);
}

1;
