Main.~pas
上传用户:mjqmds
上传日期:2022-05-05
资源大小:2827k
文件大小:57k
- unit Main;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes,Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls, dxBar, XPMenu, Buttons, dxBarExtItems,
- TFlatScrollbarUnit, ImgList, LMDCustomControl, LMDCustomPanel,
- LMDCustomTrackBar, LMDTrackBar, ExtDlgs, Menus, Math, DrawPanel,
- TFlatSplitterUnit, TFlatPanelUnit, ComCtrls, GIFImage, GraphicEx,
- AppEvnts, LMDControl, LMDBaseControl, LMDBaseGraphicControl, Graphics,
- LMDGraphicControl, LMDCustomGraphicLabel, LMDGraphicLabel, PlayList, ShellAPI,
- CoolTrayIcon, DropTarget, DropSource, DropURLTarget, Registry, OleServer;
- Const
- WM_FULLSCREEN=WM_USER+1001;
- WM_PLAYNEXT=WM_USER+1002;
- WM_PLAYPRIOR=WM_USER+1003;
- WM_STARTSHOW=WM_USER+1006;
- WM_OPENREMOTEFILE=WM_USER+1007;
- WM_SHOWAPP=WM_USER+1108;
- WM_HIDEAPP=WM_USER+1109;
- WM_KILLAPP=WM_USER+1110;
- type
- TPlayState=(psNone,psStop,psPlay,psPause,psOne,psLoad,psPreview);
- TMainForm = class(TForm)
- Timer1: TTimer;
- OpenDialog1: TOpenDialog;
- dxBarManager1: TdxBarManager;
- dxBarButton1: TdxBarButton;
- dxBarButton2: TdxBarButton;
- dxBarButton3: TdxBarButton;
- dxBarButton4: TdxBarButton;
- Panel2: TPanel;
- dxBarProgressItem1: TdxBarProgressItem;
- XPMenu1: TXPMenu;
- dxBarSubItem1: TdxBarSubItem;
- dxBarButton5: TdxBarButton;
- dxBarButton6: TdxBarButton;
- dxBarSubItem2: TdxBarSubItem;
- dxBarSubItem3: TdxBarSubItem;
- dxBarSubItem4: TdxBarSubItem;
- dxBarButton7: TdxBarButton;
- dxBarButton8: TdxBarButton;
- dxBarSubItem5: TdxBarSubItem;
- dxBarButton9: TdxBarButton;
- dxBarButton10: TdxBarButton;
- dxBarButton11: TdxBarButton;
- dxBarButton12: TdxBarButton;
- dxBarSubItem6: TdxBarSubItem;
- dxBarButton13: TdxBarButton;
- LMDTrackBar2: TLMDTrackBar;
- SavePictureDialog1: TSavePictureDialog;
- dxBarButton14: TdxBarButton;
- dxBarButton15: TdxBarButton;
- dxBarButton16: TdxBarButton;
- dxBarButton17: TdxBarButton;
- dxBarButton18: TdxBarButton;
- dxBarButton19: TdxBarButton;
- dxBarSubItem7: TdxBarSubItem;
- dxBarButton20: TdxBarButton;
- dxBarButton21: TdxBarButton;
- dxBarSubItem8: TdxBarSubItem;
- dxBarButton22: TdxBarButton;
- dxBarButton23: TdxBarButton;
- dxBarSubItem9: TdxBarSubItem;
- dxBarButton24: TdxBarButton;
- dxBarButton25: TdxBarButton;
- dxBarButton26: TdxBarButton;
- dxBarButton27: TdxBarButton;
- dxBarButton28: TdxBarButton;
- dxBarButton29: TdxBarButton;
- dxBarButton30: TdxBarButton;
- dxBarButton31: TdxBarButton;
- dxBarButton32: TdxBarButton;
- dxBarButton33: TdxBarButton;
- PopupMenu1: TPopupMenu;
- N10: TMenuItem;
- N11: TMenuItem;
- Panel3: TPanel;
- SpeedButton5: TSpeedButton;
- LMDTrackBar1: TLMDTrackBar;
- Panel4: TPanel;
- Panel5: TPanel;
- Panel6: TPanel;
- Panel1: TDrawPanel;
- dxBarSubItem10: TdxBarSubItem;
- dxBarButton34: TdxBarButton;
- dxBarButton35: TdxBarButton;
- dxBarButton36: TdxBarButton;
- dxBarButton37: TdxBarButton;
- dxBarButton38: TdxBarButton;
- dxBarButton39: TdxBarButton;
- dxBarButton40: TdxBarButton;
- dxBarButton41: TdxBarButton;
- dxBarButton42: TdxBarButton;
- dxBarButton43: TdxBarButton;
- dxBarButton44: TdxBarButton;
- dxBarButton45: TdxBarButton;
- N1: TMenuItem;
- N2: TMenuItem;
- N3: TMenuItem;
- N4: TMenuItem;
- N5: TMenuItem;
- N6: TMenuItem;
- dxBarSubItem11: TdxBarSubItem;
- dxBarButton46: TdxBarButton;
- dxBarButton47: TdxBarButton;
- ApplicationEvents1: TApplicationEvents;
- dxBarListItem1: TdxBarListItem;
- dxBarButton48: TdxBarButton;
- dxBarInPlaceSubItem1: TdxBarInPlaceSubItem;
- dxBarTreeViewCombo1: TdxBarTreeViewCombo;
- dxBarListItem2: TdxBarListItem;
- dxBarButton49: TdxBarButton;
- dxBarLargeButton1: TdxBarLargeButton;
- dxBarLargeButton2: TdxBarLargeButton;
- dxBarStatic1: TdxBarStatic;
- dxBarButton50: TdxBarButton;
- dxBarButton51: TdxBarButton;
- dxBarEdit1: TdxBarEdit;
- dxBarToolbarsListItem1: TdxBarToolbarsListItem;
- dxBarButton52: TdxBarButton;
- Panel7: TPanel;
- SpeedButton6: TSpeedButton;
- SpeedButton14: TSpeedButton;
- SpeedButton1: TSpeedButton;
- SpeedButton2: TSpeedButton;
- SpeedButton3: TSpeedButton;
- SpeedButton4: TSpeedButton;
- SpeedButton7: TSpeedButton;
- SpeedButton8: TSpeedButton;
- SpeedButton9: TSpeedButton;
- SpeedButton10: TSpeedButton;
- SpeedButton12: TSpeedButton;
- SpeedButton13: TSpeedButton;
- SpeedButton15: TSpeedButton;
- Panel22: TPanel;
- OpenDialog2: TOpenDialog;
- SaveDialog1: TSaveDialog;
- SaveDialog2: TSaveDialog;
- Panel9: TPanel;
- dxBarButton53: TdxBarButton;
- ListView1: TListView;
- dxBarButton54: TdxBarButton;
- OpenDialog3: TOpenDialog;
- SpeedButton11: TSpeedButton;
- CoolTrayIcon1: TCoolTrayIcon;
- PopupMenu2: TPopupMenu;
- N7: TMenuItem;
- N8: TMenuItem;
- N9: TMenuItem;
- N12: TMenuItem;
- N13: TMenuItem;
- N14: TMenuItem;
- N15: TMenuItem;
- dxBarButton55: TdxBarButton;
- dxBarButton56: TdxBarButton;
- ImageList1: TImageList;
- N16: TMenuItem;
- N17: TMenuItem;
- dxBarButton57: TdxBarButton;
- DropURLTarget1: TDropURLTarget;
- DropFileTarget1: TDropFileTarget;
- DropURLTarget2: TDropURLTarget;
- DropFileTarget2: TDropFileTarget;
- SpeedButton16: TSpeedButton;
- dxBarButton58: TdxBarButton;
- dxBarSubItem12: TdxBarSubItem;
- dxBarButton59: TdxBarButton;
- dxBarButton60: TdxBarButton;
- dxBarButton61: TdxBarButton;
- dxBarButton62: TdxBarButton;
- Panel8: TPanel;
- Shape1: TShape;
- PopupMenu3: TPopupMenu;
- Timer2: TTimer;
- dxBarButton63: TdxBarButton;
- dxBarSubItem13: TdxBarSubItem;
- dxBarButton64: TdxBarButton;
- dxBarButton65: TdxBarButton;
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- procedure SpeedButton4Click(Sender: TObject);
- procedure SpeedButton1Click(Sender: TObject);
- procedure SpeedButton2Click(Sender: TObject);
- procedure SpeedButton3Click(Sender: TObject);
- procedure dxBarButton4Click(Sender: TObject);
- procedure SpeedButton5Click(Sender: TObject);
- procedure SpeedButton7Click(Sender: TObject);
- procedure SpeedButton8Click(Sender: TObject);
- procedure SpeedButton9Click(Sender: TObject);
- procedure SpeedButton10Click(Sender: TObject);
- procedure LMDTrackBar2MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure LMDTrackBar2MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure LMDTrackBar2Track(Sender: TObject; ScrollCode: TScrollCode;
- var ScrollPos: Integer);
- procedure LMDTrackBar1Track(Sender: TObject; ScrollCode: TScrollCode;
- var ScrollPos: Integer);
- procedure Panel1Resize(Sender: TObject);
- procedure SpeedButton6Click(Sender: TObject);
- procedure SpeedButton14Click(Sender: TObject);
- procedure SpeedButton15Click(Sender: TObject);
- procedure dxBarButton6Click(Sender: TObject);
- procedure dxBarButton14Click(Sender: TObject);
- procedure dxBarButton15Click(Sender: TObject);
- procedure dxBarButton16Click(Sender: TObject);
- procedure dxBarButton17Click(Sender: TObject);
- procedure dxBarButton18Click(Sender: TObject);
- procedure dxBarButton19Click(Sender: TObject);
- procedure dxBarButton24Click(Sender: TObject);
- procedure dxBarButton25Click(Sender: TObject);
- procedure dxBarButton26Click(Sender: TObject);
- procedure dxBarButton32Click(Sender: TObject);
- procedure FormKeyUp(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure dxBarButton44Click(Sender: TObject);
- procedure dxBarButton7Click(Sender: TObject);
- procedure dxBarButton5Click(Sender: TObject);
- procedure ApplicationEvents1Exception(Sender: TObject; E: Exception);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure ListView1CustomDrawItem(Sender: TCustomListView;
- Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
- procedure N10Click(Sender: TObject);
- procedure N11Click(Sender: TObject);
- procedure N3Click(Sender: TObject);
- procedure N4Click(Sender: TObject);
- procedure N5Click(Sender: TObject);
- procedure N6Click(Sender: TObject);
- procedure LMDTrackBar1MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure ListView1DblClick(Sender: TObject);
- procedure dxBarButton53Click(Sender: TObject);
- procedure SpeedButton13Click(Sender: TObject);
- procedure ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
- State: TDragState; var Accept: Boolean);
- procedure ListView1DragDrop(Sender, Source: TObject; X, Y: Integer);
- procedure dxBarButton22Click(Sender: TObject);
- procedure dxBarButton21Click(Sender: TObject);
- procedure dxBarButton13Click(Sender: TObject);
- procedure dxBarButton30Click(Sender: TObject);
- procedure dxBarButton31Click(Sender: TObject);
- procedure dxBarButton27Click(Sender: TObject);
- procedure dxBarButton46Click(Sender: TObject);
- procedure dxBarButton29Click(Sender: TObject);
- procedure dxBarButton28Click(Sender: TObject);
- procedure dxBarButton33Click(Sender: TObject);
- procedure ApplicationEvents1Activate(Sender: TObject);
- procedure ApplicationEvents1Deactivate(Sender: TObject);
- procedure dxBarButton11Click(Sender: TObject);
- procedure dxBarButton47Click(Sender: TObject);
- procedure Panel1Paint(Sender: TObject);
- procedure SpeedButton12Click(Sender: TObject);
- procedure CoolTrayIcon1Click(Sender: TObject);
- procedure N12Click(Sender: TObject);
- procedure N8Click(Sender: TObject);
- procedure dxBarButton55Click(Sender: TObject);
- procedure dxBarButton56Click(Sender: TObject);
- procedure dxBarButton57Click(Sender: TObject);
- procedure DropURLTarget1Drop(Sender: TObject; ShiftState: TShiftState;
- Point: TPoint; var Effect: Integer);
- procedure DropFileTarget1Drop(Sender: TObject; ShiftState: TShiftState;
- Point: TPoint; var Effect: Integer);
- procedure FormResize(Sender: TObject);
- procedure SpeedButton16Click(Sender: TObject);
- procedure dxBarButton58Click(Sender: TObject);
- procedure dxBarButton60Click(Sender: TObject);
- procedure LMDTrackBar1MouseWheel(Sender: TObject; Shift: TShiftState;
- WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
- procedure FormDeactivate(Sender: TObject);
- procedure dxBarButton62Click(Sender: TObject);
- procedure PopupMenu3Popup(Sender: TObject);
- procedure Panel1DblClick(Sender: TObject);
- procedure Timer2Timer(Sender: TObject);
- procedure dxBarButton63Click(Sender: TObject);
- procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Panel1MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure dxBarButton64Click(Sender: TObject);
- procedure dxBarButton65Click(Sender: TObject);
- private
- PlayState:TPlayState;
- IsNoSet:Boolean;
- Rate:DOUBLE;
- OldRec:TRect;
- PubLeft:Single;
- CurrentItem:TListItem;
- PlayEndFileName:String;
- MaxSeconds,MaxMinutes,MaxHours:Integer;
- AutoPause:Boolean;
- PlayListManager:TPlayListManager;
- bNextSuccess:Boolean;
- bContinuePlay:Boolean;
- OldPosRect:TRect;
- OldX:Integer;
- OldPt:TPoint;
- RoundPlay:Boolean;
- MouseTimeout:DWORD;
- PreviewClick:Boolean;
- PreviewFileName:Array[0..3] of String;
- PausePreview:Boolean;
- procedure InitPlayMenu(Items: TdxBarSubItem; MenuItem:TMenuItem);
- procedure FilterOptionClick(Sender:TObject);
- procedure StopPlay(IsSave:Boolean);
- procedure MenuItemClick(Sender:TObject);
- procedure OpenDialog(FileType:TFileType; PlayType:TPlayType);
- procedure OnReadyEnd(Sender:TObject; PlayInfo:PPlayFileInfo; Item:TListItem);
- function OpenFile(Item:TListItem):Boolean;
- procedure WMFULLSCREEN(var Msg:TMessage);Message WM_FULLSCREEN;
- procedure UpdateFullScreen(b:Boolean);
- procedure CheckOne;
- procedure UpdateButtonState;
- procedure Init;
- procedure DoRatio;
- function GetLayerNo(X, Y: Integer): Integer;
- { Private declarations }
- protected
- bLockUpateWindow:Boolean;
- procedure WndProc(var Msg:TMessage);override;
- public
- class procedure WriteIni(Section, Key, Value: String);
- class function ReadIni(Section,Key,Default:String):String;
- class procedure WriteReg(Key:String; Value:Variant);
- class function ReadReg(Key:String; DefaultValue:Variant):Variant;
- { Public declarations }
- end;
- var
- MainForm: TMainForm;
- implementation
- uses WHPlaySDK, IniFiles, Controller, Hook, Config, MD5Unit, Password,
- About, DoUnit, AudioConfig, ConfigExt;
- {$R *.dfm}
- procedure TMainForm.FormCreate(Sender: TObject);
- Var
- i:Integer;
- menu:TMenuItem;
- begin
- WriteReg('ProcessHandle',GetCurrentProcess);
- WriteReg('MsgHandle',Handle);
- //DropURLTarget1.Register(Listview1);
- //DropURLTarget2.Register(Panel1);
- DropFileTarget1.Register(Listview1);
- DropFileTarget2.Register(Panel1);
- PlayListManager:=TPlayListManager.Create(ListView1,Handle);
- SetWindowLong(Panel1.Handle,GWL_STYLE,GetWindowLong(Panel1.Handle, GWL_STYLE)
- or WS_CHILD);
- SetWindowLong(Panel2.Handle,GWL_STYLE,GetWindowLong(Panel2.Handle, GWL_STYLE)
- or WS_CHILD);
- //SetWindowLong(Panel2.Handle,GWL_EXSTYLE,GetWindowLong(Panel2.Handle, GWL_EXSTYLE) or WS_EX_APPWINDOW);
- dllRegisterVideoHandle(Panel1.Handle);
- dllRegisterMsgHandle(Handle);
- Init;
- For i:=0 to ImageList1.Count-1 do
- begin
- Menu:=TMenuItem.Create(N16);
- Menu.Caption:='图标'+IntToStr(i);
- Menu.ImageIndex:=i;
- Menu.OnClick:=MenuItemClick;
- N16.Add(Menu);
- end;
- PlayListManager.OnReadyEnd:=OnReadyEnd;
- if (ParamStr(1)<>'') then
- begin
- PostMessage(Handle,WM_STARTSHOW,0,0);
- end;
- //SetHook;
- end;
- procedure OnNotifyEvent(eventcode:LongInt; Param:Pointer; var IsContinue:Boolean);stdcall;
- Var
- Form:TMainForm;
- begin
- Form:=TMainForm(Param);
- With Form do
- begin
- Case eventCode of
- EC_COMPLETE:
- begin
- Panel8.Caption:='播放 00:00:00/00:00:00';
- PostMessage(Form.Handle,WM_PLAYNEXT,1,0);
- end;
- EC_USERABORT:
- begin
- end;
- EC_ERRORABORT:
- begin
- end;
- end;
- end;
- end;
- procedure SwitchToThisWindow(hwnd:THandle; bRestore:Boolean);stdcall; External 'User32.dll';
- function ForceForegroundWindow(hwnd: THandle): boolean;
- const
- SPI_GETFOREGROUNDLOCKTIMEOUT = $2000;
- SPI_SETFOREGROUNDLOCKTIMEOUT = $2001;
- var
- ForegroundThreadID: DWORD;
- ThisThreadID : DWORD;
- timeout : DWORD;
- begin
- if IsIconic(hwnd) then ShowWindow(hwnd, SW_RESTORE);
- if GetForegroundWindow = hwnd then
- Result := true
- else
- begin
- SwitchToThisWindow(Hwnd,true);
- if ((Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion > 4)) or
- ((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
- ((Win32MajorVersion > 4) or ((Win32MajorVersion = 4) and
- (Win32MinorVersion > 0)))) then
- begin
- Result := false;
- ForegroundThreadID := GetWindowThreadProcessID(GetForegroundWindow,nil);
- ThisThreadID := GetWindowThreadPRocessId(hwnd,nil);
- if AttachThreadInput(ThisThreadID, ForegroundThreadID, true) then
- begin
- BringWindowToTop(hwnd); // IE 5.5 related hack
- SetForegroundWindow(hwnd);
- AttachThreadInput(ThisThreadID, ForegroundThreadID, false);
- Result := (GetForegroundWindow = hwnd);
- end;
- if not Result then
- begin
- SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, @timeout, 0);
- SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(0), SPIF_SENDCHANGE);
- BringWindowToTop(hwnd); // IE 5.5 related hack
- SetForegroundWindow(hWnd);
- SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(timeout), SPIF_SENDCHANGE);
- end;
- end
- else begin
- BringWindowToTop(hwnd); // IE 5.5 related hack
- SetForegroundWindow(hwnd);
- end;
- Result := (GetForegroundWindow = hwnd);
- end;
- end;
- procedure TMainForm.WndProc(var Msg: TMessage);
- Var
- Item:TListItem;
- Info:PPlayFileInfo;
- vHours,vMinutes,vSeconds:String;
- eventCode:LongInt;
- v:Variant;
- begin
- inherited;
- if Application.Terminated then
- Exit;
- if (Msg.Msg in [WM_PAINT,WM_SIZE,WM_DISPLAYCHANGE,WM_MOVE]) and (Not (PlayState in [psStop,psNone,psLoad])) then
- dllDefaultProcessMsg(Handle,Msg.Msg,Msg.WParam,Msg.LParam);
- Case Msg.Msg of
- WM_KILLAPP:
- begin
- Close;
- end;
- WM_SHOWAPP:
- begin
- CoolTrayIcon1.ShowMainForm;
- ForceForegroundWindow(Application.Handle);
- ForceForegroundWindow(Handle);
- end;
- WM_HIDEAPP:
- begin
- ApplicationEvents1Deactivate(nil);
- end;
- WM_OPENREMOTEFILE:
- begin
- Msg.Result:=0;
- v:=ReadReg('TmpFileName',null);
- if Not VarIsNull(v) then
- begin
- CoolTrayIcon1.ShowMainForm;
- ForceForegroundWindow(Application.Handle);
- ForceForegroundWindow(Handle);
- PlayListManager.Add(v,ftUnknown,ptPlay);
- Msg.Result:=1;
- end;
- end;
- WM_ADDITEM:
- begin
- Info:=Ptr(Msg.WParam);
- Item:=ListView1.Items.Add;
- With Item do
- begin
- Caption:=Info.DisplayName;
- GetTimeString(Info.MediaInfo.PlayHours,Info.MediaInfo.PlayMinites,Info.MediaInfo.PlaySeconds,vHours,vMinutes,vSeconds);
- SubItems.Add(vHours+':'+vMinutes+':'+vSeconds);
- SubItems.Add(FloatToStr(Info.FileSize)+'M');
- Data:=Info;
- end;
- if Info.PlayType=ptPlay then
- OnReadyEnd(Owner,Info,Item);
- end;
- WM_STARTSHOW:
- begin
- if FileExists(ParamStr(1)) then
- begin
- if UpperCase(ExtractFileExt(ParamStr(1)))='.WPL' then
- Self.PlayListManager.Open(ParamStr(1),false,true)
- else
- PlayListManager.Add(ParamStr(1),ftUnknown,ptPlay);
- end;
- end;
- WM_PLAYNEXT:
- begin
- CurrentItem:=ListView1.GetNextItem(CurrentItem,sdAll, []);
- if Not Assigned(CurrentItem) then
- begin
- StopPlay(false);
- Exit;
- end;
-
- SpeedButton3.Click;
- if CurrentItem<>nil then
- begin
- if Not OpenFile(CurrentItem) then
- begin
- PostMessage(Handle,WM_PLAYNEXT,1,0);
- end
- else
- bNextSuccess:=true;
- end
- else if Msg.WParam=1 then
- begin
- if dxBarButton53.Down then
- begin
- if ListView1.Items.Count=0 then
- Exit;
- CurrentItem:=ListView1.Items[0];
- OpenFile(CurrentItem);
- end
- else
- begin
- if dxBarButton9.Down then
- begin
- WinExit(EWX_FORCE or EWX_SHUTDOWN);
- end
- else if dxBarButton10.Down then
- begin
- Application.Terminate;
- end
- else if dxBarButton11.Down then
- begin
- ShellExecute(0,'open',PChar(PlayEndFileName),'','',SW_SHOW);
- Application.Terminate;
- end;
- end;
- end;
- end;
- WM_PLAYPRIOR:
- begin
- if (CurrentItem<>nil) and (CurrentItem.Index>0) then
- CurrentItem:=ListView1.Items[CurrentItem.Index-1]
- else
- begin
- StopPlay(false);
- Exit;
- end;
- SpeedButton3.Click;
- if CurrentItem<>nil then
- begin
- if Not OpenFile(CurrentItem) then
- begin
- PostMessage(Handle,WM_PLAYPRIOR,0,0);
- end
- else
- bNextSuccess:=true;
- end;
- end;
-
- end;
- if Msg.Msg<>WM_GRAPHNOTIFY then
- Exit;
- dllDefaultOnGraphNotify(Msg.WParam,Msg.LParam,Self,OnNotifyEvent);
- end;
- procedure TMainForm.Timer1Timer(Sender: TObject);
- Var
- Hours,Minutes,Seconds:Integer;
- vMaxHours,vMaxMinutes,vMaxSeconds,vHours,vMinutes,vSeconds:String;
- begin
- if IsNoSet then
- Exit;
- if Application.Terminated then
- Exit;
-
- if PlayState=psPreview then
- begin
- LMDTrackBar2.Position:=dllPreviewGetPosition;
- dllPreviewGetSM(Seconds,Minutes);
- end
- else
- begin
- LMDTrackBar2.Position:=dllGetPostion;
- dllReadMediaPosition(Seconds,Minutes);
- end;
- Hours:=Minutes div 60;
- Minutes:=Minutes mod 60;
- GetTimeString(MaxHours,MaxMinutes,MaxSeconds,vMaxHours,vMaxMinutes,vMaxSeconds);
- GetTimeString(Hours,Minutes,Seconds,vHours,vMinutes,vSeconds);
- Panel8.Caption:='播放 '+vHours+':'+vMinutes+':'+vSeconds+'/'+
- vMaxHours+':'+vMaxMinutes+':'+vMaxSeconds;
- end;
- procedure TMainForm.FormDestroy(Sender: TObject);
- begin
- //endhook;
- PlayListManager.Free;
- dllQuit;
- end;
- procedure TMainForm.SpeedButton4Click(Sender: TObject);
- begin
- if Not (PlayState in [psPlay,psOne,psPause]) then
- begin
- SpeedButton4.Down:=false;
- Exit;
- end;
- if SpeedButton4.Down then
- dxBarButton55.Click
- else
- With OldPosRect do
- SetBounds(Left,Top,Right,Bottom);
- end;
- procedure TMainForm.SpeedButton1Click(Sender: TObject);
- begin
- if PlayState in [psNone,psStop] then
- begin
- if ListView1.Selected<>nil then
- OpenFile(ListView1.Selected)
- else if ListView1.Items.Count>0 then
- OpenFile(ListView1.Items[0])
- else
- dxBarButton5.Click;
- end
- else
- begin
- dllPlay;
-
- dllVolume(0-(3000-LMDTrackBar1.Position));
- Timer1.Enabled:=true;
- dxBarButton56.OnClick(dxBarButton56);
- PlayState:=psPlay;
- UpdateButtonState;
- end;
- end;
- procedure TMainForm.SpeedButton2Click(Sender: TObject);
- begin
- DllPause;
- PlayState:=psPause;
- Timer1.Enabled:=false;
- UpdateButtonState;
- Panel1.Invalidate;
- end;
- procedure TMainForm.SpeedButton3Click(Sender: TObject);
- begin
- StopPlay(false);
- end;
- procedure TMainForm.dxBarButton4Click(Sender: TObject);
- begin
- dllShowVRPropertyPage
- end;
- procedure TMainForm.SpeedButton5Click(Sender: TObject);
- begin
- if SpeedButton5.Visible then
- begin
- SpeedButton11.Visible:=true;
- SpeedButton5.Visible:=false;
- dllMuteAudio;
- end
- else
- begin
- SpeedButton5.Visible:=true;
- SpeedButton11.Visible:=false;
- dllResumeAudio;
- end;
- end;
- procedure TMainForm.SpeedButton7Click(Sender: TObject);
- begin
- CheckOne;
- dllStepFrames(1);
- UpdateButtonState;
- end;
- procedure TMainForm.SpeedButton8Click(Sender: TObject);
- begin
- Rate:=Rate-(rate/2);
- dllModifyRate(Rate);
- if Rate>1.0 then
- Panel6.Caption:='播放速度:'+FloatToStr(RoundTo(Rate,-2))+'(快速)'
- else
- Panel6.Caption:='播放速度:'+FloatToStr(RoundTo(Rate,-2))+'(慢速)';
- end;
- procedure TMainForm.SpeedButton9Click(Sender: TObject);
- begin
- Rate:=Rate+0.5;
- dllModifyRate(Rate);
- if Rate>1.0 then
- Panel6.Caption:='播放速度:'+FloatToStr(RoundTo(Rate,-2))+'(快速)'
- else
- Panel6.Caption:='播放速度:'+FloatToStr(RoundTo(Rate,-2))+'(慢速)';
- end;
- procedure TMainForm.SpeedButton10Click(Sender: TObject);
- begin
- Rate:=1;
- dllModifyRate(Rate);
- Panel6.Caption:='播放速度:1.0(正常)';
- end;
- procedure TMainForm.LMDTrackBar2MouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- IsNoSet:=true;
- OldX:=X;
- end;
- procedure TMainForm.LMDTrackBar2MouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- if IsNoSet then
- begin
- LMDTrackBar2.Position:=Round(LMDTrackBar2.MaxValue*(X/LMDTrackBar2.ClientWidth));
- end;
- IsNoSet:=false;
- LMDTrackBar2.Invalidate;
- end;
- procedure TMainForm.LMDTrackBar2Track(Sender: TObject;
- ScrollCode: TScrollCode; var ScrollPos: Integer);
- begin
- if ScrollCode=scEndScroll then
- begin
- if LMDTrackBar2.Position=LMDTrackBar2.MaxValue then
- LMDTrackBar2.Position:=LMDTrackBar2.Position-1;
- if PlayState=psPreview then
- dllPreviewSetPosition(LMDTrackBar2.Position)
- else
- dllSetPosition(LMDTrackBar2.Position);
- end;
- end;
- procedure TMainForm.LMDTrackBar1Track(Sender: TObject;
- ScrollCode: TScrollCode; var ScrollPos: Integer);
- begin
- dllVolume(0-(3000-LMDTrackBar1.Position));
- if ScrollCode=scEndScroll then
- begin
- WriteIni('Config' ,'Volume',IntToStr(LMDTrackBar1.Position));
- end;
- end;
- procedure TMainForm.CheckOne;
- begin
- if Not (PlayState in [psOne]) then
- begin
- dllSwitchStepFrame;
- PlayState:=psOne;
- end;
- end;
- procedure TMainForm.Panel1Resize(Sender: TObject);
- begin
- if bLockUpateWindow then
- Exit;
- if (PlayState=psPreview) or (PausePreview) then
- dllPreviewResize();
- dllResetDisplay(Panel1.Handle);
- end;
- procedure TMainForm.Init;
- Var
- g:TGUID;
- begin
- InitPlayMenu(dxBarSubItem3,PopupMenu3.Items);
- LMDTrackBar1.Position:=StrToInt(ReadIni('Config','Volume','0'));
- g:=StringToGUID(ReadIni('Config','GUID','{c553f2c0-1529-11d0-b4d1-00805f6cbbea}'));
- dllRegisterLockFilterGUID(g);
- UpdateButtonState;
- dxBarButton53.Down:=StrToBool(ReadIni('Config','RoundPlay','0'));
- dxBarButton22.Down:=StrToBool(ReadIni('Config','Ratio','0'));
- dxBarButton56.Down:=StrToBool(ReadIni('Config','AutoSize','0'));
- ImageList1.GetIcon(StrToInt(ReadIni('Config','IconIndex','0')),CoolTrayIcon1.Icon);
- OldPosRect.Left:=StrToInt(ReadIni('Config','PosX',IntToStr((Screen.Width-Width) div 2)));
- OldPosRect.Top:=StrToInt(ReadIni('Config','PosY',IntToStr((Screen.Height-Height) div 2)));
- OldPosRect.Right:=StrToInt(ReadIni('Config','PosWidth',IntToStr(Width)));
- OldPosRect.Bottom:=StrToInt(ReadIni('Config','PosHeight',IntToStr(Height)));
- With OldPosRect do
- SetBounds(Left,Top,Right,Bottom);
- CoolTrayIcon1.Refresh;
- Rate:=1;
- dxBarButton47.Down:=StrToBool(ReadIni('Playing','PlayListVisible','0'));
- dxBarButton47Click(dxBarButton47);
- end;
- class function TMainForm.ReadIni(Section, Key, Default: String):String;
- Var
- IniFile:TIniFile;
- begin
- IniFile:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'Config.Dat');
- Try
- Result:=IniFile.ReadString(Section,Key,Default);
- Finally
- IniFile.Free;
- end;
- end;
- class procedure TMainForm.WriteIni(Section, Key, Value: String);
- Var
- IniFile:TIniFile;
- begin
- IniFile:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'Config.Dat');
- Try
- IniFile.WriteString(Section,Key,Value);
- Finally
- IniFile.Free;
- end;
- end;
- procedure TMainForm.UpdateButtonState;
- begin
- SpeedButton4.Enabled:=Not dxBarButton56.Down;
- Case PlayState of
- psNone:
- begin
- SpeedButton1.Enabled:=true;
- SpeedButton2.Enabled:=false;
- SpeedButton3.Enabled:=false;
- SpeedButton6.Enabled:=false;
- SpeedButton14.Enabled:=false;
- SpeedButton15.Enabled:=false;
- SpeedButton7.Enabled:=false;
- SpeedButton8.Enabled:=false;
- SpeedButton9.Enabled:=false;
- SpeedButton10.Enabled:=false;
- Panel5.Caption:=' 状态:没有媒体';
- Panel1.EraseBackground:=true;
- end;
- psStop:
- begin
- SpeedButton1.Enabled:=true;
- SpeedButton2.Enabled:=false;
- SpeedButton3.Enabled:=false;
- SpeedButton6.Enabled:=false;
- SpeedButton14.Enabled:=false;
- SpeedButton15.Enabled:=false;
- SpeedButton7.Enabled:=false;
- SpeedButton8.Enabled:=false;
- SpeedButton9.Enabled:=false;
- SpeedButton10.Enabled:=false;
- Panel5.Caption:=' 状态:停止';
- Panel1.EraseBackground:=true;
- Panel1.Invalidate;
- end;
- psPlay:
- begin
- SpeedButton1.Enabled:=false;
- SpeedButton2.Enabled:=true;
- SpeedButton3.Enabled:=true;
- SpeedButton6.Enabled:=true;
- SpeedButton14.Enabled:=true;
- SpeedButton15.Enabled:=true;
- SpeedButton7.Enabled:=true;
- SpeedButton8.Enabled:=true;
- SpeedButton9.Enabled:=true;
- SpeedButton10.Enabled:=true;
- Panel5.Caption:=' 状态:播放中';
- Panel1.EraseBackground:=false;
- end;
- psPause:
- begin
- SpeedButton1.Enabled:=true;
- SpeedButton2.Enabled:=false;
- SpeedButton3.Enabled:=true;
- SpeedButton6.Enabled:=true;
- SpeedButton14.Enabled:=true;
- SpeedButton15.Enabled:=true;
- SpeedButton7.Enabled:=true;
- SpeedButton8.Enabled:=false;
- SpeedButton9.Enabled:=false;
- SpeedButton10.Enabled:=false;
- Panel5.Caption:=' 状态:暂停';
- Panel1.EraseBackground:=true;
- end;
- psOne:
- begin
- SpeedButton1.Enabled:=true;
- SpeedButton2.Enabled:=false;
- SpeedButton3.Enabled:=true;
- SpeedButton6.Enabled:=false;
- SpeedButton14.Enabled:=false;
- SpeedButton15.Enabled:=true;
- SpeedButton7.Enabled:=true;
- SpeedButton8.Enabled:=false;
- SpeedButton9.Enabled:=false;
- SpeedButton10.Enabled:=false;
- Panel5.Caption:=' 状态:单步播放';
- Panel1.EraseBackground:=true;
- end;
- psLoad:
- begin
- SpeedButton1.Enabled:=true;
- SpeedButton2.Enabled:=false;
- SpeedButton3.Enabled:=true;
- SpeedButton6.Enabled:=false;
- SpeedButton14.Enabled:=false;
- SpeedButton15.Enabled:=false;
- SpeedButton7.Enabled:=false;
- SpeedButton8.Enabled:=false;
- SpeedButton9.Enabled:=false;
- SpeedButton10.Enabled:=false;
- Panel5.Caption:=' 状态:文件已打开';
- Panel1.EraseBackground:=true;
- end;
- end;
- end;
- procedure TMainForm.SpeedButton6Click(Sender: TObject);
- begin
- if Not (PlayState in [psPlay,psPause,psOne]) then
- Exit;
- UpdateFullScreen(false);
- // dllRestoreFromFullScreen;
- SpeedButton6.Visible:=false;
- SpeedButton14.Visible:=true;
- end;
- procedure TMainForm.SpeedButton14Click(Sender: TObject);
- begin
- // dllFullscreen;
- if Not (PlayState in [psPlay,psPause,psOne]) then
- Exit;
- UpdateFullScreen(true);
- SpeedButton6.Visible:=true;
- SpeedButton14.Visible:=false;
- end;
- procedure TMainForm.SpeedButton15Click(Sender: TObject);
- begin
- if SavePictureDialog1.Execute then
- begin
- dllCaptureToBmp(PChar(SavePictureDialog1.FileName));
- end;
- end;
- procedure TMainForm.dxBarButton6Click(Sender: TObject);
- begin
- OpenDialog(ftLock,ptPlay);
- end;
- procedure TMainForm.dxBarButton14Click(Sender: TObject);
- begin
- OpenDialog(ftUnLock,ptPlay);
- end;
- procedure TMainForm.dxBarButton15Click(Sender: TObject);
- begin
- SpeedButton1.Click;
- end;
- procedure TMainForm.dxBarButton16Click(Sender: TObject);
- begin
- SpeedButton2.Click;
- end;
- procedure TMainForm.dxBarButton17Click(Sender: TObject);
- begin
- SpeedButton3.Click;
- end;
- procedure TMainForm.dxBarButton18Click(Sender: TObject);
- begin
- SpeedButton12.Click;
- end;
- procedure TMainForm.dxBarButton19Click(Sender: TObject);
- begin
- SpeedButton13.Click;
- end;
- procedure TMainForm.dxBarButton24Click(Sender: TObject);
- begin
- SpeedButton8.Click;
- end;
- procedure TMainForm.dxBarButton25Click(Sender: TObject);
- begin
- SpeedButton9.Click;
- end;
- procedure TMainForm.dxBarButton26Click(Sender: TObject);
- begin
- SpeedButton10.Click;
- end;
- procedure TMainForm.dxBarButton32Click(Sender: TObject);
- begin
- SpeedButton7.Click;
- end;
- procedure TMainForm.FormKeyUp(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- if (Key=VK_ESCAPE) then
- begin
- if SpeedButton6.Visible then
- SpeedButton6.Click
- else
- PostMessage(Handle,WM_HIDEAPP,0,0);
- end
- else if (ssAlt in Shift) and (Key=VK_RETURN) then
- begin
- if SpeedButton6.Visible then
- SpeedButton6.Click
- else
- SpeedButton14.Click;
- end
- end;
- procedure TMainForm.UpdateFullScreen(b: Boolean);
- Var
- a:Integer;
- begin
- bLockUpateWindow:=true;
- SpeedButton2.Click;
- if b then
- begin
- //LockWindowUpdate(Handle);
- SpeedButton4.Visible:=false;
- dxBarManager1.Bars[0].Visible:=false;
- Panel1.Align:=alNone;
- Panel2.Align:=alNone;
- Panel2.Visible:=false;
- ListView1.Visible:=false;
- OldRec:=Rect(Self.Left,Self.Top,Self.Width,Self.Height);
- a:=GetWindowLong(Handle, GWL_STYLE);
- a:=a and not WS_CAPTION;
- SetWindowLong(Handle,GWL_STYLE,a);
- SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_TOPMOST);
- SetBounds(-4,-4,Screen.Width+8,Screen.Height+8);
- Self.Panel1.SetBounds(0,0,Screen.Width,Screen.Height);
- Self.Panel2.SetBounds(0,ClientHeight-Panel2.Height,ClientWidth,Panel2.Height);
- ShowCursor(false);
- // dllFullscreen;
- //LockWindowUpdate(0);
- end
- else
- begin
- SpeedButton4.Visible:=true;
- SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(Handle, GWL_EXSTYLE) and not WS_EX_TOPMOST);
- SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle, GWL_STYLE) or WS_CAPTION or WS_BORDER);
- Self.SetBounds(OldRec.Left,OldRec.Top,OldRec.Right,OldRec.Bottom);
- Panel1.SetBounds(Self.ClientRect.Left,Self.ClientRect.Top,
- Self.ClientRect.Right-Self.ClientRect.Left,Self.ClientRect.Bottom-Self.ClientRect.Top);
- Panel1.Align:=alClient;
- Panel2.Align:=alBottom;
- dxBarManager1.Bars[0].Visible:=true;
- Self.Panel2.Visible:=true;
- ListView1.Visible:=dxBarButton47.Down;
- ShowCursor(true);
- // dllRestoreFromFullScreen;
- end;
- bLockUpateWindow:=false;
- PostMessage(Handle,WM_FULLSCREEN,0,0);
- end;
- procedure TMainForm.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- begin
- if SpeedButton6.Visible then
- begin
- if (X<>OldPt.X) or (Y<>OldPt.Y) then
- begin
- OldPt:=Point(X,Y);
- MouseTimeout:=GetTickCount;
- if Not Timer2.Enabled then
- begin
- ShowCursor(true);
- Timer2.Enabled:=true;
- end;
- end;
- if Y>=Self.Height-Panel2.Height then
- begin
- if Panel2.Visible then
- Exit;
- Panel2.Visible:=true;
- end
- else
- begin
- if Not Panel2.Visible then
- Exit;
- Panel2.Visible:=false;
- end;
- end;
- end;
- procedure TMainForm.WMFULLSCREEN(var Msg: TMessage);
- begin
- Panel1.OnResize(Panel1);
- SpeedButton1.Click;
- end;
- procedure TMainForm.dxBarButton44Click(Sender: TObject);
- begin
- if OpenDialog1.Execute then
- begin
- dllAddUnLockGraph(PChar(OpenDialog1.FileName));
- end;
- end;
- procedure TMainForm.dxBarButton7Click(Sender: TObject);
- begin
- Form1.ShowModal;
- end;
- function TMainForm.OpenFile(Item:TListItem): Boolean;
- Var
- Info:PPlayFileInfo;
- FileStream:TFileStream;
- Str,Key:String;
- i:Integer;
- pStr:Array[0..1024] of Char;
- Var1,Var2:Integer;
- StrList:TStringList;
- Bu:TdxBarButton;
- b:Boolean;
- ItemLink:TdxBarItemLink;
- begin
- Result:=false;
- Info:=Item.Data;
- if Not Info.bExists then
- Exit;
- if Info.bLock then
- begin
- if DllOpenLockFile(PChar(Info.FileName),PChar(PForm.Password))=0 then
- Exit;
- PlayState:=psLoad;
- SpeedButton1.Click;
- UpdateButtonState;
- end
- else
- begin
- if DllOpenUnLockFile(PChar(Info.FileName))=0 then
- Exit;
- PlayState:=psLoad;
- SpeedButton1.Click;
- UpdateButtonState;
- end;
- CurrentItem:=Item;
- ListView1.Invalidate;
- DoRatio;
- DllConfig('GETFILTERNAMES',Var1,Var2);
- dxBarButton7.DestroyComponents;
- StrList:=TStringList.Create;
- Try
- b:=true;
- StrList.Text:=StrPas(Ptr(Var1));
- For i:=0 to StrList.Count-1 do
- begin
- if StrList.Strings[i]='' then
- Continue;
- Bu:=TdxBarButton.Create(dxBarButton7);
- Bu.Caption:=StrList.Strings[i];
- Bu.OnClick:=FilterOptionClick;
- ItemLink:=dxBarSubItem12.ItemLinks.Add;
- ItemLink.Item:=Bu;
- if b then
- begin
- b:=false;
- ItemLink.BeginGroup:=true;
- end;
- end;
- Finally
- StrList.Free;
- end;
- Result:=true;
- end;
- procedure TMainForm.dxBarButton5Click(Sender: TObject);
- begin
- OpenDialog(ftUnKnown,ptPlay);
- end;
- procedure TMainForm.ApplicationEvents1Exception(Sender: TObject;
- E: Exception);
- Var
- Str:String;
- begin
- Str:=E.Message;
- end;
- procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- StopPlay(true);
- end;
- procedure TMainForm.OnReadyEnd(Sender: TObject; PlayInfo: PPlayFileInfo; Item:TListItem);
- Var
- vItem:TListItem;
- Info:PPlayFileInfo;
- begin
- if PlayInfo.bExists then
- begin
- vItem:=Item;
- While (Not OpenFile(vItem)) and (vItem.Index<ListView1.Items.Count-1) do
- begin
- vItem:=ListView1.Items[vItem.Index+1];
- end;
- Info:=vItem.Data;
- Self.MaxHours:=Info.MediaInfo.PlayHours;
- Self.MaxMinutes:=Info.MediaInfo.PlayMinites;
- Self.MaxSeconds:=Info.MediaInfo.PlaySeconds;
- if Info.Pos>0 then
- begin
- LMDTrackBar2.Position:=Info.Pos;
- dllSetPosition(LMDTrackBar2.Position);
- end;
- end;
- end;
- procedure TMainForm.ListView1CustomDrawItem(Sender: TCustomListView;
- Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
- Var
- Info:PPlayFileInfo;
- OldColor:TColor;
- begin
- Info:=Item.Data;
- Sender.Canvas.Font.Color:=clLime;
- if Not Info.bExists then
- begin
- Sender.Canvas.Brush.Color:=clRed
- end
- else
- Sender.Canvas.Brush.Color:=clBlack;
- if Item=CurrentItem then
- begin
- Sender.Canvas.Brush.Color:=clYellow;
- Sender.Canvas.Font.Color:=clBlack;
- end;
- end;
- procedure TMainForm.OpenDialog(FileType:TFileType; PlayType:TPlayType);
- Var
- i:Integer;
- begin
- if Opendialog1.Execute then
- begin
- {
- DllOpenUnLockFile(PChar(OpenDialog1.FileName));
- SpeedButton1.Click;
- Exit;
- }
- For i:=0 to OpenDialog1.Files.Count-1 do
- begin
- if (i=0) and (PlayType=ptPlay) then
- begin
- Self.PlayListManager.Add(OpenDialog1.Files.Strings[i],FileType,ptPlay);
- end
- else
- Self.PlayListManager.Add(OpenDialog1.Files.Strings[i],FileType,ptAdd);
- end;
- end;
- end;
- procedure TMainForm.N10Click(Sender: TObject);
- begin
- OpenDialog(ftUnLock,ptAdd);
- end;
- procedure TMainForm.N11Click(Sender: TObject);
- Var
- CurDelete:Boolean;
- i:Integer;
- Item:TListItem;
- List:TList;
- begin
- Item:=ListView1.Selected;
- if Item=nil then
- Exit;
- List:=TList.Create;
- Try
- Repeat
- List.Add(Item);
- Item:=ListView1.GetNextItem(Item, sdAll, [isSelected]);
- Until Item=nil;
- CurDelete:=false;
- For i:=0 to List.Count-1 do
- begin
- if List.Items[i]=CurrentItem then
- begin
- CurDelete:=true;
- if SpeedButton3.Enabled then
- SpeedButton3.Click;
- CurrentItem:=ListView1.GetNextItem(CurrentItem, sdAll, []);
- end;
- Self.PlayListManager.Delete(TListItem(List.Items[i]));
- end;
- if CurDelete then
- begin
- if CurrentItem<>nil then
- OpenFile(CurrentItem);
- end;
- Finally
- List.Free;
- end;
- end;
- procedure TMainForm.N3Click(Sender: TObject);
- begin
- if OpenDialog2.Execute then
- begin
- Self.PlayListManager.Open(OpenDialog2.FileName,false);
- end;
- end;
- procedure TMainForm.N4Click(Sender: TObject);
- begin
- if OpenDialog2.Execute then
- begin
- Self.PlayListManager.Open(OpenDialog2.FileName,true);
- end;
- end;
- procedure TMainForm.N5Click(Sender: TObject);
- begin
- if Self.PlayListManager.FileName<>'' then
- begin
- Self.PlayListManager.Save(Self.PlayListManager.FileName,CurrentItem);
- end
- else
- if SaveDialog1.Execute then
- Self.PlayListManager.Save(SaveDialog1.FileName,CurrentItem);
- end;
- procedure TMainForm.N6Click(Sender: TObject);
- begin
- if SaveDialog2.Execute then
- begin
- if UpperCase(ExtractFileExt(SaveDialog2.FileName))='.WPL' then
- Self.PlayListManager.Save(SaveDialog2.FileName,CurrentItem)
- else
- Self.PlayListManager.SaveAs(SaveDialog2.FileName);
- end;
- end;
- procedure TMainForm.LMDTrackBar1MouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- Self.LMDTrackBar1.Invalidate;
- end;
- procedure TMainForm.ListView1DblClick(Sender: TObject);
- begin
- if ListView1.Selected<>nil then
- begin
- Self.OpenFile(ListView1.Selected);
- end;
- end;
- procedure TMainForm.dxBarButton53Click(Sender: TObject);
- Var
- b:Boolean;
- Item:TMenuItem;
- begin
- if Sender is TMenuItem then
- begin
- Item:=TMenuItem(PopupMenu3.Items.Find('循环播放'));
- if Item<>nil then
- begin
- Item.Checked:=Not Item.Checked;
- b:=Item.Checked;
- end
- else
- b:=dxBarButton53.Down;
- end
- else
- b:=dxBarButton53.Down;
- WriteIni('Config','RoundPlay',BoolToStr(b));
- if Sender is TdxBarButton then
- begin
- Item:=TMenuItem(PopupMenu3.Items.Find('循环播放'));
- if Item<>nil then
- begin
- Item.Checked:=b;
- end;
- end
- else
- dxBarButton53.Down:=b;
- end;
- procedure TMainForm.SpeedButton13Click(Sender: TObject);
- begin
- PostMessage(Handle,WM_PLAYNEXT,0,0);
- end;
- procedure TMainForm.ListView1DragOver(Sender, Source: TObject; X,
- Y: Integer; State: TDragState; var Accept: Boolean);
- begin
- if Source=ListView1 then accept :=true;
- end;
- procedure TMainForm.ListView1DragDrop(Sender, Source: TObject; X,
- Y: Integer);
- var
- DragItem, TargetItem:TListItem;
- TargetIndex: integer;
- begin
- DragItem := ListView1.Selected;
- TargetIndex := ListView1.DropTarget.Index;
- if TargetIndex>DragItem.Index then
- TargetItem:=ListView1.Items.Insert(TargetIndex+1)
- else
- TargetItem:=ListView1.Items.Insert(TargetIndex);
- TargetItem.Assign(DragItem);
- DragItem.Delete;
- end;
- procedure TMainForm.dxBarButton22Click(Sender: TObject);
- begin
- SpeedButton4.Enabled:=Not dxBarButton56.Down;
- DoRatio;
- end;
- procedure TMainForm.dxBarButton21Click(Sender: TObject);
- begin
- SpeedButton14.Click;
- end;
- procedure TMainForm.dxBarButton13Click(Sender: TObject);
- begin
- PForm.ShowModal;
- end;
- procedure TMainForm.dxBarButton30Click(Sender: TObject);
- begin
- N10.Click;
- end;
- procedure TMainForm.dxBarButton31Click(Sender: TObject);
- begin
- N11.Click;
- end;
- procedure TMainForm.dxBarButton27Click(Sender: TObject);
- begin
- N3.Click;
- end;
- procedure TMainForm.dxBarButton46Click(Sender: TObject);
- begin
- N4.Click;
- end;
- procedure TMainForm.dxBarButton29Click(Sender: TObject);
- begin
- N5.Click;
- end;
- procedure TMainForm.dxBarButton28Click(Sender: TObject);
- begin
- N6.Click;
- end;
- procedure TMainForm.dxBarButton33Click(Sender: TObject);
- begin
- AForm.ShowModal;
- end;
- procedure TMainForm.ApplicationEvents1Activate(Sender: TObject);
- begin
- if (PlayState=psPause) and AutoPause then
- begin
- SpeedButton1.Click;
- AutoPause:=false;
- end;
- end;
- procedure TMainForm.ApplicationEvents1Deactivate(Sender: TObject);
- begin
- if (PlayState=psPlay) and (Not AutoPause) then
- begin
- AutoPause:=true;
- SpeedButton2.Click;
- if N15.Checked then
- CoolTrayIcon1.HideMainForm
- else if N14.Checked then
- begin
- end
- else
- Application.Terminate;
- end;
- end;
- procedure TMainForm.dxBarButton11Click(Sender: TObject);
- begin
- if OpenDialog3.Execute then
- begin
- PlayEndFileName:=OpenDialog3.FileName;
- end;
- end;
- procedure TMainForm.DoRatio;
- begin
- if dxBarButton22.Down then
- dllDisplayRatio(1)
- else
- dllDisplayRatio(0);
- WriteIni('Config','Ratio',BoolToStr(dxBarButton22.Down));
- end;
- procedure TMainForm.dxBarButton47Click(Sender: TObject);
- begin
- ListView1.Visible:=dxBarButton47.Down;
- dxBarButton56.OnClick(dxBarButton56);
- if (Not dxBarButton56.Down) and (SpeedButton4.Down) then
- begin
- SpeedButton4.OnClick(SpeedButton4);
- end;
- WriteIni('Playing','PlayListVisible',BoolToStr(dxBarButton47.Down));
- end;
- procedure TMainForm.Panel1Paint(Sender: TObject);
- Var
- dc:HDC;
- begin
- if Not (PlayState in [psPause,psOne]) then
- Exit;
- DC:=GetDC(Panel1.Handle);
- Try
- dllRepaint(Panel1.Handle,DC);
- Finally
- ReleaseDC(Panel1.Handle,DC);
- end;
- end;
- procedure TMainForm.SpeedButton12Click(Sender: TObject);
- begin
- PostMessage(Handle,WM_PLAYPRIOR,0,0);
- end;
- procedure TMainForm.CoolTrayIcon1Click(Sender: TObject);
- begin
- if Not MainForm.Showing then
- CoolTrayIcon1.ShowMainForm;
- end;
- procedure TMainForm.N12Click(Sender: TObject);
- begin
- Application.Terminate;
- end;
- procedure TMainForm.N8Click(Sender: TObject);
- begin
- if Not MainForm.Showing then
- CoolTrayIcon1.ShowMainForm;
- end;
- procedure TMainForm.dxBarButton55Click(Sender: TObject);
- Var
- W,h:Integer;
- Rec:TRect;
- begin
- if SpeedButton6.Visible then
- Exit;
- OldPosRect:=Rect(Left,Top,Width,Height);
- if dllGetVideoRect(@Rec) then
- begin
- W:=Rec.Right-Panel1.ClientWidth;
- H:=Rec.Bottom-Panel1.ClientHeight;
- Width:=Width+W;
- Height:=Height+H;
- end;
- Left:=(Screen.Width-Width) div 2;
- Top:=(Screen.Height-Height) div 2;
- end;
- procedure TMainForm.dxBarButton56Click(Sender: TObject);
- begin
- SpeedButton4.Enabled:=Not dxBarButton56.Down;
- if dxBarButton56.Down then
- begin
- DoRatio;
- dxBarButton55.Click;
- end;
- WriteIni('Config','AutoSize',BoolToStr(dxBarButton56.Down));
- end;
- procedure TMainForm.MenuItemClick(Sender: TObject);
- begin
- ImageList1.GetIcon(TMenuItem(Sender).ImageIndex,CoolTrayIcon1.Icon);
- CoolTrayIcon1.Refresh;
- WriteIni('Config','IconIndex',IntToStr(TMenuItem(Sender).ImageIndex));
- end;
- procedure TMainForm.dxBarButton57Click(Sender: TObject);
- Var
- Pos:LongInt;
- FileName:String;
- FileType:TFileType;
- begin
- Pos:=StrToInt(ReadIni('Config','PlayPos','-1'));
- FileName:=ReadIni('Config','PlayPosFileName','');
- FileType:=TFileType(StrToInt(ReadIni('Config','FileType','0')));
- if (FileName='') or (Not FileExists(FileName)) or (Pos=-1) then
- begin
- MessageBox(Handle,'未发现可以恢复的媒体信息','提示',MB_ICONINFORMATION);
- Exit;
- end;
- bContinuePlay:=true;
- PlayListManager.Add(FileName,FileType,ptPlay,Pos);
- end;
- procedure TMainForm.StopPlay(IsSave: Boolean);
- Var
- Pos:LongInt;
- Info:PPlayFileInfo;
- begin
- if IsSave and (PlayState in [psPlay,psPause,psOne]) then
- begin
- Pos:=dllGetPostion;
- Info:=CurrentItem.Data;
- WriteIni('Config','PlayPos',IntToStr(Pos));
- WriteIni('Config','PlayPosFileName',Info.FileName);
- WriteIni('Config','FileType',IntToStr(Integer(Info.FileType)));
- end;
- DllStop;
- PlayState:=psStop;
- Timer1.Enabled:=false;
- UpdateButtonState;
- LMDTrackBar2.Position:=0;
- Panel1.Invalidate;
- end;
- procedure TMainForm.DropURLTarget1Drop(Sender: TObject;
- ShiftState: TShiftState; Point: TPoint; var Effect: Integer);
- begin
- PlayListManager.Add(TDropURLTarget(Sender).URL,ftUnknown,ptAdd);
- end;
- procedure TMainForm.DropFileTarget1Drop(Sender: TObject;
- ShiftState: TShiftState; Point: TPoint; var Effect: Integer);
- var
- i: integer;
- begin
- with TDropFileTarget(Sender) do
- begin
- for i := 0 to files.count-1 do
- begin
- if (i=0) and (ListView1.Items.Count=0) then
- PlayListManager.Add(files[i],ftUnknown,ptPlay)
- else
- PlayListManager.Add(files[i],ftUnknown,ptAdd);
- end;
- end;
- end;
- procedure TMainForm.FormResize(Sender: TObject);
- Var
- Rec:TRect;
- begin
- Rec:=Rect(Left,Top,Width,Height);
- WriteIni('Config','PosX',IntToStr(Rec.Left));
- WriteIni('Config','PosY',IntToStr(Rec.Top));
- WriteIni('Config','PosWidth',IntToStr(Rec.Right));
- WriteIni('Config','PosHeight',IntToStr(Rec.Bottom));
- end;
- procedure TMainForm.SpeedButton16Click(Sender: TObject);
- begin
- AuForm.ShowModal;
- end;
- procedure TMainForm.dxBarButton58Click(Sender: TObject);
- Var
- Val1,Val2:LongInt;
- begin
- DllConfig('SHOWDECODEPROPERTY',Val1,Val2);
- end;
- procedure TMainForm.FilterOptionClick(Sender: TObject);
- Var
- Val1,Val2:LongInt;
- begin
- Val1:=Integer(PChar(TdxBarButton(Sender).Caption));
- DllConfig('SHOWFILTERPROPERTY',Val1,Val2);
- end;
- procedure TMainForm.dxBarButton60Click(Sender: TObject);
- begin
- CEForm.ShowModal;
- end;
- procedure TMainForm.LMDTrackBar1MouseWheel(Sender: TObject;
- Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
- var Handled: Boolean);
- begin
- LMDTrackBar1.Position:=LMDTrackBar1.Position+WheelDelta;
- end;
- procedure TMainForm.FormDeactivate(Sender: TObject);
- begin
- ApplicationEvents1Deactivate(nil);
- end;
- class function TMainForm.ReadReg(Key: String; DefaultValue: Variant): Variant;
- Var
- Reg:TRegistry;
- begin
- Result:=NULL;
- Reg:=TRegistry.Create;
- Try
- Reg.RootKey:=HKEY_CURRENT_USER;
- if Reg.OpenKey('/WHSUPPERPLAYER/RUN',false) then
- begin
- Result:=Reg.ReadString(Key);
- if VarIsNull(Result) or VarIsEmpty(Result) then
- Result:=DefaultValue;
- end
- else
- Result:=DefaultValue;
- Finally
- Reg.Free;
- end;
- end;
- class procedure TMainForm.WriteReg(Key: String; Value: Variant);
- Var
- Reg:TRegistry;
- begin
- Reg:=TRegistry.Create;
- Try
- Reg.RootKey:=HKEY_CURRENT_USER;
- if Reg.OpenKey('/WHSUPPERPLAYER/RUN',true) then
- begin
- Reg.WriteString(Key,Value);
- end
- Finally
- Reg.Free;
- end;
- end;
- procedure TMainForm.dxBarButton62Click(Sender: TObject);
- begin
- Close;
- end;
- procedure TMainForm.InitPlayMenu(Items: TdxBarSubItem; MenuItem:TMenuItem);
- Var
- i:Integer;
- Item:TMenuItem;
- Link:TdxBarItemLink;
- begin
- for i:=0 to Items.ItemLinks.Count-1 do
- begin
- Link:=Items.ItemLinks.Items[i];
- if Link.BeginGroup then
- begin
- Item:=TMenuItem.Create(MenuItem);
- MenuItem.Add(Item);
- Item.Caption:='-';
- end;
- if Link.Item.ClassType=TdxBarSubItem then
- begin
- Item:=TMenuItem.Create(MenuItem);
- MenuItem.Add(Item);
- Item.Caption:=Link.Caption;
- Item.OnClick:=TdxBarSubItem(Link.Item).OnClick;
- InitPlayMenu(TdxBarSubItem(Link.Item),Item);
- end
- else
- begin
- Item:=TMenuItem.Create(MenuItem);
- MenuItem.Add(Item);
- Item.Caption:=Link.Caption;
- Item.OnClick:=TdxBarButton(Link.Item).OnClick;
- end;
- end;
- end;
- procedure TMainForm.PopupMenu3Popup(Sender: TObject);
- Var
- Item:TMenuItem;
- begin
- Item:=TMenuItem(PopupMenu3.Items.Find('循环播放'));
- if Item<>nil then
- begin
- Item.Checked:=dxBarButton53.Down;
- end;
- end;
- procedure TMainForm.Panel1DblClick(Sender: TObject);
- Var
- nLayer:Integer;
- Pt:TPoint;
- begin
- if PlayState in [psPreview] then
- begin
- GetCursorPos(Pt);
- Pt:=Panel1.ScreenToClient(Pt);
- nLayer:=GetLayerNo(Pt.X,Pt.Y);
- PlayListManager.Add(PreviewFileName[nLayer],ftUnknown,ptPlay,LMDTrackBar2.Position);
- PausePreview:=true;
- DllPreviewPause();
- Exit;
- end;
- if Not (PlayState in [psPlay,psPause,psOne,psPreview]) then
- Exit;
- if SpeedButton14.Visible then
- SpeedButton14.Click
- else
- SpeedButton6.Click;
- end;
- procedure TMainForm.Timer2Timer(Sender: TObject);
- begin
- if Not (SpeedButton6.Visible) then
- Exit;
- if Panel2.Visible then
- Exit;
- if GetTickCount-MouseTimeout>2000 then
- begin
- Timer2.Enabled:=false;
- ShowCursor(false);
- end;
- end;
- procedure TMainForm.dxBarButton63Click(Sender: TObject);
- Var
- i,L,T:Integer;
- Rec:TRect;
- procedure GetRect;
- Var
- W,H:Integer;
- begin
- W:=Panel1.ClientWidth div 2;
- H:=Panel1.ClientHeight div 2;
- T:=(i div 2)*H;
- L:=(i mod 2)*W;
- Rec:=Rect(L,T,L+W,T+H);
- end;
- begin
- if Not (PlayState in [psPreview,psNone]) then
- SpeedButton3.Click;
-
- PausePreview:=false;
- dllBeginPreview(Panel1.Handle,4);
- if OpenDialog1.Execute then
- begin
- for i:=0 to OpenDialog1.Files.Count-1 do
- begin
- dllSetPreviewMedia(PChar(OpenDialog1.Files.Strings[i]),i);
- GetRect;
- dllSetPreviewMediaRect(i,Rec);
- PreviewFileName[i]:=OpenDialog1.Files.Strings[i];
- end;
- end;
- dllPreviewPlay;
- PlayState:=psPreview;
- Timer1.Enabled:=true;
- end;
- function TMainForm.GetLayerNo(X,Y:Integer):Integer;
- Var
- nLayer:Integer;
- begin
- nLayer:=0;
- if PtInRect(Rect(0,0,ClientWidth div 2,ClientHeight div 2),Point(X,Y)) then
- begin
- nLayer:=0;
- end
- else if PtInRect(Rect(ClientWidth div 2,0,ClientWidth,ClientHeight div 2),Point(X,Y)) then
- begin
- nLayer:=1;
- end
- else if PtInRect(Rect(0,ClientHeight div 2,ClientWidth div 2,ClientHeight),Point(X,Y)) then
- begin
- nLayer:=2;
- end
- else if PtInRect(Rect(0,ClientHeight div 2,ClientWidth,ClientHeight),Point(X,Y)) then
- begin
- nLayer:=3;
- end;
- Result:=nLayer;
- end;
- procedure TMainForm.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- PreviewClick:=true;
- end;
- procedure TMainForm.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- Var
- nLayer:Integer;
- begin
- if (PreviewClick) and (PlayState=psPreview) then
- begin
- nLayer:=GetLayerNo(X,Y);
- PreviewClick:=false;
- dllPreviewSetAudio(nLayer,0-(3000-LMDTrackBar1.Position));
- end;
- end;
- procedure TMainForm.dxBarButton64Click(Sender: TObject);
- begin
- if PlayState<>psPreview then
- begin
- Exit;
- end;
- Timer1.Enabled:=false;
- Playstate:=psNone;
- DllEndPreview();
- PausePreview:=false;
- Panel1.Invalidate;
- end;
- procedure TMainForm.dxBarButton65Click(Sender: TObject);
- begin
- if PausePreview then
- begin
- SpeedButton3.Click;
- PlayState:=psPreview;
- DllPreviewPlay();
- Timer1.Enabled:=true;
- end
- end;
- end.