2010-11-23 4 views
4

delphi를 사용하여 설명, 제목, 자막, 등급, 아티스트 등과 같은 mp3 파일 세부 정보를 편집하는 방법은 무엇입니까? 이 일을하기위한 구성 요소가 있습니까? mp3 파일 세부 정보 편집 방법 (Delphi)

는 당신이있어 무엇처럼 보이는, 당신은

+5

나는이 태그를 idv3 태그라고 부릅니다. idv3 태그를 읽고 편집 할 수있는 델파이 용 구성 요소/확장을 검색해야합니다. –

+0

응답 주셔서 감사합니다. – Kermia

답변

6

아마도 ID3V1뿐만 아니라 ID3V2도 조작 할 수 있습니다.

그래서, 이것은 내가 본 기기를 가지고 어디 기억하지

http://www.3delite.hu/Object Pascal Developer Resources/id3v2library.html

+2

Welcome to Stack Overflow, PA. URL의 형식을 지정하기 위해 억양으로 URL을 포장하지 마십시오. 대신 링크를 붙여 넣기 만하면 스택 오버플로가 URL을 하이퍼 링크로 전환합니다. 억음 악센트를 사용하면 * 링크를 사용하는 것이 더 어려워집니다. –

1

id3mgmnt.pas 한 번 봐 주셔서 감사합니다.

처음 테스트 한 결과를 테스트 한 적이 없습니다.

2

당신에게 도움이 될 수 있습니다 라이브러리입니다,하지만 난 얼마 전에 애완 동물 프로젝트를 위해 그것을 사용 :

unit ID3v2; 

interface 

uses 
    Classes, SysUtils; 

const 
    TAG_VERSION_2_3 = 3;        { Code for 
ID3v2.3.0 tag } 

type 
    { Class TID3v2 } 
    TID3v2 = class(TObject) 
    private 
     { Private declarations } 
     FExists: Boolean; 
     FVersionID: Byte; 
     FSize: Integer; 
     FTitle: string; 
     FArtist: string; 
     FAlbum: string; 
     FTrack: Byte; 
     FYear: string; 
     FGenre: string; 
     FComment: string; 
    public 
     { Public declarations } 
     constructor Create;          { Create 
object } 
     procedure ResetData;         { Reset 
all data } 
     function ReadFromFile(const FileName: string): Boolean;  { 
Load tag } 
     property Exists: Boolean read FExists;    { True if tag 
found } 
     property VersionID: Byte read FVersionID;    { 
Version code } 
     property Size: Integer read FSize;      { Total 
tag size } 
     property Title: string read FTitle;      { Song 
title } 
     property Artist: string read FArtist;      { 
Artist name } 
     property Album: string read FAlbum;      { 
Album name } 
     property Track: Byte read FTrack;      { Track 
number } 
     property Year: string read FYear; 
{ Year } 
     property Genre: string read FGenre;      { 
Genre name } 
     property Comment: string read FComment;      { 
Comment } 
    end; 

implementation 

const 
    { Max. number of supported tag frames } 
    ID3V2_FRAME_COUNT = 7; 

    { Names of supported tag frames } 
    ID3V2_FRAME: array [1..ID3V2_FRAME_COUNT] of string = 
    ('TIT2', 'TPE1', 'TALB', 'TRCK', 'TYER', 'TCON', 'COMM'); 

type 
    { ID3v2 frame header } 
    FrameHeader = record 
    ID: array [1..4] of AnsiChar;          { 
Frame ID } 
    Size: Integer;         { Size excluding 
header } 
    Flags: Word;              { 
Flags } 
    end; 

    { ID3v2 header data - for internal use } 
    TagInfo = record 
    { Real structure of ID3v2 header } 
    ID: array [1..3] of AnsiChar;         { Always 
"ID3" } 
    Version: Byte;           { Version 
number } 
    Revision: Byte;           { Revision 
number } 
    Flags: Byte;            { Flags 
of tag } 
    Size: array [1..4] of Byte;     { Tag size excluding 
header } 
    { Extended data } 
    FileSize: Integer;         { File size 
(bytes) } 
    Frame: array [1..ID3V2_FRAME_COUNT] of string; { Information from 
frames } 
    end; 

{ ********************* Auxiliary functions & procedures 
******************** } 

function ReadHeader(const FileName: string; var Tag: TagInfo): Boolean; 
var 
    SourceFile: file; 
    Transferred: Integer; 
begin 
    try 
    Result := true; 
    { Set read-access and open file } 
    AssignFile(SourceFile, FileName); 
    FileMode := 0; 
    Reset(SourceFile, 1); 
    { Read header and get file size } 
    BlockRead(SourceFile, Tag, 10, Transferred); 
    Tag.FileSize := FileSize(SourceFile); 
    CloseFile(SourceFile); 
    { if transfer is not complete } 
    if Transferred < 10 then Result := false; 
    except 
    { Error } 
    Result := false; 
    end; 
end; 

{ 
--------------------------------------------------------------------------- 

} 

function GetVersionID(const Tag: TagInfo): Byte; 
begin 
    { Get tag version from header } 
    Result := Tag.Version; 
end; 

{ 
--------------------------------------------------------------------------- 

} 

function GetTagSize(const Tag: TagInfo): Integer; 
begin 
    { Get total tag size } 
    Result := 
    Tag.Size[1] * $200000 + 
    Tag.Size[2] * $4000 + 
    Tag.Size[3] * $80 + 
    Tag.Size[4] + 10; 
    if Result > Tag.FileSize then Result := 0; 
end; 

{ 
--------------------------------------------------------------------------- 

} 

procedure SetTagItem(const ID, Data: string; var Tag: TagInfo); 
var 
    Iterator: Byte; 
begin 
    { Set tag item if supported frame found } 
    for Iterator := 1 to ID3V2_FRAME_COUNT do 
    if ID3V2_FRAME[Iterator] = ID then Tag.Frame[Iterator] := Data; 
end; 

{ 
--------------------------------------------------------------------------- 

} 

function Swap32(const Figure: Integer): Integer; 
var 
    ByteArray: array [1..4] of Byte absolute Figure; 
begin 
    { Swap 4 bytes } 
    Result := 
    ByteArray[1] * $100000000 + 
    ByteArray[2] * $10000 + 
    ByteArray[3] * $100 + 
    ByteArray[4]; 
end; 

{ 
--------------------------------------------------------------------------- 

} 

procedure ReadFrames(const FileName: string; var Tag: TagInfo); 
var 
    SourceFile: file; 
    Frame: FrameHeader; 
    Data: array [1..250] of AnsiChar; 
    DataPosition: Integer; 
begin 
    try 
    { Set read-access, open file } 
    AssignFile(SourceFile, FileName); 
    FileMode := 0; 
    Reset(SourceFile, 1); 
    Seek(SourceFile, 10); 
    while (FilePos(SourceFile) < GetTagSize(Tag)) and (not 
EOF(SourceFile)) do 
    begin 
     FillChar(Data, SizeOf(Data), 0); 
     { Read frame header } 
     BlockRead(SourceFile, Frame, 10); 
     DataPosition := FilePos(SourceFile); 
     { Read frame data and set tag item if frame supported } 
     BlockRead(SourceFile, Data, Swap32(Frame.Size) mod SizeOf(Data)); 
     SetTagItem(Frame.ID, Data, Tag); 
     Seek(SourceFile, DataPosition + Swap32(Frame.Size)); 
    end; 
    CloseFile(SourceFile); 
    except 
    end; 
end; 

{ 
--------------------------------------------------------------------------- 

} 

function GetTrack(const TrackString: string): Byte; 
var 
    Index, Value, Code: Integer; 
begin 
    { Extract track from string } 
    Index := Pos('/', TrackString); 
    if Index = 0 then Val(Trim(TrackString), Value, Code) 
    else Val(Copy(Trim(TrackString), 1, Index), Value, Code); 
    if Code = 0 then Result := Value 
    else Result := 0; 
end; 

{ 
--------------------------------------------------------------------------- 

} 

function GetGenre(const GenreString: string): string; 
begin 
    { Extract genre from string } 
    Result := Trim(GenreString); 
    if Pos(')', Result) > 0 then Delete(Result, 1, LastDelimiter(')', 
Result)); 
end; 

{ ********************** Public functions & procedures 
********************** } 

constructor TID3v2.Create; 
begin 
    inherited; 
    ResetData; 
end; 

{ 
--------------------------------------------------------------------------- 

} 

procedure TID3v2.ResetData; 
begin 
    FExists := false; 
    FVersionID := 0; 
    FSize := 0; 
    FTitle := ''; 
    FArtist := ''; 
    FAlbum := ''; 
    FTrack := 0; 
    FYear := ''; 
    FGenre := ''; 
    FComment := ''; 
end; 

{ 
--------------------------------------------------------------------------- 

} 

function TID3v2.ReadFromFile(const FileName: string): Boolean; 
var 
    Tag: TagInfo; 
begin 
    { Reset data and load header from file to variable } 
    ResetData; 
    Result := ReadHeader(FileName, Tag); 
    { Process data if loaded and header valid } 
    if (Result) and (Tag.ID = 'ID3') then 
    begin 
    FExists := true; 
    { Fill properties with header data } 
    FVersionID := GetVersionID(Tag); 
    FSize := GetTagSize(Tag); 
    { Get information from frames if version supported } 
    if (FVersionID = TAG_VERSION_2_3) and (FSize > 0) then 
    begin 
     ReadFrames(FileName, Tag); 
     { Fill properties with data from frames } 
     FTitle := Trim(Tag.Frame[1]); 
     FArtist := Trim(Tag.Frame[2]); 
     FAlbum := Trim(Tag.Frame[3]); 
     FTrack := GetTrack(Tag.Frame[4]); 
     FYear := Trim(Tag.Frame[5]); 
     FGenre := GetGenre(Tag.Frame[6]); 
     FComment := Trim(Copy(Tag.Frame[7], 5, Length(Tag.Frame[7]) - 4)); 
    end; 
    end; 
end; 

end. 
+0

가능한 복사 본입니다. –

+0

내 음악 라이브러리를 WMP, iTunes 또는 WinAmp가 원하는 방식이 아닌 원하는 방식으로 구성하는 프로젝트에 적합합니다. –

+0

나중에 델파이 버전에서 유니 코드 지원 코드를 업데이트했습니다. 나는 모든 종류의 'Char'를 'AnsiChar'로 바꿨다. –

1

당신은 내가 얼마 전에 위르겐 폴의 오디오 도구 라이브러리의 일부를 사용 http://www.delphi-jedi.org/

+0

하지만 읽기 전용입니다! 변경 사항을 저장할 수 없습니다 – Kermia

+0

@Kermia : 그건 당신의 대답입니다! 귀하의 메시지가 승인 된 것으로 표시되기 전후인지 확실하지 않습니다. 어쨌든 부정확 한 답변을 수락하지 않거나 댓글이 달린 문제를 해결하면이 고아를 여기에 남겨 두지 마십시오. – jachguate

1

에서 TJvID3v1 또는 TJvID3v2 구성 요소를 사용할 수 있습니다. 조금 오래되었지만 (2005),이 라이브러리는 2005 년까지 다른 사람들이 관리했습니다. 다양한 구성 요소 저장소에서 이전 2002 버전을 구하거나 http://mac.sourceforge.net/atl/에서 "최신"버전을 구할 수 있습니다. 이 코드가 최신 ID3 표준에 맞는지는 모르겠지만 2002 코드는 기존 오디오 플레이어 프로젝트의 MP3 파일에서 데이터를 가져옵니다.

@ioan : 게시 한 유닛이 실제로이 라이브러리의 일부 버전에서 제공됩니다.