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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
{Last.fm Player}
unit pl_LastFM;
interface
implementation
uses windows,common,messages,syswin,srv_player,wat_api;
const
LFMName = 'Last.fm Player';
LFMText = 'Last.fm';
LFMClass = 'QWidget';
const
UserName:pWideChar=nil;
function Check(wnd:HWND;aflags:integer):HWND;cdecl;
var
tmp,EXEName:PAnsiChar;
begin
if wnd<>0 then
begin
result:=0;
exit;
end;
result:=FindWindow(LFMClass,nil{LFMName});
if result<>0 then
begin
tmp:=Extract(GetEXEByWnd(result,EXEName),true);
if lstrcmpia(tmp,'LASTFM.EXE')<>0 then
result:=0;
mFreeMem(tmp);
mFreeMem(EXEName);
if result<>0 then
result:=GetWindow(result,GW_OWNER);
end;
if result=0 then
mFreeMem(UserName);
end;
function GetWndText(wnd:HWND):pWideChar;
var
ps:array [0..255] of WideChar;
p:pWideChar;
begin
SendMessageW(wnd,WM_GETTEXT,255,lparam(@ps));
p:=StrPosW(ps,' | ');
if p<>nil then
begin
mFreeMem(UserName);
StrDupW(UserName,p+3);
p^:=#0;
end;
StrDupW(result,ps);
end;
function GetFileName(wnd:HWND;flags:integer):PWideChar;cdecl;
var
buf:array [0..1023] of WideChar;
p:pWideChar;
begin
// lstrcpyw(buf,'http://');
buf[0]:=#0;
p:=GetWndText(wnd);
StrCatW(buf,p);
StrCatW(buf,'.mp3');
StrDupW(result,buf);
mFreeMem(p);
end;
function GetStatus(wnd:HWND):integer; cdecl;
var
txt:pWideChar;
begin
txt:=GetWndText(wnd);
if StrCmpW(txt,LFMText,Length(LFMText))<>0 then
result:=WAT_MES_PLAYING
else
result:=WAT_MES_STOPPED;
mFreeMem(txt);
end;
function GetInfo(var SongInfo:tSongInfo;aflags:integer):integer;cdecl;
begin
result:=0;
with SongInfo do
begin
fsize:=1;
if (aflags and WAT_OPT_CHANGES)<>0 then
begin
wndtext:=GetWndText(plwnd);
end
else
begin
end;
end;
end;
const
plRec:tPlayerCell=(
Desc :'Last.fm';
flags :WAT_OPT_LAST or WAT_OPT_SINGLEINST or WAT_OPT_HASURL;
Icon :0;
Init :nil;
DeInit :nil;
Check :@Check;
GetStatus:@GetStatus;
GetName :@GetFileName;
GetInfo :@GetInfo;
Command :nil;
URL :'http://www.lastfm.com/';
Notes :'Works by window title analysing only');
var
LocalPlayerLink:twPlayer;
procedure InitLink;
begin
LocalPlayerLink.Next:=PlayerLink;
LocalPlayerLink.This:=@plRec;
PlayerLink :=@LocalPlayerLink;
end;
initialization
// ServicePlayer(WAT_ACT_REGISTER,dword(@plRec));
InitLink;
end.
|