コード例 #1
0
  /** @return list of artwork images */
  public List<Artwork> getArtworkList() {
    List<Artwork> artworkList = new ArrayList<Artwork>(1);

    // Read Old Format
    if (getArtworkBinaryData() != null & getArtworkBinaryData().length > 0) {
      Artwork artwork = new Artwork();
      artwork.setMimeType(getArtworkMimeType());
      artwork.setBinaryData(getArtworkBinaryData());
      artworkList.add(artwork);
    }

    // New Format (Supports Multiple Images)
    List<TagField> metadataBlockPics = this.get(VorbisCommentFieldKey.METADATA_BLOCK_PICTURE);
    for (TagField tagField : metadataBlockPics) {

      try {
        byte[] imageBinaryData = Base64Coder.decode(((TagTextField) tagField).getContent());
        MetadataBlockDataPicture coverArt =
            new MetadataBlockDataPicture(ByteBuffer.wrap(imageBinaryData));
        Artwork artwork = Artwork.createArtworkFromMetadataBlockDataPicture(coverArt);
        artworkList.add(artwork);
      } catch (IOException ioe) {
        throw new RuntimeException(ioe);
      } catch (InvalidFrameException ife) {
        throw new RuntimeException(ife);
      }
    }
    return artworkList;
  }
コード例 #2
0
 /**
  * Create Artwork field
  *
  * @param artwork
  * @return
  * @throws FieldDataInvalidException
  */
 public TagField createField(Artwork artwork) throws FieldDataInvalidException {
   try {
     char[] testdata = Base64Coder.encode(createMetadataBlockDataPicture(artwork).getRawContent());
     String base64image = new String(testdata);
     TagField imageTagField =
         createField(VorbisCommentFieldKey.METADATA_BLOCK_PICTURE, base64image);
     return imageTagField;
   } catch (UnsupportedEncodingException uee) {
     throw new RuntimeException(uee);
   }
 }
コード例 #3
0
  /**
   * Create artwork field using the non-standard COVERART tag
   *
   * <p>Actually create two fields , the data field and the mimetype. Its is not recommended that
   * you use this method anymore.
   *
   * @param data raw image data
   * @param mimeType mimeType of data
   *     <p>
   * @return
   */
  @Deprecated
  public void setArtworkField(byte[] data, String mimeType) {
    char[] testdata = Base64Coder.encode(data);
    String base64image = new String(testdata);
    VorbisCommentTagField dataField =
        new VorbisCommentTagField(VorbisCommentFieldKey.COVERART.getFieldName(), base64image);
    VorbisCommentTagField mimeField =
        new VorbisCommentTagField(VorbisCommentFieldKey.COVERARTMIME.getFieldName(), mimeType);

    setField(dataField);
    setField(mimeField);
  }
コード例 #4
0
 /**
  * Retrieve artwork raw data when using the deprecated COVERART format
  *
  * @return
  */
 public byte[] getArtworkBinaryData() {
   String base64data = this.getFirst(VorbisCommentFieldKey.COVERART);
   byte[] rawdata = Base64Coder.decode(base64data.toCharArray());
   return rawdata;
 }