简体   繁体   English

android中的mp3标头阅读问题

[英]mp3 header reading problem in android

hi i am doing a program for reading mp3 header. 嗨,我正在做一个程序,用于读取mp3标头。 i get reading source code from the site . 我从网站上读取源代码。 if aware of this site or mp3 header reading. 如果知道此站点或mp3标头阅读。 please help me. 请帮我。

code is: 代码是:

    File oSourceFile = new File("D:\\Mp3\\a.mp3");

    // create an MP3File object representing our chosen file
    MediaFile oMediaFile = new MP3File(oSourceFile);

    // any tags read from the file are returned, in an array, in an order which you should not assume
    ID3Tag[] aoID3Tag = oMediaFile.getTags();
    // let's loop through and see what we've got
    // (NOTE:  we could also use getID3V1Tag() or getID3V2Tag() methods, if we specifically want one or the other)
    for (int i=0; i < aoID3Tag.length; i++)
    {
        // check to see if we read a v1.0 tag, or a v2.3.0 tag (just for example..)
        if (aoID3Tag[i] instanceof ID3V1_0Tag)
        {
            ID3V1_0Tag oID3V1_0Tag = (ID3V1_0Tag)aoID3Tag[i];
            // does this tag happen to contain a title?
            if (oID3V1_0Tag.getTitle() != null)
            {
                System.out.println("Title = " + oID3V1_0Tag.getTitle());
            }
            // etc.
        }
        else if (aoID3Tag[i] instanceof ID3V2_3_0Tag)
        {
            ID3V2_3_0Tag oID3V2_3_0Tag = (ID3V2_3_0Tag)aoID3Tag[i];
            // check if this v2.3.0 frame contains a title, using the actual frame name
            if (oID3V2_3_0Tag.getTIT2TextInformationFrame() != null)
            {
                System.out.println("Title = " + oID3V2_3_0Tag.getTIT2TextInformationFrame().getTitle());
            }
            // but check using the convenience method if it has a year set (either way works)
            try
            {
                System.out.println("Year = " + oID3V2_3_0Tag.getYear());  // reads TYER frame
            }
            catch (ID3Exception e)
            {
                // error getting year.. if one wasn't set
                System.out.println("Could get read year from tag: " + e.toString());
            }
            // etc.
        }
    }

run the code i get java.lang.NoClassDefFoundError: 运行我得到java.lang.NoClassDefFoundError的代码:

my console output: 我的控制台输出:

  Exception in thread "main" java.lang.NoClassDefFoundError: junit/framework/TestCase
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at org.blinkenlights.jid3.test.ID3Test.testWriteV1_0Tag(ID3Test.java:60)
at org.blinkenlights.jid3.test.ID3Test.main(ID3Test.java:46)
    Caused by: java.lang.ClassNotFoundException: junit.framework.TestCase
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
     --- testWriteV1_0Tag ---

at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 14 more

It looks like testWriteV1_0Tag depends on JUnit , which isn't in your classpath. 看起来testWriteV1_0Tag依赖于JUnit ,它不在您的类路径中。 Either change your code so it's not using JUnit (and not depending on anything else which uses JUnit) or include JUnit in your path. 要么更改您的代码,使其使用JUnit(并且不依赖于其他使用JUnit的东西),要么在您的路径中包含JUnit。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM