Dongxu Ma > Audio-TagLib-1.43 > Audio::TagLib::FileRef::FileTypeResolver

Download:
Audio-TagLib-1.43.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  2
View/Report Bugs
Module Version: 1.41   Source   Latest Release: Audio-TagLib-1.50_01

NAME ^

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

DESCRIPTION ^

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 ^

Audio::TagLib

AUTHOR ^

Dongxu Ma, <dongxu@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2005 by Dongxu Ma

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: