📄 jvid3v2editformu.pas
字号:
{******************************************************************
JEDI-VCL Demo
Copyright (C) 2002 Project JEDI
Original author:
Contributor(s):
You may retrieve the latest version of this file at the JEDI-JVCL
home page, located at http://jvcl.sourceforge.net
The contents of this file are used with permission, subject to
the Mozilla Public License Version 1.1 (the "License"); you may
not use this file except in compliance with the License. You may
obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1_1Final.html
Software distributed under the License is distributed on an
"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
******************************************************************}
unit JvID3v2EditFormU;
{$I jvcl.inc}
interface
uses
Windows, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ActnList, StdCtrls,
JvID3v2Base, JvId3v2, ExtCtrls, JvComponent, ImgList, ToolWin;
type
TJvID3v2EditForm = class(TForm)
PageControl1: TPageControl;
lsbNavigator: TListBox;
ToolBar1: TToolBar;
tshWinampTags: TTabSheet;
tshLyrics: TTabSheet;
tshPictures: TTabSheet;
lblTitle: TLabel;
lblArtist: TLabel;
lblAlbum: TLabel;
lblYear: TLabel;
lblComposer: TLabel;
lblOrigArtist: TLabel;
lblCopyright: TLabel;
lblURL: TLabel;
lblEncodedBy: TLabel;
edtTitle: TEdit;
edtArtist: TEdit;
edtAlbum: TEdit;
edtYear: TEdit;
edtComposer: TEdit;
edtOrigArtist: TEdit;
edtCopyright: TEdit;
edtURL: TEdit;
edtEncodedBy: TEdit;
cmbGenre: TComboBox;
lblGenre: TLabel;
memComment: TMemo;
lblComment: TLabel;
acl16: TActionList;
iml16: TImageList;
actOK: TAction;
actCancel: TAction;
actRemove: TAction;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
JvID3v21: TJvID3v2;
lblLanguage: TLabel;
cmbLanguage: TComboBox;
memLyrics: TMemo;
lblDescription: TLabel;
lblWriter: TLabel;
edtDescription: TEdit;
edtWriter: TEdit;
lsvPictures: TListView;
imgPicture: TImage;
actAddPicture: TAction;
actDeletePicture: TAction;
actSavePicture: TAction;
lblPictureName: TLabel;
lblPictureType: TLabel;
edtPictureName: TEdit;
cmbPictureType: TComboBox;
tshAllFrames: TTabSheet;
lsvAllFrames: TListView;
btnChange: TButton;
actChangePicture: TAction;
Button1: TButton;
Button2: TButton;
Button3: TButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
actCopyTov1: TAction;
actCopyFromv1: TAction;
procedure actOKExecute(Sender: TObject);
procedure actCancelExecute(Sender: TObject);
procedure actRemoveExecute(Sender: TObject);
procedure actAddPictureExecute(Sender: TObject);
procedure actDeletePictureExecute(Sender: TObject);
procedure actSavePictureExecute(Sender: TObject);
procedure lsvPicturesClick(Sender: TObject);
procedure lsbNavigatorClick(Sender: TObject);
procedure actChangePictureExecute(Sender: TObject);
procedure ItemSelected(Sender: TObject);
procedure actCopyTov1Execute(Sender: TObject);
procedure actCopyFromv1Execute(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure lsvAllFramesInfoTip(Sender: TObject; Item: TListItem;
var InfoTip: String);
private
FTagDeleted: Boolean;
protected
procedure Init;
procedure Final;
procedure InitAllFramesTab;
procedure TagToCtrls;
procedure CtrlsToTag;
procedure FillPictureTypes(Strings: TStrings);
class function Instance: TJvID3v2EditForm;
public
class function Execute(const AFileName: string): Boolean;
end;
implementation
uses
ExtDlgs,
JvID3v2Types;
{$R *.dfm}
var
CFrameDescriptions: array[TJvID3FrameID] of string = (
'Error', {fiErrorFrame}
'Padding', {fiPaddingFrame}
'No known frame', {fiNoFrame}
'Audio encryption', {fiAudioCrypto}
'Attached picture', {fiPicture}
'Audio seek point index', {fiAudioSeekPoint}
'Comments', {fiComment}
'Commercial frame', {fiCommercial}
'Encryption method registration', {fiCryptoReg}
'Equalisation (2)', {fiEqualization2}
'Equalization', {fiEqualization}
'Event timing codes', {fiEventTiming}
'General encapsulated object', {fiGeneralObject}
'Group identification registration', {fiGroupingReg}
'Involved people list', {fiInvolvedPeople}
'Linked information', {fiLinkedInfo}
'Music CD identifier', {fiCDID}
'MPEG location lookup table', {fiMPEGLookup}
'Ownership frame', {fiOwnership}
'Private frame', {fiPrivate}
'Play counter', {fiPlayCounter}
'Popularimeter', {fiPopularimeter}
'Position synchronisation frame', {fiPositionsync}
'Recommended buffer size', {fiBufferSize}
'Relative volume adjustment (2)', {fiVolumeAdj2}
'Relative volume adjustment', {fiVolumeAdj}
'Reverb', {fiReverb}
'Seek frame', {fiSeekFrame}
'Signature frame', {fiSignature}
'Synchronized lyric/text', {fiSyncedLyrics}
'Synchronized tempo codes', {fiSyncedTempo}
'Album/Movie/Show title', {fiAlbum}
'BPM (beats per minute)', {fiBPM}
'Composer', {fiComposer}
'Content type', {fiContentType}
'Copyright message', {fiCopyright}
'Date', {fiDate}
'Encoding time', {fiEncodingTime}
'Playlist delay', {fiPlaylistDelay}
'Original release time', {fiOrigReleaseTime}
'Recording time', {fiRecordingTime}
'Release time', {fiReleaseTime}
'Tagging time', {fiTaggingTime}
'Involved people list', {fiInvolvedPeople2}
'Encoded by', {fiEncodedBy}
'Lyricist/Text writer', {fiLyricist}
'File type', {fiFileType}
'Time', {fiTime}
'Content group description', {fiContentGroup}
'Title/songname/content description', {fiTitle}
'Subtitle/Description refinement', {fiSubTitle}
'Initial key', {fiInitialKey}
'Language(s)', {fiLanguage}
'Length', {fiSongLen}
'Musician credits list', {fiMusicianCreditList}
'Media type', {fiMediaType}
'Mood', {fiMood}
'Original album/movie/show title', {fiOrigAlbum}
'Original filename', {fiOrigFileName}
'Original lyricist(s)/text writer(s)', {fiOrigLyricist}
'Original artist(s)/performer(s)', {fiOrigArtist}
'Original release year', {fiOrigYear}
'File owner/licensee', {fiFileOwner}
'Lead performer(s)/Soloist(s)', {fiLeadArtist}
'Band/orchestra/accompaniment', {fiBand}
'Conductor/performer refinement', {fiConductor}
'Interpreted, remixed, or otherwise modified by', {fiMixArtist}
'Part of a set', {fiPartInSet}
'Produced notice', {fiProducedNotice}
'Publisher', {fiPublisher}
'Track number/Position in set', {fiTrackNum}
'Recording dates', {fiRecordingDates}
'Internet radio station name', {fiNetRadioStation}
'Internet radio station owner', {fiNetRadioOwner}
'Size', {fiSize}
'Album sort order', {fiAlbumSortOrder}
'Performer sort order', {fiPerformerSortOrder}
'Title sort order', {fiTitleSortOrder}
'ISRC (international standard recording code)', {fiISRC}
'Software/Hardware and settings used for encoding', {fiEncoderSettings}
'Set subtitle', {fiSetSubTitle}
'User defined text information', {fiUserText}
'Year', {fiYear}
'Unique file identifier', {fiUniqueFileID}
'Terms of use', {fiTermsOfUse}
'Unsynchronized lyric/text transcription', {fiUnsyncedLyrics}
'Commercial information', {fiWWWCommercialInfo}
'Copyright/Legal information', {fiWWWCopyright}
'Official audio file webpage', {fiWWWAudioFile}
'Official artist/performer webpage', {fiWWWArtist}
'Official audio source webpage', {fiWWWAudioSource}
'Official internet radio station homepage', {fiWWWRadioPage}
'Payment', {fiWWWPayment}
'Official publisher webpage', {fiWWWPublisher}
'User defined URL link', {fiWWWUser}
'Encrypted meta frame', {fiMetaCrypto}
'Compressed meta frame' {fiMetaCompression}
);
CPictureTypeStr: array[TJvID3PictureType] of string = (
'Other',
'32x32 pixels ''file icon'' (PNG only)',
'Other file icon',
'Cover (front)',
'Cover (back)',
'Leaflet page',
'Media (e.g. lable side of CD)',
'Lead artist/lead performer/soloist',
'Artist/performer',
'Conductor',
'Band/Orchestra',
'Composer',
'Lyricist/text writer',
'Recording Location',
'During recording',
'During performance',
'Movie/video screen capture',
'A bright coloured fish',
'Illustration',
'Band/artist logotype',
'Publisher/Studio logotype'
);
procedure SetPictureListItemTo(ListItem: TListItem; Frame: TJvID3PictureFrame);
begin
with ListItem, Frame do
begin
Caption := Description;
while SubItems.Count < 3 do
SubItems.Add('');
SubItems[0] := CPictureTypeStr[PictureType]; //Type
SubItems[1] := MIMEType; //Format
SubItems[2] := IntToStr(DataSize); //Size
Data := Frame;
end;
end;
procedure TJvID3v2EditForm.FormCreate(Sender: TObject);
begin
FillPictureTypes(cmbPictureType.Items);
ISO_639_2Names(cmbLanguage.Items);
ID3_Genres(cmbGenre.Items);
end;
procedure TJvID3v2EditForm.actOKExecute(Sender: TObject);
var
HasTag: Boolean;
Version: TJvID3Version;
Cursor: TCursor;
begin
Cursor := Screen.Cursor;
Screen.Cursor := crHourGlass;
try
CtrlsToTag;
JvID3v21.Frames.RemoveEmptyFrames;
HasTag := True;
if JvID3v21.FrameCount = 0 then
GetID3v2Version(JvID3v21.FileName, HasTag, Version);
if HasTag then
JvID3v21.Commit;
ModalResult := mrOk;
finally
Screen.Cursor := Cursor;
end;
end;
procedure TJvID3v2EditForm.actCancelExecute(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TJvID3v2EditForm.actRemoveExecute(Sender: TObject);
var
Cursor: TCursor;
begin
if MessageDlg('Remove tag?', mtConfirmation, mbOKCancel, 0) <> mrOk then
Exit;
Cursor := Screen.Cursor;
Screen.Cursor := crHourGlass;
try
JvID3v21.Erase;
FTagDeleted := True;
TagToCtrls;
finally
Screen.Cursor := Cursor;
end;
end;
class function TJvID3v2EditForm.Execute(const AFileName: string): Boolean;
begin
with TJvID3v2EditForm.Instance do
try
JvID3v21.FileName := AFileName;
Init;
try
Result := (ShowModal = mrOk) or FTagDeleted;
finally
Final;
end;
finally
Hide;
end;
end;
procedure TJvID3v2EditForm.Init;
begin
Caption := Format('Edit ''%s''', [ExtractFileName(JvID3v21.FileName)]);
JvID3v21.Open;
TagToCtrls;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -