summaryrefslogtreecommitdiff
path: root/plugins/Watrack/players/pl_mpc.pas
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-10-08 18:43:29 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-10-08 18:43:29 +0000
commit864081102a5f252415f41950b3039a896b4ae9c5 (patch)
treec6b764651e9dd1f8f53b98eab05f16ba4a492a79 /plugins/Watrack/players/pl_mpc.pas
parentdb5149b48346c417e18add5702a9dfe7f6e28dd0 (diff)
Awkwars's plugins - welcome to our trunk
git-svn-id: http://svn.miranda-ng.org/main/trunk@1822 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Watrack/players/pl_mpc.pas')
-rw-r--r--plugins/Watrack/players/pl_mpc.pas117
1 files changed, 117 insertions, 0 deletions
diff --git a/plugins/Watrack/players/pl_mpc.pas b/plugins/Watrack/players/pl_mpc.pas
new file mode 100644
index 0000000000..a2127cea76
--- /dev/null
+++ b/plugins/Watrack/players/pl_mpc.pas
@@ -0,0 +1,117 @@
+{Media Player Classic}
+unit pl_MPC;
+{$include compilers.inc}
+
+interface
+
+implementation
+uses windows,common,wrapper,srv_player,wat_api;
+
+const
+ MPCClass98 = 'MediaPlayerClassicA';
+ MPCClassXP = 'MediaPlayerClassicW';
+ MPCTail = ' - Media Player Classic';
+
+function Check(wnd:HWND;flags:integer):HWND;cdecl;
+begin
+ result:=FindWindowEx(0,wnd,MPCClassXP,NIL);
+ if result=0 then
+ result:=FindWindowEx(0,wnd,MPCClass98,NIL);
+end;
+
+function chwnd(awnd:hwnd;Param:pdword):boolean; stdcall;
+var
+ s:array [0..31] of AnsiChar;
+ i:integer;
+begin
+ FillChar(s,SizeOf(s),0);
+ GetWindowTextA(awnd,s,30);
+ i:=StrIndex(PAnsiChar(@s),' / ');
+ if i<>0 then
+ begin
+ if Param^=0 then
+ begin
+ s[i-1]:=#0;
+ Param^:=TimeToInt(s);
+ end
+ else
+ begin
+ Param^:=TimeToInt(s+i+2);
+ end;
+ result:=false;
+ end
+ else
+ result:=true;
+end;
+
+function GetElapsedTime(wnd:HWND):integer;
+begin
+ result:=0;
+ if EnumChildWindows(wnd,@chwnd,int_ptr(@result)) then
+ result:=0;
+end;
+
+function GetTotalTime(wnd:HWND):integer;
+begin
+ result:=1;
+ if EnumChildWindows(wnd,@chwnd,int_ptr(@result)) then
+ result:=0;
+end;
+
+function GetWndText(wnd:HWND):pWidechar;
+var
+ p:pWideChar;
+begin
+ result:=GetDlgText(wnd);
+ if result<>nil then
+ begin
+ p:=StrPosW(result,MPCTail);
+ if p<>nil then
+ p^:=#0;
+ end;
+end;
+
+function GetInfo(var SongInfo:tSongInfo;flags:integer):integer;cdecl;
+begin
+ result:=0;
+ with SongInfo do
+ begin
+ if (flags and WAT_OPT_CHANGES)<>0 then
+ begin
+ time :=GetElapsedTime(SongInfo.plwnd);
+ wndtext:=GetWndText(SongInfo.plwnd);
+ end
+ else if total=0 then
+ total:=GetTotalTime(SongInfo.plwnd);
+ end;
+end;
+
+const
+ plRec:tPlayerCell=(
+ Desc :'MPC';
+ flags :WAT_OPT_HASURL;
+ Icon :0;
+ Init :nil;
+ DeInit :nil;
+ Check :@Check;
+ GetStatus:nil;
+ GetName :nil;
+ GetInfo :@GetInfo;
+ Command :nil;
+ URL :'http://gabest.org/';
+ Notes :nil);
+
+var
+ LocalPlayerLink:twPlayer;
+
+procedure InitLink;
+begin
+ LocalPlayerLink.Next:=PlayerLink;
+ LocalPlayerLink.This:=@plRec;
+ PlayerLink :=@LocalPlayerLink;
+end;
+
+initialization
+// ServicePlayer(WAT_ACT_REGISTER,dword(@plRec));
+ InitLink;
+end.