📄 jvqid3v2.pas
字号:
//=== { TJvID3Text } =========================================================
constructor TJvID3Text.Create(AController: TJvID3Controller);
begin
inherited Create(AController);
FDummyList := TStringList.Create;
end;
destructor TJvID3Text.Destroy;
begin
FDummyList.Free;
inherited Destroy;
end;
function TJvID3Text.GetDateTime(const FrameID: Integer{TJvID3FrameID}): TDateTime;
var
Frame: TJvID3TimestampFrame;
begin
Frame := TJvID3TimestampFrame.Find(FController, TJvID3FrameID(FrameID));
if Assigned(Frame) then
Result := Frame.Value
else
Result := 0;
end;
function TJvID3Text.GetList(const FrameID: Integer{TJvID3FrameID}): TStrings;
begin
if FController.Active then
Result := TJvID3SimpleListFrame.FindOrCreate(FController, TJvID3FrameID(FrameID)).List
else
begin
Result := FDummyList;
Result.Clear;
end;
end;
function TJvID3Text.GetNumber(const FrameID: Integer{TJvID3FrameID}): Cardinal;
var
Frame: TJvID3NumberFrame;
begin
Frame := TJvID3NumberFrame.Find(FController, TJvID3FrameID(FrameID));
if Assigned(Frame) then
Result := Frame.Value
else
Result := 0;
end;
function TJvID3Text.GetText(const FrameID: Integer{TJvID3FrameID}): string;
var
Frame: TJvID3TextFrame;
begin
Frame := TJvID3TextFrame.Find(FController, TJvID3FrameID(FrameID));
if Assigned(Frame) then
Result := Frame.Text
else
Result := '';
end;
procedure TJvID3Text.SetDateTime(const FrameID: Integer{TJvID3FrameID};
const Value: TDateTime);
begin
if FController.Active then
TJvID3TimestampFrame.FindOrCreate(FController, TJvID3FrameID(FrameID)).Value := Value;
end;
procedure TJvID3Text.SetList(const FrameID: Integer{TJvID3FrameID};
const Value: TStrings);
begin
if FController.Active then
TJvID3SimpleListFrame.FindOrCreate(FController, TJvID3FrameID(FrameID)).List.Assign(Value);
end;
procedure TJvID3Text.SetNumber(const FrameID: Integer{TJvID3FrameID};
const Value: Cardinal);
begin
if FController.Active then
TJvID3NumberFrame.FindOrCreate(FController, TJvID3FrameID(FrameID)).Value := Value;
end;
procedure TJvID3Text.SetText(const FrameID: Integer{TJvID3FrameID}; const Value: string);
begin
if FController.Active then
TJvID3TextFrame.FindOrCreate(FController, TJvID3FrameID(FrameID)).Text := Value;
end;
//=== { TJvID3UDText } =======================================================
procedure TJvID3UDText.Add(const ADescription, AValue: string);
begin
if not Assigned(FController) then
ID3Error(RsEID3NoController);
with TJvID3UserFrame(FController.AddFrame(fiUserText)) do
begin
Description := ADescription;
Value := AValue;
end;
end;
function TJvID3UDText.GetDescription: string;
var
Frame: TJvID3UserFrame;
begin
if ItemIndex < 0 then
Result := ''
else
begin
Frame := TJvID3UserFrame.Find(FController, ItemIndex);
if Assigned(Frame) then
Result := Frame.Description
else
Result := '';
end;
end;
function TJvID3UDText.GetItemCount: Integer;
begin
if not FController.Active then
Result := 0
else
Result := FController.GetFrameCountFor(fiUserText);
end;
function TJvID3UDText.GetItemIndex: Integer;
begin
if not FController.Active then
FItemIndex := -1
else
FItemIndex := Min(FItemIndex, ItemCount - 1);
Result := FItemIndex;
end;
function TJvID3UDText.GetValue: string;
var
Frame: TJvID3UserFrame;
begin
if ItemIndex < 0 then
Result := ''
else
begin
Frame := TJvID3UserFrame.Find(FController, ItemIndex);
if Assigned(Frame) then
Result := Frame.Value
else
Result := '';
end;
end;
procedure TJvID3UDText.SetDescription(const Value: string);
begin
if FController.Active and (ItemIndex >= 0) and (ItemIndex < ItemCount) then
TJvID3UserFrame.Find(FController, ItemIndex).Description := Value;
end;
procedure TJvID3UDText.SetItemIndex(const Value: Integer);
begin
if Value <> FItemIndex then
FItemIndex := Min(Value, ItemCount - 1);
end;
procedure TJvID3UDText.SetValue(const Value: string);
begin
if FController.Active and (ItemIndex >= 0) and (ItemIndex < ItemCount) then
TJvID3UserFrame.Find(FController, ItemIndex).Value := Value;
end;
//=== { TJvID3UDUrl } ========================================================
procedure TJvID3UDUrl.Add(const ADescription, AURL: string);
begin
if not Assigned(FController) then
ID3Error(RsEID3NoController);
with TJvID3URLUserFrame(FController.AddFrame(fiWWWUser)) do
begin
Description := ADescription;
URL := AURL;
end;
end;
function TJvID3UDUrl.GetDescription: string;
var
Frame: TJvID3URLUserFrame;
begin
if ItemIndex < 0 then
Result := ''
else
begin
Frame := TJvID3URLUserFrame.Find(FController, ItemIndex);
if Assigned(Frame) then
Result := Frame.Description
else
Result := '';
end;
end;
function TJvID3UDUrl.GetItemCount: Integer;
begin
if not FController.Active then
Result := 0
else
Result := FController.GetFrameCountFor(fiWWWUser);
end;
function TJvID3UDUrl.GetItemIndex: Integer;
begin
if not FController.Active then
FItemIndex := -1
else
FItemIndex := Min(FItemIndex, ItemCount - 1);
Result := FItemIndex;
end;
function TJvID3UDUrl.GetURL: string;
var
Frame: TJvID3URLUserFrame;
begin
if ItemIndex < 0 then
Result := ''
else
begin
Frame := TJvID3URLUserFrame.Find(FController, ItemIndex);
if Assigned(Frame) then
Result := Frame.URL
else
Result := '';
end;
end;
procedure TJvID3UDUrl.SetDescription(const Value: string);
begin
if FController.Active and (ItemIndex >= 0) then
TJvID3URLUserFrame.Find(FController, ItemIndex).Description := Value;
end;
procedure TJvID3UDUrl.SetItemIndex(const Value: Integer);
begin
if Value <> FItemIndex then
FItemIndex := Min(Value, ItemCount - 1);
end;
procedure TJvID3UDUrl.SetURL(const Value: string);
begin
if FController.Active and (ItemIndex >= 0) then
TJvID3URLUserFrame.Find(FController, ItemIndex).URL := Value;
end;
//=== { TJvID3v2 } ===========================================================
constructor TJvID3v2.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
RegisterClient(Self, ActiveChanged);
FID3Text := TJvID3Text.Create(Self);
FWeb := TJvID3Web.Create(Self);
FUserDefinedText := TJvID3UDText.Create(Self);
FUserDefinedWeb := TJvID3UDUrl.Create(Self);
FInvolvedPeople := TJvID3Ipl.Create(Self);
FImages := TJvID3Images.Create(Self);
FOwner := TJvID3Owner.Create(Self);
FPopularimeter := TJvID3Popularimeter.Create(Self);
{ This ensures that possible unicode tags will be translated to ansi }
WriteEncodingAs := ifeISO_8859_1;
ReadEncodingAs := ifeISO_8859_1;
Options := [coAutoCorrect, coRemoveEmptyFrames];
end;
destructor TJvID3v2.Destroy;
begin
UnRegisterClient(Self);
FID3Text.Free;
FWeb.Free;
FUserDefinedText.Free;
FUserDefinedWeb.Free;
FInvolvedPeople.Free;
FImages.Free;
FOwner.Free;
FPopularimeter.Free;
inherited Destroy;
end;
procedure TJvID3v2.ActiveChanged(Sender: TObject; Activated: Boolean);
begin
if Activated then
FImages.Pictures.RetrievePictures
else
FImages.Pictures.RemovePictures;
end;
function TJvID3v2.GetPlayCounter: Cardinal;
var
Frame: TJvID3PlayCounterFrame;
begin
Frame := TJvID3PlayCounterFrame.Find(Self);
if Assigned(Frame) then
Result := Frame.Counter
else
Result := 0;
end;
procedure TJvID3v2.SetPlayCounter(const Value: Cardinal);
begin
if Active then
TJvID3PlayCounterFrame.FindOrCreate(Self).Counter := Value;
end;
//=== { TJvID3Web } ==========================================================
function TJvID3Web.GetText(const FrameID: Integer{TJvID3FrameID}): string;
var
Frame: TJvID3URLFrame;
begin
Frame := TJvID3URLFrame.Find(FController, TJvID3FrameID(FrameID));
if Assigned(Frame) then
Result := Frame.URL
else
Result := '';
end;
procedure TJvID3Web.SetText(const FrameID: Integer{TJvID3FrameID}; const Value: string);
begin
if FController.Active then
TJvID3URLFrame.FindOrCreate(FController, TJvID3FrameID(FrameID)).URL := Value;
end;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$RCSfile: JvQId3v2.pas,v $';
Revision: '$Revision: 1.17 $';
Date: '$Date: 2004/09/07 23:11:17 $';
LogPath: 'JVCL\run'
);
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -