org.farng.mp3.id3.FrameBodyAPIC Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jid3lib Show documentation
Show all versions of jid3lib Show documentation
This library reads song information, such as song title, artist, and album, from an MP3 file. It supports ID3v1, ID3v1.1, Lyrics3v1, Lyrics3v2, ID3v2.2, ID3v2.3, and ID3v2.4 tags. MP3 Frame Headers can also be read. There is a FilenameTag, a ID3v2.4 tag that is intelligently derived from the file name. It contains tag synchronization utilities, multiple save options, and easy tag conversion methods.
The newest version!
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;
/**
* 4.14. Attached picture
*
* This frame contains a picture directly related to the audio file.
Image format is
* the MIME type and subtype [MIME] for the image. In
the event that the MIME media type name is
* omitted, "image/" will be
*
* implied. The "image/png" [PNG] or "image/jpeg" [JFIF] picture format
* should be used when interoperability is wanted. Description is a
short description of
* the picture, represented as a terminated
*
* text string. 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 [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. label 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
*
* @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"));
}
}