当前位置: 首页>>代码示例>>Java>>正文


Java ID3v24Tag类代码示例

本文整理汇总了Java中org.jaudiotagger.tag.id3.ID3v24Tag的典型用法代码示例。如果您正苦于以下问题:Java ID3v24Tag类的具体用法?Java ID3v24Tag怎么用?Java ID3v24Tag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ID3v24Tag类属于org.jaudiotagger.tag.id3包,在下文中一共展示了ID3v24Tag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDefaultTag

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
public static Tag createDefaultTag()
{
    if(TagOptionSingleton.getInstance().getID3V2Version()== ID3V2Version.ID3_V24)
    {
        return new ID3v24Tag();
    }
    else if(TagOptionSingleton.getInstance().getID3V2Version()==ID3V2Version.ID3_V23)
    {
        return new ID3v23Tag();
    }
    else if(TagOptionSingleton.getInstance().getID3V2Version()==ID3V2Version.ID3_V22)
    {
        return new ID3v22Tag();
    }
    //Default in case not set somehow
    return new ID3v24Tag();
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:18,代码来源:Dsf.java

示例2: setMP3Tags

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的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();
}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:27,代码来源:TagMP3AudioBook.java

示例3: readTag

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
private Tag readTag(RandomAccessFile file, long tagOffset) throws CannotReadException, IOException {
    //Move to start of ID3Tag and read rest of file into ByteBuffer
    file.seek(tagOffset);
    ByteBuffer tagBuffer = Utils.readFileDataIntoBufferLE(file, (int) (file.length() - file.getFilePointer()));

    //Work out ID3 major version
    int majorVersion = tagBuffer.get(AbstractID3v2Tag.FIELD_TAG_MAJOR_VERSION_POS);
    try {
        logger.log(Level.FINE, "Start creating ID3v2 Tag for version: " + majorVersion);
        switch (majorVersion) {
            case ID3v22Tag.MAJOR_VERSION:
                return new ID3v22Tag(tagBuffer, "");
            case ID3v23Tag.MAJOR_VERSION:
                return new ID3v23Tag(tagBuffer, "");
            case ID3v24Tag.MAJOR_VERSION:
                return new ID3v24Tag(tagBuffer, "");
            default:
                logger.log(Level.WARNING, "Unknown major ID3v2 version " + majorVersion + ". Returning an empty ID3v2 Tag.");
                return new ID3v24Tag();
        }
    } catch (TagException e) {
        throw new CannotReadException("Could not create ID3v2 Tag");
    }
}
 
开发者ID:Old-Geek,项目名称:Musique,代码行数:25,代码来源:DsfAudioFileReader.java

示例4: copyTag

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
/**
 * copy existing tag into a nice new ID3v24Tag tag
 * 
 * @throws FieldDataInvalidException
 */
private static ID3v24Tag copyTag(Tag tag) throws FieldDataInvalidException {
   final ID3v24Tag ret = new ID3v24Tag();
   Iterator<TagField> iter = null;
   try {
      iter = tag.getFields();
   } catch (final UnsupportedOperationException e) {
      // seems like some old tag types don't support iteration
      return null;
   }
   while (iter.hasNext()) {
      final TagField tagField = iter.next();
      ret.setField(tagField);
   }
   return ret;
}
 
开发者ID:teverett,项目名称:musicbrainztagger,代码行数:21,代码来源:ID3.java

示例5: readBPMFrom

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的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;
}
 
开发者ID:nwaldispuehl,项目名称:interval-music-compositor,代码行数:23,代码来源:Mp3BPMReaderWriter.java

示例6: check

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
@Override
public void check(GenericTag genericTag) {
  if (genericTag == null) {
    return;
  }

  /* get the classes of the source tags */
  Set<Class<? extends Object>> sourceTagClasses = genericTag.getSourceTagClasses();
  assert (sourceTagClasses != null);

  if (!sourceTagClasses.contains(ID3v24Tag.class)) {
    return;
  }

  genericTag.addReport(GenericTagFieldName.OTHER, Messages.getString("NoID3v24TagChecker.0"), null, null, null); //$NON-NLS-1$
}
 
开发者ID:fhuberts,项目名称:musicTreePrograms,代码行数:17,代码来源:NoID3v24TagChecker.java

示例7: testMp3TagConverter

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
@Test(timeout = 8000)
public void testMp3TagConverter() {
  Set<Class<? extends Object>> stc = converter.getSupportedTagClasses();

  assertThat(stc, notNullValue());
  assertThat(Integer.valueOf(stc.size()), equalTo(Integer.valueOf(3)));
  assertThat(Boolean.valueOf(stc.contains(ID3v22Tag.class)), equalTo(Boolean.TRUE));
  assertThat(Boolean.valueOf(stc.contains(ID3v23Tag.class)), equalTo(Boolean.TRUE));
  assertThat(Boolean.valueOf(stc.contains(ID3v24Tag.class)), equalTo(Boolean.TRUE));

  Map<Class<? extends Object>, Set<String>> utfns = converter.getUnknownTagFieldNames();
  assertThat(utfns, notNullValue());
  assertThat(Integer.valueOf(utfns.size()), equalTo(Integer.valueOf(3)));
  Set<String> utfns22 = utfns.get(ID3v22Tag.class);
  assertThat(utfns22, notNullValue());
  assertThat(Integer.valueOf(utfns22.size()), equalTo(Integer.valueOf(0)));
  Set<String> utfns23 = utfns.get(ID3v22Tag.class);
  assertThat(utfns23, notNullValue());
  assertThat(Integer.valueOf(utfns23.size()), equalTo(Integer.valueOf(0)));
  Set<String> utfns24 = utfns.get(ID3v22Tag.class);
  assertThat(utfns24, notNullValue());
  assertThat(Integer.valueOf(utfns24.size()), equalTo(Integer.valueOf(0)));
}
 
开发者ID:fhuberts,项目名称:musicTreePrograms,代码行数:24,代码来源:TestMp3TagConverter.java

示例8: readMp3Tag

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
private static AbstractID3Tag readMp3Tag(File flacFile, boolean v24) {
  AudioFile af;
  try {
    af = AudioFileIO.read(flacFile);
  }
  catch (Throwable e) {
    System.err.println(String.format("Failed to read mp3 file", flacFile.getPath()));
    return null;
  }

  Tag tag = af.getTag();
  if (v24) {
    assert (tag instanceof ID3v24Tag);
    return (ID3v24Tag) tag;
  }

  assert (tag instanceof ID3v23Tag);
  return (ID3v23Tag) tag;
}
 
开发者ID:fhuberts,项目名称:musicTreePrograms,代码行数:20,代码来源:TestFlacToMp3Impl.java

示例9: testConvertFromId3V1_Empty_v10

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
@Test(timeout = 8000)
public void testConvertFromId3V1_Empty_v10() {
  ID3v1Tag id3v1Tag = new ID3v1Tag();
  ID3v24Tag id3v24Tag = FlacToMp3Impl.convertFromId3V1(id3v1Tag);

  assertThat(id3v24Tag, notNullValue());

  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.ALBUM), null), equalTo(null));
  /* no FieldKey.ALBUM_ARTIST */
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.ARTIST), null), equalTo(null));
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.YEAR), null), equalTo(null));
  /* no FieldKey.DISC_NO */
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.GENRE), null), equalTo(null));
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.TITLE), null), equalTo(null));
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.TRACK), null), equalTo(null));
  /* no FieldKey.TRACK_TOTAL */
}
 
开发者ID:fhuberts,项目名称:musicTreePrograms,代码行数:18,代码来源:TestFlacToMp3Impl.java

示例10: testConvertFromId3V1_Empty_v11

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
@Test(timeout = 8000)
public void testConvertFromId3V1_Empty_v11() {
  ID3v11Tag id3v1Tag = new ID3v11Tag();
  ID3v24Tag id3v24Tag = FlacToMp3Impl.convertFromId3V1(id3v1Tag);

  assertThat(id3v24Tag, notNullValue());

  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.ALBUM), null), equalTo(null));
  /* no FieldKey.ALBUM_ARTIST */
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.ARTIST), null), equalTo(null));
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.YEAR), null), equalTo(null));
  /* no FieldKey.DISC_NO */
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.GENRE), null), equalTo(null));
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.TITLE), null), equalTo(null));
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.TRACK), null), equalTo(null));
  /* no FieldKey.TRACK_TOTAL */
}
 
开发者ID:fhuberts,项目名称:musicTreePrograms,代码行数:18,代码来源:TestFlacToMp3Impl.java

示例11: testConvertFromId3V1_Random_v10

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
@Test(timeout = 8000)
public void testConvertFromId3V1_Random_v10() throws KeyNotFoundException {
  ID3v1Tag id3v1Tag = TagHelper.getRandomID3v1Tag(true);

  ID3v24Tag id3v24Tag = FlacToMp3Impl.convertFromId3V1(id3v1Tag);

  assertThat(id3v24Tag, notNullValue());

  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.ALBUM), null),
      equalTo("Text=\"" + TagHelper.album + "\"; "));
  /* no FieldKey.ALBUM_ARTIST */
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.ARTIST), null),
      equalTo("Text=\"" + TagHelper.artist + "\"; "));
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.YEAR), null),
      equalTo("Text=\"" + TagHelper.date + "\"; "));
  /* no FieldKey.DISC_NO */
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.GENRE), null),
      equalTo("Text=\"" + TagHelper.genreNumber + "\"; "));
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.TITLE), null),
      equalTo("Text=\"" + TagHelper.title + "\"; "));
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.TRACK), null), equalTo(null));
  /* no FieldKey.TRACK_TOTAL */
}
 
开发者ID:fhuberts,项目名称:musicTreePrograms,代码行数:24,代码来源:TestFlacToMp3Impl.java

示例12: testConvertFromId3V1_Random_v11

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
@Test(timeout = 8000)
public void testConvertFromId3V1_Random_v11() throws KeyNotFoundException {
  ID3v1Tag id3v1Tag = TagHelper.getRandomID3v1Tag(false);

  ID3v24Tag id3v24Tag = FlacToMp3Impl.convertFromId3V1(id3v1Tag);

  assertThat(id3v24Tag, notNullValue());

  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.ALBUM), null),
      equalTo("Text=\"" + TagHelper.album + "\"; "));
  /* no FieldKey.ALBUM_ARTIST */
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.ARTIST), null),
      equalTo("Text=\"" + TagHelper.artist + "\"; "));
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.YEAR), null),
      equalTo("Text=\"" + TagHelper.date + "\"; "));
  /* no FieldKey.DISC_NO */
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.GENRE), null),
      equalTo("Text=\"" + TagHelper.genreNumber + "\"; "));
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.TITLE), null),
      equalTo("Text=\"" + TagHelper.title + "\"; "));
  assertThat(TagUtils.concatenateTagFields(id3v24Tag.getFields(FieldKey.TRACK), null),
      equalTo("Text=\"" + TagHelper.tracknumber + "\"; "));
  /* no FieldKey.TRACK_TOTAL */
}
 
开发者ID:fhuberts,项目名称:musicTreePrograms,代码行数:25,代码来源:TestFlacToMp3Impl.java

示例13: readTag

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
/**
 * Reads the ID3v2 tag starting at the {@code tagOffset} position in the
 * supplied file.
 *
 * @param fc       the filechannel from which to read
 * @param dsd      the dsd chunk
 * @param fileName
 * @return the read tag or an empty tag if something went wrong. Never
 * <code>null</code>.
 * @throws IOException if cannot read file.
 */
private Tag readTag(FileChannel fc, DsdChunk dsd, String fileName) throws CannotReadException, IOException {
    if (dsd.getMetadataOffset() > 0) {
        fc.position(dsd.getMetadataOffset());
        ID3Chunk id3Chunk = ID3Chunk.readChunk(Utils.readFileDataIntoBufferLE(fc, (int) (fc.size() - fc.position())));
        if (id3Chunk != null) {
            int version = id3Chunk.getDataBuffer().get(AbstractID3v2Tag.FIELD_TAG_MAJOR_VERSION_POS);
            try {
                switch (version) {
                    case ID3v22Tag.MAJOR_VERSION:
                        return new ID3v22Tag(id3Chunk.getDataBuffer(), "");
                    case ID3v23Tag.MAJOR_VERSION:
                        return new ID3v23Tag(id3Chunk.getDataBuffer(), "");
                    case ID3v24Tag.MAJOR_VERSION:
                        return new ID3v24Tag(id3Chunk.getDataBuffer(), "");
                    default:
                        logger.log(Level.WARNING, fileName + " Unknown ID3v2 version " + version + ". Returning an empty ID3v2 Tag.");
                        return null;
                }
            } catch (TagException e) {
                throw new CannotReadException(fileName + " Could not read ID3v2 tag:corruption");
            }
        } else {
            logger.log(Level.WARNING, fileName + " No existing ID3 tag(1)");
            return null;
        }
    } else {
        logger.log(Level.WARNING, fileName + " No existing ID3 tag(2)");
        return null;
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:42,代码来源:DsfFileReader.java

示例14: setID3v2Tag

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
/**
 * Sets the v2 tag to the v2 tag provided as an argument.
 * Also store a v24 version of tag as v24 is the interface to be used
 * when talking with client applications.
 *
 * @param id3v2tag
 */
public void setID3v2Tag(AbstractID3v2Tag id3v2tag) {
    this.id3v2tag = id3v2tag;
    if (id3v2tag instanceof ID3v24Tag) {
        this.id3v2Asv24tag = (ID3v24Tag) this.id3v2tag;
    } else {
        this.id3v2Asv24tag = new ID3v24Tag(id3v2tag);
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:16,代码来源:MP3File.java

示例15: createDefaultTag

import org.jaudiotagger.tag.id3.ID3v24Tag; //导入依赖的package包/类
/**
 * Create Default Tag
 *
 * @return
 */
@Override
public Tag createDefaultTag() {
    if (TagOptionSingleton.getInstance().getID3V2Version() == ID3V2Version.ID3_V24) {
        return new ID3v24Tag();
    } else if (TagOptionSingleton.getInstance().getID3V2Version() == ID3V2Version.ID3_V23) {
        return new ID3v23Tag();
    } else if (TagOptionSingleton.getInstance().getID3V2Version() == ID3V2Version.ID3_V22) {
        return new ID3v22Tag();
    }
    //Default in case not set somehow
    return new ID3v24Tag();
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:18,代码来源:MP3File.java


注:本文中的org.jaudiotagger.tag.id3.ID3v24Tag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。