unit info_get; //{$DEFINE DEBUG} interface uses Classes, myTag, myWStrings; type T_MyInfoGet = class(TThread) private { Private 宣言 } F_iIndex : Integer; F_sFileName : WideString; FTag : TMyTag; F_bCreateTag : Boolean; F_bUpdateVideoSize : Boolean; procedure UpdateInfo; procedure UpdateInfo2; protected procedure Execute; override; public constructor Create(iIndex: Integer; sFileName: WideString); destructor Destroy; override; end; var G_PlaylistStrings : TMyWStrings; implementation uses {$IFDEF DEBUG} myDebug, {$ENDIF} Forms, SysUtils, myFile, // main, list; { TMyInfoGet } constructor T_MyInfoGet.Create(iIndex: Integer; sFileName: WideString); var li_Time1 : Int64; li_Time2 : Int64; l_Tag : TMyTag; begin F_iIndex := iIndex; F_sFileName := sFileName; FTag := nil; F_bCreateTag := True; F_bUpdateVideoSize := False; if (gfnbFileExists(F_sFileName)) then begin if (Assigned(G_PlaylistStrings.Objects[iIndex])) then begin //既にタグオブジェクト作成済み l_Tag := TMyTag(G_PlaylistStrings.Objects[iIndex]); if (WideUpperCase(l_Tag.FileName) = WideUpperCase(F_sFileName)) then begin //Beep; //ファイル名が一致 if (l_Tag.RawTitle <> '') then begin li_Time1 := l_Tag.FileWriteTimeInt; li_Time2 := gfniFileWriteTimeGet(F_sFileName); if (li_Time1 = li_Time2) then begin //取得済みのタグ情報の更新日と現在の更新日が同じならタグ情報の更新の必要はない F_bCreateTag := False; if (l_Tag.MediaDuration < 0) then begin //だがしかし長さが0ならビデオサイズの取得はまだなのでビデオサイズの更新は行う FTag := TMyTag.Create(l_Tag); F_bUpdateVideoSize := True; end; end; end; end; end; end; {$IFDEF DEBUG} myDebug.gpcDebug('InfoGet Create'); {$ENDIF} FreeOnTerminate := True; inherited Create(False); // inherited Create(True); end; destructor T_MyInfoGet.Destroy; begin {$IFDEF DEBUG} myDebug.gpcDebug(['InfoGet Destroy', F_bCreateTag, F_bUpdateVideoSize]); {$ENDIF} if (FTag <> nil) then begin FTag.Free; // FreeAndNil(FTag); end; inherited; end; procedure T_MyInfoGet.Execute; begin {$IFDEF DEBUG} myDebug.gpcDebug('InfoGet Execute'); {$ENDIF} if (Terminated) or (Application.Terminated) then begin Exit; end; if (F_bCreateTag) then begin //アーティスト名、タイトルなどのタグ情報 FTag := TMyTag.Create(F_sFileName); Synchronize(UpdateInfo); if (Terminated) or (Application.Terminated) then begin Exit; end; //メディアの長さ、ビデオの大きさ、フレームレート。 //処理に時間がかかるので↑とは分けて取得。 FTag.GetVideoSize; {$IFDEF DEBUG} myDebug.gpcDebug('InfoGet Execute 1'); {$ENDIF} Synchronize(UpdateInfo2); end else if (F_bUpdateVideoSize) then begin Synchronize(UpdateInfo); if (Terminated) or (Application.Terminated) then begin Exit; end; //メディアの長さ、ビデオの大きさ、フレームレートの取得がまだなので取得。 FTag.GetVideoSize; Synchronize(UpdateInfo2); end else begin //FTagはnilのまま Synchronize(UpdateInfo); Synchronize(UpdateInfo2); end; end; procedure T_MyInfoGet.UpdateInfo; begin {$IFDEF DEBUG} myDebug.gpcDebug('UpdateInfo'); {$ENDIF} if (Terminated) or (Application.Terminated) then begin {$IFDEF DEBUG} myDebug.gpcDebug('UpdateInfo Terminated'); {$ENDIF} Exit; end; G_PlaylistForm.SetInfo(Self, F_iIndex, FTag); end; procedure T_MyInfoGet.UpdateInfo2; begin {$IFDEF DEBUG} myDebug.gpcDebug('UpdateInfo2'); {$ENDIF} if (Terminated) or (Application.Terminated) then begin {$IFDEF DEBUG} myDebug.gpcDebug('UpdateInfo2 Terminated'); {$ENDIF} Exit; end; G_PlaylistForm.SetInfo2(Self, F_iIndex, FTag); end; end.