本文整理汇总了Java中org.jaudiotagger.audio.mp3.MP3File类的典型用法代码示例。如果您正苦于以下问题:Java MP3File类的具体用法?Java MP3File怎么用?Java MP3File使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MP3File类属于org.jaudiotagger.audio.mp3包,在下文中一共展示了MP3File类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStructure
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
public void createStructure()
{
MP3File.getStructureFormatter().openHeadingElement(TYPE_TAG, getIdentifier());
super.createStructureHeader();
//Header
MP3File.getStructureFormatter().openHeadingElement(TYPE_HEADER, "");
MP3File.getStructureFormatter().addElement(TYPE_COMPRESSION, this.compression);
MP3File.getStructureFormatter().addElement(TYPE_UNSYNCHRONISATION, this.unsynchronization);
MP3File.getStructureFormatter().closeHeadingElement(TYPE_HEADER);
//Body
super.createStructureBody();
MP3File.getStructureFormatter().closeHeadingElement(TYPE_TAG);
}
示例2: createStructure
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
/**
* For representing the MP3File in an XML Format
*/
public void createStructure()
{
MP3File.getStructureFormatter().openHeadingElement(TYPE_TAG, getIdentifier());
super.createStructureHeader();
//Header
MP3File.getStructureFormatter().openHeadingElement(TYPE_HEADER, "");
MP3File.getStructureFormatter().addElement(TYPE_UNSYNCHRONISATION, this.isUnsynchronization());
MP3File.getStructureFormatter().addElement(TYPE_EXTENDED, this.extended);
MP3File.getStructureFormatter().addElement(TYPE_EXPERIMENTAL, this.experimental);
MP3File.getStructureFormatter().addElement(TYPE_CRCDATA, this.crc32);
MP3File.getStructureFormatter().addElement(TYPE_PADDINGSIZE, this.paddingSize);
MP3File.getStructureFormatter().closeHeadingElement(TYPE_HEADER);
//Body
super.createStructureBody();
MP3File.getStructureFormatter().closeHeadingElement(TYPE_TAG);
}
示例3: createStructureBody
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
public void createStructureBody()
{
MP3File.getStructureFormatter().openHeadingElement(TYPE_BODY, "");
AbstractID3v2Frame frame;
for (Object o : frameMap.values())
{
if (o instanceof AbstractID3v2Frame)
{
frame = (AbstractID3v2Frame) o;
frame.createStructure();
}
else
{
ArrayList<AbstractID3v2Frame> multiFrames = (ArrayList<AbstractID3v2Frame>) o;
for (ListIterator<AbstractID3v2Frame> li = multiFrames.listIterator(); li.hasNext(); )
{
frame = li.next();
frame.createStructure();
}
}
}
MP3File.getStructureFormatter().closeHeadingElement(TYPE_BODY);
}
示例4: setMP3Tags
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
public static void setMP3Tags(Book book, File bookMP3File, File imageFile) throws Exception {
MP3File mp3file = new MP3File(bookMP3File.getAbsolutePath());
ID3v24Tag tag = new ID3v24Tag();
mp3file.setID3v2Tag(tag);
tag.addField(tag.createField(ID3v24FieldKey.GENRE, book.getGenre()));
tag.addField(tag.createField(ID3v24FieldKey.ARTIST, book.getAuthor()));
tag.addField(tag.createField(ID3v24FieldKey.COMPOSER, book.getNarratedBy()));
tag.addField(tag.createField(ID3v24FieldKey.TITLE, book.getFullTitle()));
tag.addField(tag.createField(ID3v24FieldKey.AMAZON_ID, book.getAsin()));
tag.addField(tag.createField(ID3v24FieldKey.URL_OFFICIAL_RELEASE_SITE, "https://www.audible.com" + book.getInfoLink()));
tag.addField(tag.createField(ID3v24FieldKey.RECORD_LABEL, book.getPublisher()));
tag.addField(tag.createField(ID3v24FieldKey.COMMENT, book.getSummary()));
tag.addField(tag.createField(ID3v24FieldKey.CATALOG_NO, book.getProduct_id()));
tag.addField(tag.createField(ID3v24FieldKey.ENCODER, book.getCopyright()));
tag.addField(tag.createField(ID3v24FieldKey.ALBUM, book.getShortTitle()));
tag.addField(tag.createField(ID3v24FieldKey.YEAR, AudibleUtils.getYear(book)));
if (imageFile.exists()) {
byte imageBytes[] = Files.readAllBytes(Paths.get(imageFile.getAbsolutePath()));
tag.addField(tag.createArtworkField(imageBytes, "image/jpeg"));
}
mp3file.commit();
mp3file.save();
}
示例5: createStructure
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
/**
* For representing the MP3File in an XML Format
*/
public void createStructure() {
MP3File.getStructureFormatter().openHeadingElement(TYPE_TAG, getIdentifier());
super.createStructureHeader();
//Header
MP3File.getStructureFormatter().openHeadingElement(TYPE_HEADER, "");
MP3File.getStructureFormatter().addElement(TYPE_UNSYNCHRONISATION, this.isUnsynchronization());
MP3File.getStructureFormatter().addElement(TYPE_EXTENDED, this.extended);
MP3File.getStructureFormatter().addElement(TYPE_EXPERIMENTAL, this.experimental);
MP3File.getStructureFormatter().addElement(TYPE_CRCDATA, this.crc32);
MP3File.getStructureFormatter().addElement(TYPE_PADDINGSIZE, this.paddingSize);
MP3File.getStructureFormatter().closeHeadingElement(TYPE_HEADER);
//Body
super.createStructureBody();
MP3File.getStructureFormatter().closeHeadingElement(TYPE_TAG);
}
示例6: createStructureBody
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
public void createStructureBody() {
MP3File.getStructureFormatter().openHeadingElement(TYPE_BODY, "");
AbstractID3v2Frame frame;
for (Object o : frameMap.values()) {
if (o instanceof AbstractID3v2Frame) {
frame = (AbstractID3v2Frame) o;
frame.createStructure();
} else {
ArrayList<AbstractID3v2Frame> multiFrames = (ArrayList<AbstractID3v2Frame>) o;
for (ListIterator<AbstractID3v2Frame> li = multiFrames.listIterator(); li.hasNext(); ) {
frame = li.next();
frame.createStructure();
}
}
}
MP3File.getStructureFormatter().closeHeadingElement(TYPE_BODY);
}
示例7: main
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
public static void main(final String[] args) {
ExtractID3TagFromFile test = new ExtractID3TagFromFile();
if (args.length != 2) {
System.err.println("usage ExtractID3TagFromFile Filename FilenameOut");
System.err.println(" You must enter the file to extract the tag from and where to extract to");
System.exit(1);
}
File file = new File(args[0]);
File outFile = new File(args[1]);
if (!file.isFile()) {
System.err.println("usage ExtractID3TagFromFile Filename FilenameOut");
System.err.println(" File " + args[0] + " could not be found");
System.exit(1);
}
try {
final MP3File tmpMP3 = new MP3File(file);
tmpMP3.extractID3v2TagDataIntoFile(outFile);
} catch (Exception e) {
System.err.println("Unable to extract tag");
System.exit(1);
}
}
示例8: getMp3Info
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
/**
* 获取mp3信息
*
* @return
*/
public Mp3Info getMp3Info() {
if (this.mp3Info == null) {
try {
MP3File mp3 = new MP3File(this.mSourceMp3File);
ID3v1Tag v1 = mp3.getID3v1Tag();
String encoding = v1.getEncoding();
MP3AudioHeader header = (MP3AudioHeader) mp3.getAudioHeader();
this.mp3Info = new Mp3Info();
this.mp3Info.setTitle(StringUtil.convertEncode(v1.getFirst(FieldKey.TITLE), encoding));
this.mp3Info.setArtist(StringUtil.convertEncode(v1.getFirst(FieldKey.ARTIST), encoding));
this.mp3Info.setAlbum(StringUtil.convertEncode(v1.getFirst(FieldKey.ALBUM), encoding));
this.mp3Info.setTrackLength(header.getTrackLength());
this.mp3Info.setBiteRate(header.getBitRate());
} catch (Exception e) {
e.printStackTrace();
}
}
return this.mp3Info;
}
示例9: createStructure
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
public void createStructure() {
MP3File.getStructureFormatter().openHeadingElement(TYPE_TAG, getIdentifier());
super.createStructureHeader();
//Header
MP3File.getStructureFormatter().openHeadingElement(TYPE_HEADER, "");
MP3File.getStructureFormatter().addElement(TYPE_UNSYNCHRONISATION, this.isUnsynchronization());
MP3File.getStructureFormatter().addElement(TYPE_EXTENDED, this.extended);
MP3File.getStructureFormatter().addElement(TYPE_EXPERIMENTAL, this.experimental);
MP3File.getStructureFormatter().addElement(TYPE_CRCDATA, this.crc32);
MP3File.getStructureFormatter().addElement(TYPE_PADDINGSIZE, this.paddingSize);
MP3File.getStructureFormatter().closeHeadingElement(TYPE_HEADER);
//Body
super.createStructureBody();
MP3File.getStructureFormatter().closeHeadingElement(TYPE_TAG);
}
示例10: createStructureBody
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
public void createStructureBody() {
MP3File.getStructureFormatter().openHeadingElement(TYPE_BODY, "");
AbstractID3v2Frame frame;
for (Object o : frameMap.values()) {
if (o instanceof AbstractID3v2Frame) {
frame = (AbstractID3v2Frame) o;
frame.createStructure();
} else {
ArrayList<AbstractID3v2Frame> multiFrames = (ArrayList<AbstractID3v2Frame>) o;
for (AbstractID3v2Frame multiFrame : multiFrames) {
frame = multiFrame;
frame.createStructure();
}
}
}
MP3File.getStructureFormatter().closeHeadingElement(TYPE_BODY);
}
示例11: readFileData
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
/**
* Read the contents of the file.
*/
private void readFileData() {
try {
AudioFile audioFile = AudioFileIO.read(m_file);
Tag tag = audioFile.getTag();
if (tag == null) {
tag = fillEmptyTag(audioFile);
}
parseTags(tag);
MP3File mp3File = new MP3File(m_file);
m_length = mp3File.getMP3AudioHeader().getPreciseTrackLength();
m_frames = mp3File.getMP3AudioHeader().getNumberOfFrames();
} catch (Exception e) {
e.printStackTrace(); //for now
}
}
示例12: readBPMFrom
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
@Override
public Integer readBPMFrom(File file) {
try {
MP3File f = (MP3File) AudioFileIO.read(file);
String bpmTag = "";
if (f.hasID3v2Tag()) {
ID3v24Tag tag = f.getID3v2TagAsv24();
bpmTag = tag.getFirst(ID3v24FieldKey.BPM);
if (!bpmTag.equals("")) {
return Integer.valueOf(bpmTag);
}
}
} catch (Exception e) {
// nop
}
return null;
}
示例13: createStructure
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
public void createStructure()
{
MP3File.getStructureFormatter().openHeadingElement(TYPE_TAG, getIdentifier());
//Header
MP3File.getStructureFormatter().addElement(TYPE_TITLE, this.title);
MP3File.getStructureFormatter().addElement(TYPE_ARTIST, this.artist);
MP3File.getStructureFormatter().addElement(TYPE_ALBUM, this.album);
MP3File.getStructureFormatter().addElement(TYPE_YEAR, this.year);
MP3File.getStructureFormatter().addElement(TYPE_COMMENT, this.comment);
MP3File.getStructureFormatter().addElement(TYPE_TRACK, this.track);
MP3File.getStructureFormatter().addElement(TYPE_GENRE, this.genre);
MP3File.getStructureFormatter().closeHeadingElement(TYPE_TAG);
}
示例14: createStructure
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
public void createStructure()
{
MP3File.getStructureFormatter().openHeadingElement(TYPE_FLAGS, "");
MP3File.getStructureFormatter().addElement(TYPE_TAGALTERPRESERVATION, originalFlags & MASK_TAG_ALTER_PRESERVATION);
MP3File.getStructureFormatter().addElement(TYPE_FILEALTERPRESERVATION, originalFlags & MASK_FILE_ALTER_PRESERVATION);
MP3File.getStructureFormatter().addElement(TYPE_READONLY, originalFlags & MASK_READ_ONLY);
MP3File.getStructureFormatter().closeHeadingElement(TYPE_FLAGS);
}
示例15: createStructure
import org.jaudiotagger.audio.mp3.MP3File; //导入依赖的package包/类
/**
* Return String Representation of body
*/
public void createStructure()
{
MP3File.getStructureFormatter().openHeadingElement(TYPE_FRAME, getIdentifier());
MP3File.getStructureFormatter().addElement(TYPE_FRAME_SIZE, frameSize);
frameBody.createStructure();
MP3File.getStructureFormatter().closeHeadingElement(TYPE_FRAME);
}