本文介绍了使用 mp3agic 更改专辑名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想遍历一个包含 .mp3 文件的文件夹,并使用 mp3agic.

I wanted to loop through a folder containig .mp3 files and changing their album names (if they don't have one) to their title (e.g. Remix.mp3 with Title "Remix" gets the Album "Remix") using mp3agic.

这是我目前的代码:

if (mp3file.hasId3v1Tag()) {
    ID3v1 id3v1Tag = mp3file.getId3v1Tag();

    try {
        if (id3v1Tag.getAlbum().equals("")) {
            id3v1Tag.setAlbum(id3v1Tag.getTitle());
            mp3file.save(SAVE_DIR + "\\" + child.getName());
            System.out.println(SAVE_DIR + "/" + child.getName());
        } else {
            mp3file.save(SAVE_DIR + "/" + child.getName());
        }
    } catch (Exception e) {
        mp3file.save(SAVE_DIR + "/" + child.getName());
    }
}

我收到以下错误:

线程main"com.mpatric.mp3agic.NotSupportedException 中的异常:不支持打包过时的帧在 com.mpatric.mp3agic.ID3v2ObseleteFrame.packFrame(ID3v2ObseleteFrame.java:32)在 com.mpatric.mp3agic.ID3v2Frame.toBytes(ID3v2Frame.java:83)在 com.mpatric.mp3agic.AbstractID3v2Tag.packSpecifiedFrames(AbstractID3v2Tag.java:275)在 com.mpatric.mp3agic.AbstractID3v2Tag.packFrames(AbstractID3v2Tag.java:261)在 com.mpatric.mp3agic.AbstractID3v2Tag.packTag(AbstractID3v2Tag.java:227)在 com.mpatric.mp3agic.AbstractID3v2Tag.toBytes(AbstractID3v2Tag.java:218)在 com.mpatric.mp3agic.Mp3File.save(Mp3File.java:450)在 de.thejetstream.main.Iterator.(Iterator.java:57)在 de.thejetstream.main.Main.main(Main.java:12)

在这个文件中:

名称:黑色和黄色感觉很好.mp3

title: Feel Good in Black and Yellow (feat. Gorillaz & De La Soul)

title: Feel Good in Black and Yellow (feat. Gorillaz & De La Soul)

专辑:Black and Yellow - Single

album: Black and Yellow - Single

它在第 57 行崩溃,这等于最后一次保存(在捕获中).

It crashes at line 57, which equals to the last save (in the catch).

这段代码有什么问题?仅仅是因为文件使用了旧的编解码器或类似的东西吗?

What is the problem with this code? Is it just because the file uses an old kind of codec or something like this?

推荐答案

我找到了解决方案:

问题是这些文件使用了 ip3v2 标签而不是 ip3v1.只需检查其上的哪个并相应地调整代码即可解决所有问题.

The problem was that these files used ip3v2 tags instead of ip3v1. Simply checking which on it is and adjusting the code accordingly solved everything.

这篇关于使用 mp3agic 更改专辑名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 20:38