回 帖 发 新 帖 刷新版面

主题:关于读写音乐文件的id3信息

我想做一个音乐管理程序,为此,得读写音乐文件的id3信息,哪位大侠有相关的代码吗,指点一二,跪谢。
    我不懂怎样读写一个指定文件后128字节的信息,请给以详细帮助。

回复列表 (共3个回复)

沙发

我也在写这样一个软件,不过我是用java写的,不过我觉得C#和java都差不多,你说的后128位是ID3V1,但现在的播放器像winamp都只认ID3V2的,我只写好了读取ID3v1和ID3v2的类,写信息的还没写,我在java板块里发了读ID3v2的,ID3V1放在下面了,不过我是放暑假才开始学java的,写的可能不好,多指教啊,我看我们可以相互交流一下,我的qq是:200864110

板凳

import java.io.*;


public class Test {
    public static void main( String[] args ){
        try{
        
        String directory = "文件路径";
        String fileName = "*.mp3";
        File audioInf = new File( directory, fileName );
        RandomAccessFile infIn = new RandomAccessFile(
          audioInf, "rw" );
        infIn.seek(infIn.length() - 128);
        ByteArrayOutputStream bo = new
          ByteArrayOutputStream();
        for( int index = 0; index < 128; index++ ){
               bo.write(infIn.readByte());
        }
        
        String buffer = bo.toString();
        String[] list = new String[ 5 ];
        list[0] = buffer.substring( 0, 3);
        list[1] = buffer.substring( 3, 33);
        list[2] = buffer.substring( 33, 63);
        list[3] = buffer.substring( 63, 93);
        list[4] = buffer.substring( 93, 97);
        
        System.out.println("MP3音频信息:");
             System.out.println( "格式标签:" + list[0]);
             System.out.println( "歌曲名:" + list[1]);
             System.out.println( "作者:" + list[2]);
             System.out.println( "专辑:" + list[3]);
        
        
        System.out.print("\n");        
            }
        catch( FileNotFoundException  e ){
          System.err.println(e);
          return;
        }
        catch ( IOException e ){
          System.err.println(
                    "Error reading input file" + e );
          return;
        }
        
    }
}

3 楼

呵,谢谢啦,我那个程序是写来玩的,这几天忙着别的事情,还没空继续。网上有用delphi写的,问题是不知道在c#里该用哪个函数。有空多交流,我的qq是:116125733,欢迎交流,注“编程爱好者”就可以通过了。或者我上班时再记得加你吧.

我来回复

您尚未登录,请登录后再回复。点此登录或注册