FileDocCategorySizeDatePackage
FrameBodyAPIC.javaAPI DocJaudiotagger 2.0.410566Wed Mar 30 16:12:02 BST 2011org.jaudiotagger.tag.id3.framebody

FrameBodyAPIC

public class FrameBodyAPIC extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBody
Attached picture frame.

This frame contains a picture directly related to the audio file. Image format is the MIME type and subtype for the image. In the event that the MIME media type name is omitted, "image/" will be implied. The "image/png" or "image/jpeg" picture format should be used when interoperability is wanted. Description is a short description of the picture, represented as a terminated textstring. The description has a maximum length of 64 characters, but may be empty. There may be several pictures attached to one file, each in their individual "APIC" frame, but only one with the same content descriptor. There may only be one picture with the picture type declared as picture type $01 and $02 respectively. There is the possibility to put only a link to the image file by using the 'MIME type' "-->" and having a complete URL instead of picture data. The use of linked files should however be used sparingly since there is the risk of separation of files.

<Header for 'Attached picture', ID: "APIC">
Text encoding $xx
MIME type <text string> $00
Picture type $xx
Description <text string according to encoding> $00 (00)
Picture data <binary data>

Picture type: $00 Other
$01 32x32 pixels 'file icon' (PNG only)
$02 Other file icon
$03 Cover (front)
$04 Cover (back)
$05 Leaflet page
$06 Media (e.g. lable side of CD)
$07 Lead artist/lead performer/soloist
$08 Artist/performer
$09 Conductor
$0A Band/Orchestra
$0B Composer
$0C Lyricist/text writer
$0D Recording Location
$0E During recording
$0F During performance
$10 Movie/video screen capture
$11 A bright coloured fish
$12 Illustration
$13 Band/artist logotype
$14 Publisher/Studio logotype

For more details, please refer to the ID3 specifications:

author
: Paul Taylor
author
: Eric Farng
version
$Id: FrameBodyAPIC.java 895 2010-04-15 15:21:45Z paultaylor $

Fields Summary
public static final String
IMAGE_IS_URL
Constructors Summary
public FrameBodyAPIC()
Creates a new FrameBodyAPIC datatype.


              
     
    
        //Initilise default text encoding
        setObjectValue(DataTypes.OBJ_TEXT_ENCODING, TextEncoding.ISO_8859_1);
    
public FrameBodyAPIC(FrameBodyAPIC body)

        super(body);
    
public FrameBodyAPIC(FrameBodyPIC body)
Conversion from v2 PIC to v3/v4 APIC

param
body

        this.setObjectValue(DataTypes.OBJ_TEXT_ENCODING, body.getTextEncoding());
        this.setObjectValue(DataTypes.OBJ_MIME_TYPE, ImageFormats.getMimeTypeForFormat((String) body.getObjectValue(DataTypes.OBJ_IMAGE_FORMAT)));
        this.setObjectValue(DataTypes.OBJ_PICTURE_TYPE, body.getObjectValue(DataTypes.OBJ_PICTURE_TYPE));
        this.setObjectValue(DataTypes.OBJ_DESCRIPTION, body.getDescription());
        this.setObjectValue(DataTypes.OBJ_PICTURE_DATA, body.getObjectValue(DataTypes.OBJ_PICTURE_DATA));

    
public FrameBodyAPIC(byte textEncoding, String mimeType, byte pictureType, String description, byte[] data)
Creates a new FrameBodyAPIC datatype.

param
textEncoding
param
mimeType
param
pictureType
param
description
param
data

        this.setObjectValue(DataTypes.OBJ_TEXT_ENCODING, textEncoding);
        this.setMimeType(mimeType);
        this.setPictureType(pictureType);
        this.setDescription(description);
        this.setImageData(data);
    
public FrameBodyAPIC(ByteBuffer byteBuffer, int frameSize)
Creates a new FrameBodyAPIC datatype.

param
byteBuffer
param
frameSize
throws
InvalidTagException if unable to create framebody from buffer

        super(byteBuffer, frameSize);
    
Methods Summary
public java.lang.StringgetDescription()
Get a description of the image

return
a description of the image

        return (String) getObjectValue(DataTypes.OBJ_DESCRIPTION);
    
public java.lang.StringgetIdentifier()
The ID3v2 frame identifier

return
the ID3v2 frame identifier for this frame type

        return ID3v24Frames.FRAME_ID_ATTACHED_PICTURE;
    
public byte[]getImageData()
Get Image data

return

        return (byte[]) getObjectValue(DataTypes.OBJ_PICTURE_DATA);
    
public java.lang.StringgetImageUrl()

return
the image url if there is otherwise return an empty String

        if (isImageUrl())
        {
            return Utils.getString(((byte[]) getObjectValue(DataTypes.OBJ_PICTURE_DATA)), 0, ((byte[]) getObjectValue(DataTypes.OBJ_PICTURE_DATA)).length, TextEncoding.CHARSET_ISO_8859_1);
        }
        else
        {
            return "";
        }
    
public java.lang.StringgetMimeType()
Get mimetype

return
a description of the image

        return (String) getObjectValue(DataTypes.OBJ_MIME_TYPE);
    
public intgetPictureType()

return
picturetype

        return ((Long) getObjectValue(DataTypes.OBJ_PICTURE_TYPE)).intValue();
    
public java.lang.StringgetUserFriendlyValue()

      return getMimeType()+":"+getDescription()+":"+getImageData().length;
    
public booleanisImageUrl()

return
true if imagedata is held as a url rather than actually being imagedata

        return getMimeType() != null && getMimeType().equals(IMAGE_IS_URL);
    
public voidsetDescription(java.lang.String description)
Set a description of the image

param
description

        setObjectValue(DataTypes.OBJ_DESCRIPTION, description);
    
public voidsetImageData(byte[] imageData)
Set imageData

param
imageData

        setObjectValue(DataTypes.OBJ_PICTURE_DATA, imageData);
    
public voidsetMimeType(java.lang.String mimeType)
Set mimeType

param
mimeType

        setObjectValue(DataTypes.OBJ_MIME_TYPE, mimeType);
    
public voidsetPictureType(byte pictureType)
Set Picture Type

param
pictureType

        setObjectValue(DataTypes.OBJ_PICTURE_TYPE, pictureType);
    
protected voidsetupObjectList()

        objectList.add(new NumberHashMap(DataTypes.OBJ_TEXT_ENCODING, this, TextEncoding.TEXT_ENCODING_FIELD_SIZE));
        objectList.add(new StringNullTerminated(DataTypes.OBJ_MIME_TYPE, this));
        objectList.add(new NumberHashMap(DataTypes.OBJ_PICTURE_TYPE, this, PictureTypes.PICTURE_TYPE_FIELD_SIZE));
        objectList.add(new TextEncodedStringNullTerminated(DataTypes.OBJ_DESCRIPTION, this));
        objectList.add(new ByteArraySizeTerminated(DataTypes.OBJ_PICTURE_DATA, this));
    
public voidwrite(java.io.ByteArrayOutputStream tagBuffer)
If the description cannot be encoded using current encoder, change the encoder

        if (!((AbstractString) getObject(DataTypes.OBJ_DESCRIPTION)).canBeEncoded())
        {
            this.setTextEncoding(TextEncoding.UTF_16);
        }
        super.write(tagBuffer);