Additional information for Flac files

Reading Data

Flac has exactly the same features as OggVorbis files, but with full support for embedding images. All calls to FlacTag are delegated to the vorbis tag except for images


FlacTag tag = (FlacTag)f.getTag();
VorbisCommentTag vorbisTag = tag.getVorbisCommentTag();
List images = tag.getImages();	
.

The only common binary field is Artwork, you get can access to the Flac specific attributes as follows:


MetadataBlockDataPicture image = tag.getImages().get(0);
(int)image.getPictureType();
image.getMimeType();
image.getImageUrl();
image.getDescription();
image.getWidth();
image.getHeight();
image.getColourDepth();
image.getIndexedColourCount();
BufferedImage bi = ImageIO.read(ImageIO.createImageInputStream(new ByteArrayInputStream(image.getImageData());
.

Writing Data

You may wish to create a field, that is not listed in the general or audio specific enumeration. Vorbis Comments allow custom keys so you can create a custom field as follows

	
tag.addField("VOLINIST,"Sarah Curtis"));

You can create images as follows

RandomAccessFile imageFile = new RandomAccessFile(new File("testdata", "coverart.png"), "r");
byte[] imagedata = new byte[(int) imageFile.length()];
imageFile.read(imagedata);
tag.set(tag.createArtworkField(imagedata,
                     PictureTypes.DEFAULT_ID,
                     ImageFormats.MIME_TYPE_PNG,
                     "test",
                     200,
                     200,
                     24,
                     0));

You can create a linked images as follows

tag.getImages().add((MetadataBlockDataPicture)tag.createLinkedArtworkField("..\\testdata\\coverart.jpg"));