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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
{BeholderTV}
unit pl_behold;
{$include compilers.inc}
interface
implementation
uses windows,messages,common,wrapper,srv_player,wat_api;
const
WM_BHCMD = WM_USER+200;
WMBH_CHNLUP = WM_USER+203; // Ïåðåêëþ÷èòü íà ñëåäóþùèé êàíàë
WMBH_CHNLDOWN = WM_USER+204; // Ïåðåêëþ÷èòü íà ïðåäûäóùèé êàíàë
WMBH_VOLUMEUP = WM_USER+210; // Óâåëè÷èòü âûáðàííûé óðîâåíü
WMBH_VOLUMEDOWN = WM_USER+211; // Óìåíüøèòü âûáðàííûé óðîâåíü
WMBH_FREEZE = WM_USER+232; // Òðèããåð ñòîï-êàäðà
WMBH_SETVOLUME = WM_USER+280; // Óñòàíîâèòü óðîâåíü ãðîìêîñòè (LParam = 0..65535)
WMBH_GETVOLUME = WM_USER+281; // Ïîëó÷èòü òåêóùèé óðîâåíü ãðîìêîñòè (èñïîëüçîâàòü SendMessage, Result = 0..65535)
WMBH_GETVERSION = WM_USER+285; // Ïîëó÷èòü íîâåð âåðñèè ÏÎ (èñïîëüçîâàòü SendMessage)
const
TitleWndClass = 'TApplication';
EXEName = 'BEHOLDTV.EXE';
var
TitleWnd:HWND;
function enumproc(wnd:HWND; lParam:LPARAM):bool; stdcall;
var
buf:array [0..64] of AnsiChar;
begin
result:=true;
if GetClassNameA(wnd,buf,63)<>0 then
begin
if StrCmp(buf,TitleWndClass)=0 then
begin
TitleWnd:=wnd;
result:=false;
end
end;
end;
function Check(wnd:HWND;flags:integer):HWND;cdecl;
begin
if wnd<>0 then
begin
result:=0;
exit;
end;
result:=FindWindow('TMain','BeholdTV');
if result<>0 then
EnumThreadWindows(GetWindowThreadProcessId(result,nil),@enumproc,0);
end;
function GetVersion(wnd:HWND):integer;
begin
result:=DWORD(SendMessage(wnd,WM_BHCMD,WMBH_GETVERSION,0));
result:=((result shr 16) shl 8)+LoWord(result);
end;
function GetVersionText(ver:integer):PWideChar; //!!
begin
mGetMem(result,10*SizeOf(WideChar));
IntToStr(result+1,ver);
result[0]:=result[1];
result[1]:='.';
end;
function GetFileName(wnd:HWND;flags:integer):pWideChar;cdecl;
begin
result:=nil;
end;
function Pause(wnd:HWND):integer;
begin
result:=0;
PostMessage(wnd,WM_BHCMD,WMBH_FREEZE,0);
end;
function Next(wnd:HWND):integer;
begin
result:=0;
PostMessage(wnd,WM_BHCMD,WMBH_CHNLUP,0);
end;
function Prev(wnd:HWND):integer;
begin
result:=0;
PostMessage(wnd,WM_BHCMD,WMBH_CHNLDOWN,0);
end;
function GetVolume(wnd:HWND):cardinal;
begin
result:=WORD(SendMessage(wnd,WM_BHCMD,WMBH_GETVOLUME,0));
result:=(result shl 16)+(result shr 12);
end;
procedure SetVolume(wnd:HWND;value:cardinal);
begin
SendMessage(wnd,WM_BHCMD,WMBH_SETVOLUME,value shl 12);
end;
function VolDn(wnd:HWND):integer;
begin
result:=WORD(SendMessage(wnd,WM_BHCMD,WMBH_VOLUMEDOWN,0));
end;
function VolUp(wnd:HWND):integer;
begin
result:=WORD(SendMessage(wnd,WM_BHCMD,WMBH_VOLUMEUP,0));
end;
function GetInfo(var SongInfo:tSongInfo;flags:integer):integer;cdecl;
begin
result:=0;
if (flags and WAT_OPT_PLAYERDATA)<>0 then
begin
if SongInfo.plyver=0 then
begin
SongInfo.plyver:=GetVersion (SongInfo.plwnd);
SongInfo.txtver:=GetVersionText(SongInfo.plyver);
end;
exit;
end;
if (flags and WAT_OPT_CHANGES)<>0 then
SongInfo.wndtext:=GetDlgText(TitleWnd);
end;
function Command(wnd:HWND;cmd:integer;value:integer):integer;cdecl;
begin
case cmd of
WAT_CTRL_PREV : result:=Prev(wnd);
// WAT_CTRL_PLAY : result:=Play(wnd,pWideChar(value));
WAT_CTRL_PAUSE: result:=Pause(wnd);
// WAT_CTRL_STOP : result:=Stop(wnd);
WAT_CTRL_NEXT : result:=Next(wnd);
WAT_CTRL_VOLDN: result:=VolDn(wnd);
WAT_CTRL_VOLUP: result:=VolUp(wnd);
// WAT_CTRL_SEEK : result:=Seek(wnd,value);
else
result:=0;
end;
end;
const
plRec:tPlayerCell=(
Desc :'BeholdTV';
flags :WAT_OPT_HASURL;
Icon :0;
Init :nil;
DeInit :nil;
Check :@Check;
GetStatus:nil;
GetName :@GetFileName;
GetInfo :@GetInfo;
Command :@Command;
URL :nil;
Notes :'Still experimental, no tested. Can work not properly');
var
LocalPlayerLink:twPlayer;
procedure InitLink;
begin
LocalPlayerLink.Next:=PlayerLink;
LocalPlayerLink.This:=@plRec;
PlayerLink :=@LocalPlayerLink;
end;
initialization
// ServicePlayer(WAT_ACT_REGISTER,dword(@plRec));
InitLink;
end.
|