Audio::TagLib::FileRef::FileTypeResolver - A class for pluggable file type resolution.


Audio-TagLib documentation  | view source Contained in the Audio-TagLib distribution.

Index


NAME

Top

Audio::TagLib::FileRef::FileTypeResolver - A class for pluggable file type resolution.

DESCRIPTION

Top

This class is used to add extend Audio::TagLib's very basic file name based file type resolution.

This can be accomplished with:

  package Audio::TagLib::FileRef::MyFileTypeResolver;

  our @ISA = qw(Audio::TagLib::FileRef::FileTypeResolver);

  sub createFile() {
      my $package  = shift;
      my $filename = shift;
      if(&someCheckForAnMP3File($filename)) {
          my $file = Audio::TagLib::MPEG::File->new($filename);
          # skip DESTROY() in Perl level
          $file->_setReadOnly();
          return $file;
      }
      return undef;
  }

  package main;

  Audio::TagLib::FileRef->addFileTypeResolver(
      Audio::TagLib::FileRef::MyFileTypeResolver->new());

Naturally a less contrived example would be slightly more complex. This can be used to plug in mime-type detection systems or to add new file types to Audio::TagLib.

File createFile(PV $fileName, BOOL $readAudioProperties = TRUE, PV $audioPropertiesStyle = "Average") [pure virtual]

This method must be overriden to provide an additional file type resolver. If the resolver is able to determine the file type it should return a valid File object; if not it should return undef.

NOTE The created file is then owned by the FileRef and should not be deleted. Deletion will happen automatically when the FileRef passes out of scope.

EXPORT

None by default.

SEE ALSO

Top

Audio::TagLib

AUTHOR

Top

Dongxu Ma, <dongxu@cpan.org>

COPYRIGHT AND LICENSE

Top


Audio-TagLib documentation  | view source Contained in the Audio-TagLib distribution.