Here is a collection of frequently asked questions about sMeta:
Here's some of the source of
magoffin.matt.meta.MetadataResourceExample
:
public static void main(String[] args) throws IOException {
if ( args == null || args.length < 1 ) {
System.err.println("Pass files to read metadata from.");
}
// 1: get a MetadataResourceFactoryManager instance
MetadataResourceFactoryManager manager
= MetadataResourceFactoryManager.getDefaultManagerInstance();
for ( String filePath : args ) {
File oneFile = new File(filePath);
// 2: get a MetadataResourceFactory for this file type
MetadataResourceFactory factory
= manager.getMetadataResourceFactory(oneFile);
try {
// 3: get a MetadataResource for this file
MetadataResource metaResource
= factory.getMetadataResourceInstance(oneFile);
// 4: print out all available metadata
Iterable<String> keys = metaResource.getParsedKeys();
System.out.println("\nMetadata for file ["
+oneFile.getAbsolutePath() +"]:");
for ( String key : keys ) {
System.out.println(key +" = "
+metaResource.getValue(key, Locale.getDefault()));
}
} catch ( MetadataNotSupportedException e ) {
System.err.println("File [" +oneFile.getAbsolutePath()
+"] is not supported by the ["
+factory.getClass().getName() +"] factory");
}
}
}
A sample of the output from this program is:
Look for a magoffin.matt.meta.MetadataImage
object in the metdata returned for your MP3 file. This API provides an easy
way to either get a java.awt.image.BufferedImage
from
the embedded image data, or write the unaltered image data to an
java.io.OutputStream
.
For example, running the
magoffin.matt.meta.MetadataResourceExample
on an MP3 with
an embedded PNG image results in this:
Note the ALBUM_COVER
metadata key, which is an instance of
magoffin.matt.meta.MetadataImage
and is showing the image format
(PNG) and size (26,781 bytes).
This is handled in the same fashion as extracting the album cover from an MP3
file (above). The POSTER
metadata key will contain a
magoffin.matt.meta.MetadataImage
if sMeta is able to extract a still
frame from the video. For video formats with the ability to specify a poster frame
(i.e. QuickTime) sMeta will extract that frame. For other video formats sMeta will
extract the first frame.