Ejemplo n.º 1
0
 /**
  * Populate Artwork from MetadataBlockDataPicture as used by Flac and VorbisComment
  *
  * @param coverArt
  */
 public void setFromMetadataBlockDataPicture(MetadataBlockDataPicture coverArt) {
   setMimeType(coverArt.getMimeType());
   setDescription(coverArt.getDescription());
   setPictureType(coverArt.getPictureType());
   if (coverArt.isImageUrl()) {
     setLinked(coverArt.isImageUrl());
     setImageUrl(coverArt.getImageUrl());
   } else {
     setBinaryData(coverArt.getImageData());
   }
   setWidth(coverArt.getWidth());
   setHeight(coverArt.getHeight());
 }
Ejemplo n.º 2
0
  @Override
  public BufferedImage getArtwork() {
    BufferedImage image = super.getArtwork();

    if (image == null) {
      try {
        AudioFile audioFile = AudioFileIO.read(file);
        FlacTag tag = (FlacTag) audioFile.getTag();
        if (tag != null) {
          List<MetadataBlockDataPicture> images = tag.getImages();
          if (images != null && !images.isEmpty()) {
            MetadataBlockDataPicture picture = images.get(0);
            byte[] data = picture.getImageData();
            image = imageFromData(data);
          }
        }
      } catch (Throwable e) {
        LOG.error("Unable to read cover art from flac");
      }
    }

    return image;
  }