• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AbstractID3v2Tag类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getTagAndConvertOrCreateAndSetDefault

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
/**
 * Get the tag and convert to the default tag version or if the file doesn't have one at all, create a default tag
 * set as tag for this file
 *
 * Conversions are currently only necessary/available for formats that support ID3
 *
 * @return
 */
public Tag getTagAndConvertOrCreateAndSetDefault()
{
    Tag tag = getTagOrCreateDefault();

    /* TODO Currently only works for Dsf We need additional check here for Wav and Aif because they wrap the ID3 tag so never return
     * null for getTag() and the wrapper stores the location of the existing tag, would that be broken if tag set to something else
     */
    if(tag instanceof AbstractID3v2Tag)
    {
        Tag convertedTag = convertID3Tag((AbstractID3v2Tag)tag, TagOptionSingleton.getInstance().getID3V2Version());
        if(convertedTag!=null)
        {
            setTag(convertedTag);
        }
        else
        {
            setTag(tag);
        }
    }
    else
    {
        setTag(tag);
    }
    return getTag();
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:34,代码来源:AudioFile.java


示例2: getMP3StartByte

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
/**
 * Used by tags when writing to calculate the location of the music file
 *
 * @param file
 * @return the location within the file that the audio starts
 * @throws java.io.IOException
 * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
 */
public long getMP3StartByte(File file) throws InvalidAudioFrameException, IOException {
    try {
        //Read ID3v2 tag size (if tag exists) to allow audio header parsing to skip over tag
        long startByte = AbstractID3v2Tag.getV2TagSizeIfExists(file);

        MP3AudioHeader audioHeader = new MP3AudioHeader(file, startByte);
        if (startByte != audioHeader.getMp3StartByte()) {
            logger.config("First header found after tag:" + audioHeader);
            audioHeader = checkAudioStart(startByte, audioHeader);
        }
        return audioHeader.getMp3StartByte();
    } catch (InvalidAudioFrameException iafe) {
        throw iafe;
    } catch (IOException ioe) {
        throw ioe;
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:26,代码来源:MP3File.java


示例3: readTag

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的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: getMP3StartByte

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
@SuppressWarnings("TryWithIdenticalCatches")
public long getMP3StartByte(File file) throws InvalidAudioFrameException, IOException {
    //noinspection CaughtExceptionImmediatelyRethrown,CaughtExceptionImmediatelyRethrown
    try {
        //Read ID3v2 tag size (if tag exists) to allow audio header parsing to skip over tag
        long startByte = AbstractID3v2Tag.getV2TagSizeIfExists(file);

        MP3AudioHeader audioHeader = new MP3AudioHeader(file, startByte);
        if (startByte != audioHeader.getMp3StartByte()) {
            logger.config("First header found after tag:" + audioHeader);
            audioHeader = checkAudioStart(startByte, audioHeader);
        }
        return audioHeader.getMp3StartByte();
    } catch (InvalidAudioFrameException iafe) {
        throw iafe;
    } catch (IOException ioe) {
        throw ioe;
    }
}
 
开发者ID:Old-Geek,项目名称:Musique,代码行数:20,代码来源:MP3File.java


示例5: isId3v2Tag

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
/**
 * Reads 3 bytes to determine if the tag really looks like ID3 data.
 */
private boolean isId3v2Tag(final ByteBuffer headerData) throws IOException
{
    for (int i = 0; i < AbstractID3v2Tag.FIELD_TAGID_LENGTH; i++)
    {
        if (headerData.get() != AbstractID3v2Tag.TAG_ID[i])
        {
            return false;
        }
    }
    return true;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:15,代码来源:ID3Chunk.java


示例6: read

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
/**
 * Read next PageHeader from file
 * @param raf
 * @return
 * @throws IOException
 * @throws CannotReadException
 */
public static OggPageHeader read(RandomAccessFile raf) throws IOException, CannotReadException
{
    long start = raf.getFilePointer();
    logger.fine("Trying to read OggPage at:" + start);

    byte[] b = new byte[OggPageHeader.CAPTURE_PATTERN.length];
    raf.read(b);
    if (!(Arrays.equals(b, OggPageHeader.CAPTURE_PATTERN)))
    {
        raf.seek(start);
        if(AbstractID3v2Tag.isId3Tag(raf))
        {
            logger.warning(ErrorMessage.OGG_CONTAINS_ID3TAG.getMsg(raf.getFilePointer() - start));
            raf.read(b);
            if ((Arrays.equals(b, OggPageHeader.CAPTURE_PATTERN)))
            {
                //Go to the end of the ID3 header
                start=raf.getFilePointer() - OggPageHeader.CAPTURE_PATTERN.length;
            }
        }
        else
        {
            throw new CannotReadException(ErrorMessage.OGG_HEADER_CANNOT_BE_FOUND.getMsg(new String(b)));
        }
    }

    raf.seek(start + OggPageHeader.FIELD_PAGE_SEGMENTS_POS);
    int pageSegments = raf.readByte() & 0xFF; //unsigned
    raf.seek(start);

    b = new byte[OggPageHeader.OGG_PAGE_HEADER_FIXED_LENGTH + pageSegments];
    raf.read(b);


    OggPageHeader pageHeader = new OggPageHeader(b);
    pageHeader.setStartByte(start);
    //Now just after PageHeader, ready for Packet Data
    return pageHeader;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:47,代码来源:OggPageHeader.java


示例7: readTag

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的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


示例8: setID3v2Tag

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的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


示例9: delete

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
/**
 * Remove tag from file
 *
 * @param mp3tag
 * @throws FileNotFoundException
 * @throws IOException
 */
public void delete(AbstractTag mp3tag) throws FileNotFoundException, IOException {
    RandomAccessFile raf = new RandomAccessFile(this.file, "rw");
    mp3tag.delete(raf);
    raf.close();
    if (mp3tag instanceof ID3v1Tag) {
        id3v1tag = null;
    }

    if (mp3tag instanceof AbstractID3v2Tag) {
        id3v2tag = null;
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:20,代码来源:MP3File.java


示例10: setTag

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
/**
 * Set the Tag
 * <p>
 * If the parameter tag is a v1tag then the v1 tag is set if v2tag then the v2tag.
 *
 * @param tag
 */
public void setTag(Tag tag) {
    this.tag = tag;
    if (tag instanceof ID3v1Tag) {
        setID3v1Tag((ID3v1Tag) tag);
    } else {
        setID3v2Tag((AbstractID3v2Tag) tag);
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:16,代码来源:MP3File.java


示例11: getTagAndConvertOrCreateAndSetDefault

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
/**
 * Get the ID3v2 tag and convert to preferred version or if the file doesn't have one at all
 * create a default tag of preferred version and set it. The file may already contain a ID3v1 tag but because
 * this is not terribly useful the v1tag is not considered for this problem.
 *
 * @return
 */
@Override
public Tag getTagAndConvertOrCreateAndSetDefault() {
    Tag tag = getTagOrCreateDefault();
    Tag convertedTag = convertID3Tag((AbstractID3v2Tag) tag, TagOptionSingleton.getInstance().getID3V2Version());
    if (convertedTag != null) {
        setTag(convertedTag);
    } else {
        setTag(tag);
    }
    return getTag();
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:19,代码来源:MP3File.java


示例12: isId3v2Tag

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
private boolean isId3v2Tag() throws IOException
{
    fc.position(0);
    if(AbstractID3v2Tag.isId3Tag(fc))
    {
        logger.warning(loggingName + ErrorMessage.FLAC_CONTAINS_ID3TAG.getMsg(fc.position()));
        //FLAC Stream immediately after end of id3 tag
        if (isFlacHeader())
        {
            return true;
        }
    }
    return false;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:15,代码来源:FlacStreamReader.java


示例13: read

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
/**
 * Read next PageHeader from file
 *
 * @param raf
 * @return
 * @throws IOException
 * @throws CannotReadException
 */
public static OggPageHeader read(RandomAccessFile raf) throws IOException, CannotReadException {
    long start = raf.getFilePointer();
    logger.fine("Trying to read OggPage at:" + start);

    byte[] b = new byte[OggPageHeader.CAPTURE_PATTERN.length];
    raf.read(b);
    if (!(Arrays.equals(b, OggPageHeader.CAPTURE_PATTERN))) {
        raf.seek(start);
        if (AbstractID3v2Tag.isId3Tag(raf)) {
            logger.warning(ErrorMessage.OGG_CONTAINS_ID3TAG.getMsg(raf.getFilePointer() - start));
            raf.read(b);
            if ((Arrays.equals(b, OggPageHeader.CAPTURE_PATTERN))) {
                //Go to the end of the ID3 header
                start = raf.getFilePointer() - OggPageHeader.CAPTURE_PATTERN.length;
            }
        } else {
            throw new CannotReadException(ErrorMessage.OGG_HEADER_CANNOT_BE_FOUND.getMsg(new String(b)));
        }
    }

    raf.seek(start + OggPageHeader.FIELD_PAGE_SEGMENTS_POS);
    int pageSegments = raf.readByte() & 0xFF; //unsigned
    raf.seek(start);

    b = new byte[OggPageHeader.OGG_PAGE_HEADER_FIXED_LENGTH + pageSegments];
    raf.read(b);


    OggPageHeader pageHeader = new OggPageHeader(b);
    pageHeader.setStartByte(start);
    //Now just after PageHeader, ready for Packet Data
    return pageHeader;
}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:42,代码来源:OggPageHeader.java


示例14: isId3v2Tag

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
private boolean isId3v2Tag() throws IOException {
    raf.seek(0);
    if (AbstractID3v2Tag.isId3Tag(raf)) {
        logger.warning(ErrorMessage.FLAC_CONTAINS_ID3TAG.getMsg(raf.getFilePointer()));
        //FLAC Stream immediately after end of id3 tag
        if (isFlacHeader()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:12,代码来源:FlacStreamReader.java


示例15: isId3v2Tag

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
private boolean isId3v2Tag(final ByteBuffer headerData) throws IOException {
    for (int i = 0; i < AbstractID3v2Tag.FIELD_TAGID_LENGTH; i++) {
        if (headerData.get() != AbstractID3v2Tag.TAG_ID[i]) {
            return false;
        }
    }
    return true;
}
 
开发者ID:Old-Geek,项目名称:Musique,代码行数:9,代码来源:ID3Chunk.java


示例16: read

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
public static OggPageHeader read(RandomAccessFile raf) throws IOException, CannotReadException {
    long start = raf.getFilePointer();
    logger.fine("Trying to read OggPage at:" + start);

    byte[] b = new byte[OggPageHeader.CAPTURE_PATTERN.length];
    raf.read(b);
    if (!(Arrays.equals(b, OggPageHeader.CAPTURE_PATTERN))) {
        raf.seek(start);
        if (AbstractID3v2Tag.isId3Tag(raf)) {
            logger.warning(ErrorMessage.OGG_CONTAINS_ID3TAG.getMsg(raf.getFilePointer() - start));
            raf.read(b);
            if ((Arrays.equals(b, OggPageHeader.CAPTURE_PATTERN))) {
                //Go to the end of the ID3 header
                start = raf.getFilePointer() - OggPageHeader.CAPTURE_PATTERN.length;
            }
        } else {
            throw new CannotReadException(ErrorMessage.OGG_HEADER_CANNOT_BE_FOUND.getMsg(new String(b)));
        }
    }

    raf.seek(start + OggPageHeader.FIELD_PAGE_SEGMENTS_POS);
    int pageSegments = raf.readByte() & 0xFF; //unsigned
    raf.seek(start);

    b = new byte[OggPageHeader.OGG_PAGE_HEADER_FIXED_LENGTH + pageSegments];
    raf.read(b);


    OggPageHeader pageHeader = new OggPageHeader(b);
    pageHeader.setStartByte(start);
    //Now just after PageHeader, ready for Packet Data
    return pageHeader;
}
 
开发者ID:Old-Geek,项目名称:Musique,代码行数:34,代码来源:OggPageHeader.java


示例17: MP3File

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
public MP3File(File file, int loadOptions, boolean readOnly) throws IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException {
    RandomAccessFile newFile = null;
    try {
        this.file = file;

        //Check File accessibility
        newFile = checkFilePermissions(file, readOnly);

        //Read ID3v2 tag size (if tag exists) to allow audioHeader parsing to skip over tag
        long tagSizeReportedByHeader = AbstractID3v2Tag.getV2TagSizeIfExists(file);
        logger.config("TagHeaderSize:" + Hex.asHex(tagSizeReportedByHeader));
        audioHeader = new MP3AudioHeader(file, tagSizeReportedByHeader);

        //If the audio header is not straight after the end of the tag then search from start of file
        if (tagSizeReportedByHeader != ((MP3AudioHeader) audioHeader).getMp3StartByte()) {
            logger.config("First header found after tag:" + audioHeader);
            audioHeader = checkAudioStart(tagSizeReportedByHeader, (MP3AudioHeader) audioHeader);
        }

        //Read v1 tags (if any)
        readV1Tag(file, newFile, loadOptions);

        //Read v2 tags (if any)
        readV2Tag(file, loadOptions, (int) ((MP3AudioHeader) audioHeader).getMp3StartByte());

        //If we have a v2 tag use that, if we do not but have v1 tag use that
        //otherwise use nothing
        //TODO:if have both should we merge
        //rather than just returning specific ID3v22 tag, would it be better to return v24 version ?
        if (this.getID3v2Tag() != null) {
            tag = this.getID3v2Tag();
        } else if (id3v1tag != null) {
            tag = id3v1tag;
        }
    } finally {
        if (newFile != null) {
            newFile.close();
        }
    }
}
 
开发者ID:Old-Geek,项目名称:Musique,代码行数:41,代码来源:MP3File.java


示例18: setID3v2Tag

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
public void setID3v2Tag(AbstractID3v2Tag id3v2tag) {
    this.id3v2tag = id3v2tag;
    if (id3v2tag instanceof ID3v24Tag) {
        this.id3v2Asv24tag = (ID3v24Tag) this.id3v2tag;
    } else {
        this.id3v2Asv24tag = new ID3v24Tag(id3v2tag);
    }
}
 
开发者ID:Old-Geek,项目名称:Musique,代码行数:9,代码来源:MP3File.java


示例19: delete

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
public void delete(AbstractTag mp3tag) throws FileNotFoundException, IOException {
    RandomAccessFile raf = new RandomAccessFile(this.file, "rw");
    mp3tag.delete(raf);
    raf.close();
    if (mp3tag instanceof ID3v1Tag) {
        id3v1tag = null;
    }

    if (mp3tag instanceof AbstractID3v2Tag) {
        id3v2tag = null;
    }
}
 
开发者ID:Old-Geek,项目名称:Musique,代码行数:13,代码来源:MP3File.java


示例20: setTag

import org.jaudiotagger.tag.id3.AbstractID3v2Tag; //导入依赖的package包/类
public void setTag(Tag tag) {
    this.tag = tag;
    if (tag instanceof ID3v1Tag) {
        setID3v1Tag((ID3v1Tag) tag);
    } else {
        setID3v2Tag((AbstractID3v2Tag) tag);
    }
}
 
开发者ID:Old-Geek,项目名称:Musique,代码行数:9,代码来源:MP3File.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EMTextMessageBody类代码示例发布时间:2022-05-22
下一篇:
Java FirebaseFirestore类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap