jaudiotagger POPULARIMETER tag



我正在迁移我的应用程序从使用org.blinkenlights。Jid3到jaudiotagger。我已经成功地实现了大多数的mp3标签,但我挣扎与POPM标签。我正试图通过获取框架来读取POPM。这似乎是正确的方法,因为代码识别了三个方法

(Long irating = popmframe.getRating();
Long cnt = popmframe.getCounter();
String mail = popmframe.getEmailToUser()). 

我应该在括号FrameBodyPOPM popmframe = id3v24tag中添加什么?getFrame();。使用JID3,我得到了如下结果:

try {
                ID3V2_3_0Tag ID3V2_3_0Tag =     (org.blinkenlights.jid3.v2.ID3V2_3_0Tag) MediaFile.getID3V2Tag();
                if (null != ID3V2_3_0Tag) {
                    for (int i = 0; i < ID3V2_3_0Tag.getPOPMFrames().length; i++) {
                        if (ID3V2_3_0Tag.getPOPMFrames()[i] != null) {
                            rating = ID3V2_3_0Tag.getPOPMFrames()[i].getPopularity();
                            break;
                        }
                    }
                }
                rating = rating / 50;
            } catch (ID3Exception e) {
                e.printStackTrace();
            }
到目前为止,我有以下代码:
          try {
        MP3File musicFile = (MP3File) AudioFileIO.read(SourceFile);
        if (musicFile != null && musicFile.hasID3v2Tag()) {
            ID3v24Tag id3v24tag = musicFile.getID3v2TagAsv24();
            FrameBodyPOPM popmframe = id3v24tag.getFrame(??????);
            Long irating = popmframe.getRating();
            Long cnt = popmframe.getCounter();
            String mail = popmframe.getEmailToUser();
        }
    } catch (CannotReadException | IOException | TagException
            | ReadOnlyFileException | InvalidAudioFrameException e5) {
        throw e5;
    }

对于问号,它报告字符串,但当我输入一个字符串,如"POPM",它报告需要:org.jaudiotagger.tag.id3.framebody FramebodyPOPM, found java.lang.Object

谁可以展示如何读取和写入POPM标签使用jaudiotagger库?

update:我认为该值应该是一个帧标识符,所以

FrameBodyPOPM popmframe = (FrameBodyPOPM) id3v24tag.getFrame(ID3v24Frames.FRAME_ID_POPULARIMETER);

可以编译,但会导致错误:

java.lang.ClassCastException: org.jaudiotagger.tag.id3.ID3v24Frame cannot be cast to org.jaudiotagger.tag.id3.framebody.FrameBodyPOPM

但是如果我使popmframe为ID3v24Frame,则这3种方法不再可用,因此我认为FrameBodyPOPM是正确的方法。

已解决问题。下面的代码按预期工作:

         try {
        MP3File musicFile = (MP3File) AudioFileIO.read(SourceFile);
        if (musicFile != null && musicFile.hasID3v2Tag()) {
            ID3v23Frame frame = (ID3v23Frame) musicFile.getID3v2Tag().getFrame(ID3v24Frames.FRAME_ID_POPULARIMETER);
            FrameBodyPOPM body = (FrameBodyPOPM) frame.getBody();
            String mail = body.getEmailToUser();
            Long irating = body.getRating();
            Long cnt = body.getCounter();
        }
    } catch (CannotReadException | IOException | TagException
            | ReadOnlyFileException | InvalidAudioFrameException e5) {
        throw e5;
    }

相关内容

  • 没有找到相关文章

最新更新