Audio::File::Tag - abstracts the tag of an audio file


Audio-File documentation Contained in the Audio-File distribution.

Index


Code Index:

NAME

Top

Audio::File::Tag - abstracts the tag of an audio file

DESCRIPTION

Top

Audio::File::Tag is the base class for other file format independant tag classes like Audio::File::Flac::Tag or Audio::File::Ogg::Tag. You shouldn't use this class yourself exept you're writing an own file format dependant subclass.

METHODS

Top

new

Constructor. Creates a new Audio::File::Tag object. You shouldn't use this method yourself. It is called by the filetype-dependant subclasses of Audio::File::Type automatically.

init

Initializes the object. It's called by the constructor and empty by default. It's ought to be overwritten by subclasses.

title

Using title() you can get or set the tags title field. If called without any argument it'll return the current content of the title field. If you call title() with an scalar argument it will set the title field to what the argument contains. The methods artist(), album(), comment(), genre(), year(), track() and total() are called in the same way.

artist

Set/get the artist field in the files tag.

album

Set/get the album field in the files tag.

comment

Set/get the comment field in the files tag.

genre

Set/get the genre field in the files tag.

year

Set/get the year field in the files tag.

track

Set/get the track field in the files tag.

total

Set/get the total number of tracks.

all

Set/get all tags. To set the tags pass a hash reference with the names of the tags as keys and the tag values as hash values. Returns a hash reference if no argument is specified.

is_empty

Returns whether all tag fields are empty or not.

save

Saves the changed tag information. Not yet implemented.

TODO

Top

Implement writing tags

AUTHOR

Top

Florian Ragwitz <flora@cpan.org>

COPYRIGHT AND LICENSE

Top


Audio-File documentation Contained in the Audio-File distribution.
package Audio::File::Tag;

use strict;
use warnings;

our $VERSION = '0.03';

sub new {
	my($class, $filename) = @_;
	$class = ref $class || $class;
	my $self = { filename => $filename };
	bless $self, $class;
	$self->init(@_) or return;
	return $self;
}

sub init {

}

sub title {
	my $self = shift;
	if( @_ ) {
		$self->{title} = shift;
		return 1;
	}

	return $self->{title};
}

sub artist {
	my $self = shift;
	if( @_ ) {
		$self->{artist} = shift;
		return 1;
	}

	return $self->{artist};
}

sub album {
	my $self = shift;
	if( @_ ) {
		$self->{album} = shift;
		return 1;
	}

	return $self->{album};
}

sub comment {
	my $self = shift;
	if( @_ ) {
		$self->{comment} = shift;
		return 1;
	}

	return $self->{comment};
}

sub genre {
	my $self = shift;
	if( @_ ) {
		$self->{genre} = shift;
		return 1;
	}

	return $self->{genre};
}

sub year {
	my $self = shift;
	if( @_ ) {
		$self->{year} = shift;
		return 1;
	}

	return $self->{year};

}

sub track {
	my $self = shift;
	if( @_ ) {
		$self->{track} = shift;
		return 1;
	}
	
	return $self->{track} + 0;

}

sub total {
	my $self = shift;
	if ( @_ ) {
		$self->{total} = shift;
		return 1;
	}

	return $self->{total} + 0;
}

sub all {
	my $self = shift;

	if (@_) {
		my $tags = shift;
		$self->$_($tags->{$_}) for keys %{$tags};
		return 1;
	}

	return {
		title	=> $self->title(),
		artist	=> $self->artist(),
		album	=> $self->album(),
		comment	=> $self->comment(),
		genre	=> $self->genre(),
		year	=> $self->year(),
		track	=> $self->track(),
		total	=> $self->total()
	};
}

sub is_empty {
	my $self = shift;
	return ($self->title() &&
			$self->artist() &&
			$self->album() &&
			$self->comment() &&
			$self->genre() &&
			$self->year() &&
			$self->track() &&
			$self->total());
}

sub save {

}

1;