回 帖 发 新 帖 刷新版面

主题:mp3 ID3 读取

mp3的id3信息存放在mp3文件结尾处的128字节处,结构如下:
   type ID3struct =packed record
                              ID:array[0..2] of char
                              title :array[0..29] of char;
                              artist:array[0..29] of char;
                              album:array[0..29} of char;
                              year:array[0..3] of char;
                              comment:array[0..29] of char;
                              genre:byte;
用指针读出相应位置的数据,就可以读出ID3信息:

program showID3;

{$apptype console}

var
    tempfile:file of byte; //tempfile指针,二进制型文件
    i:integer;
    x:byte;
begin
   
    assign(tempfile,'1.mp3');
    reset(tempfile);//文件关联,复位
    seek(tempfile,(filesize(tempfile)-128)); //指针指向距文件结尾128字节处
    
    writeln('ID:');
    for i:=0 to 2 do
        begin
            read(tempfile,x);
            write(chr(x));
        end;
    writeln;
    
    writeln('title:');
    for i:=0 to 29 do
        begin
            read(tempfile,x);
            write(chr(x));
        end;
    writeln;
    
    writeln('artist:');
    for i:=0 to 29 do
        begin
            read(tempfile,x);
            write(chr(x));
        end;
    writeln;
    
    writeln('album:');
    for i:=0 to 29 do
        begin
            read(tempfile,x);
            write(chr(x));
        end;
    writeln;
    
    writeln('year:');
    for i:=0 to 3 do
        begin
            read(tempfile,x);
            write(chr(x));
        end;
    writeln;
    
    writeln('comment:');
    for i:=0 to 29 do
        begin
            read(tempfile,x);
            write(chr(x));
        end;
    writeln;  //用循环的方法依次读出各个字节
    
    close(tempfile);
end.    
        

回复列表 (共4个回复)

沙发

谢谢,正在找这个

板凳

精!

3 楼

请问什么是ID3信息?

4 楼

可以用Pascal更改其中的信息么?比如标题、艺术家、日期

我来回复

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