您现在的位置:首页 >> 图形媒体 >> 图形媒体 >> 内容

Delphi中如何读取出MP3文件的信息

时间:2011/9/3 15:01:06 点击:

  核心提示:unit Unit1mp3tag;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, F...

unit Unit1mp3tag;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TID3Tag=packed record   //128字节
    TAGID: array[0..2] of Char; //3字节:必须是TAG
    Title: array[0..29] of Char; //30字节:歌曲标题
    Artist: array[0..29] of Char; //30字节:歌曲的艺术家
    Album: array[0..29] of Char; //30字节:歌曲专辑
    Year: array[0..3] of Char; //4字节:出版年
    Comment: array[0..29] of Char; //30字节: 评论
    Genre: byte;   //1 字节: 种类标识
  end;  

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function GetMp3TAG(const Mp3FileName:string):TID3Tag;
var
  mp3file: TFileStream;
begin
  mp3file:=TFileStream.create(Mp3FileName,$0000);
  try
    mp3file.Position:=mp3file.size-128;   //跳到id3-tag
    mp3file.Read(Result,SizeOf(Result));
  finally
    mp3file.free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
 var  
  m:TID3TAg;
begin
  m:=GetMp3tag('E:\Music\MYLOVE\test.mp3');
  ShowMessage(m.Title+' '+m.Artist+' '+m.Album+' '+m.Year+' '+m.Comment);
end;

end.



迅雷专用高速下载

作者:网络 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
本类推荐
  • 没有
本类固顶
  • 没有
  • 盒子文章(www.2ccc.com) © 2024 版权所有 All Rights Reserved.
  • 沪ICP备05001939号