summaryrefslogtreecommitdiff
path: root/plugins/Watrack/players/pl_1by1.pas
blob: 630b825363275f9da3aa6449df032a135fa5a14f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{1by1 player}
unit pl_1by1;
{$include compilers.inc}

interface

implementation
uses windows,common,wrapper,srv_player,wat_api;

const
  ObOClass = '1by1WndClass';
  ObOTitle = '1by1 - The Directory Player';

function Check(wnd:HWND;flags:integer):HWND;cdecl;
begin
  if wnd<>0 then
  begin
    result:=0;
    exit;
  end;
  result:=FindWindow(ObOClass,NIL);
end;

{
  need to set 'Elapsed time in title bar'
          and 'Show : instead of ' as minute char'
}
function GetElapsedTime(wnd:HWND):integer;
var
  s,p:PAnsiChar;
begin
  result:=0;
  s:=GetDlgText(wnd,true);
  if s<>nil then
  begin
    if (s^>='0') and (s^<='9') then
    begin
      p:=StrScan(s,' ');
      if p<>nil then
        p^:=#0;
      result:=TimeToInt(s)
    end;
    mFreeMem(s);
  end;
end;

function GetInfo(var SongInfo:tSongInfo;flags:integer):integer;cdecl;
begin
  result:=0;
  if (flags and WAT_OPT_CHANGES)<>0 then
    SongInfo.time:=GetElapsedTime(SongInfo.plwnd);
end;

const
  plRec:tPlayerCell=(
    Desc     :'1by1';
    flags    :WAT_OPT_HASURL;
    Icon     :0;
    Init     :nil;
    DeInit   :nil;
    Check    :@Check;
    GetStatus:nil;
    GetName  :nil;
    GetInfo  :@GetInfo;
    Command  :nil;
    URL      :'http://www.mpesch3.de/';
    Notes    :'To get elapsed time, needs to set "Elapsed time in title bar" and '#13#10+
              '"Show : instead of '#39' as minute char" in player settings "Display" tab.'
);

var
  LocalPlayerLink:twPlayer;

procedure InitLink;
begin
  LocalPlayerLink.Next:=PlayerLink;
  LocalPlayerLink.This:=@plRec;
  PlayerLink          :=@LocalPlayerLink;
end;

initialization
//  ServicePlayer(WAT_ACT_REGISTER,dword(@plRec));
  InitLink;
end.