package org.farng.mp3.id3;
import org.farng.mp3.InvalidTagException;
import org.farng.mp3.object.ObjectByteArraySizeTerminated;
import org.farng.mp3.object.ObjectNumberHashMap;
import org.farng.mp3.object.ObjectStringNullTerminated;
import java.io.IOException;
import java.io.RandomAccessFile;
/**
* <h3>4.14. Attached picture</h3>
* <p/>
* <p> This frame contains a picture directly related to the audio file.<br> Image format is
* the MIME type and subtype [MIME] for the image. In<br> the event that the MIME media type name is
* omitted, "image/" will be<br>
* <p/>
* implied. The "image/png" [PNG] or "image/jpeg" [JFIF] picture format<br>
* should be used when interoperability is wanted. Description is a<br> short description of
* the picture, represented as a terminated<br>
* <p/>
* text string. There may be several pictures attached to one file, each<br> in their
* individual "APIC" frame, but only one with the same content<br> descriptor. There may only be
* one picture with the picture type<br> declared as picture type $01 and $02 respectively. There is
* the<br>
* <p/>
* possibility to put only a link to the image file by using the 'MIME<br> type'
* "-->" and having a complete URL [URL] instead of picture data.<br> The use of linked files
* should however be used sparingly since there<br> is the risk of separation of files.</p>
* <p/>
* <p> <Header for 'Attached picture', ID: "APIC"><br>
* Text encoding $xx<br> MIME
* type <text string>
* <p/>
* $00<br> Picture type $xx<br>
* Description <text string according to encoding> $00 (00)<br>
* <p/>
* Picture data <binary data><br> </p>
* <p/>
* <p> Picture type: $00 Other<br>
* <p/>
* $01 32x32 pixels 'file icon' (PNG only)<br>
* $02 Other file icon<br>
* $03 Cover (front)<br>
* <p/>
* $04
* Cover (back)<br>
* $05 Leaflet page<br>
* $06 Media (e.g. label side of CD)<br>
* <p/>
* $07 Lead
* artist/lead performer/soloist<br>
* $08 Artist/performer<br>
* $09 Conductor<br>
* <p/>
* $0A
* Band/Orchestra<br>
* $0B Composer<br>
* $0C Lyricist/text writer<br>
* <p/>
* $0D
* Recording Location<br>
* $0E During recording<br>
* $0F During performance<br>
* <p/>
* $10
* Movie/video screen capture<br>
* $11 A bright coloured fish<br>
* $12 Illustration<br>
* <p/>
* $13
* Band/artist logotype<br>
* $14 Publisher/Studio logotype<br> </p>
*
* @author Eric Farng
* @version $Revision: 1.4 $
*/
public class FrameBodyAPIC extends AbstractID3v2FrameBody {
/**
* Creates a new FrameBodyAPIC object.
*/
public FrameBodyAPIC() {
super();
}
/**
* Creates a new FrameBodyAPIC object.
*/
public FrameBodyAPIC(final FrameBodyAPIC body) {
super(body);
}
/**
* Creates a new FrameBodyAPIC object.
*/
public FrameBodyAPIC(final byte textEncoding,
final String mimeType,
final byte pictureType,
final String description,
final byte[] data) {
super();
setObject("Text Encoding", new Byte(textEncoding));
setObject("MIME Type", mimeType);
setObject("Picture Type", new Byte(pictureType));
setObject("Description", description);
setObject("Picture Data", data);
}
/**
* Creates a new FrameBodyAPIC object.
*/
public FrameBodyAPIC(final RandomAccessFile file) throws IOException, InvalidTagException {
super();
read(file);
}
public void setDescription(final String description) {
setObject("Description", description);
}
public String getDescription() {
return (String) getObject("Description");
}
public String getIdentifier() {
return "APIC" + (char) 0 + getDescription();
}
protected void setupObjectList() {
appendToObjectList(new ObjectNumberHashMap("Text Encoding", 1));
appendToObjectList(new ObjectStringNullTerminated("MIME Type"));
appendToObjectList(new ObjectStringNullTerminated("Description"));
appendToObjectList(new ObjectByteArraySizeTerminated("Picture Data"));
}
}