diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-10-08 18:43:29 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-10-08 18:43:29 +0000 |
commit | 864081102a5f252415f41950b3039a896b4ae9c5 (patch) | |
tree | c6b764651e9dd1f8f53b98eab05f16ba4a492a79 /plugins/Watrack/players | |
parent | db5149b48346c417e18add5702a9dfe7f6e28dd0 (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')
-rw-r--r-- | plugins/Watrack/players/mradio.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | plugins/Watrack/players/mradio.rc | 3 | ||||
-rw-r--r-- | plugins/Watrack/players/mradio.res | bin | 0 -> 1264 bytes | |||
-rw-r--r-- | plugins/Watrack/players/pl_1by1.pas | 84 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_aimp.pas | 376 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_apollo.pas | 263 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_behold.pas | 175 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_bs.pas | 252 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_cowon.pas | 392 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_foobar.pas | 534 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_itunes.pas | 392 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_la.pas | 141 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_lastfm.pas | 129 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_mmonkey.pas | 181 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_mpc.pas | 117 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_mradio.pas | 345 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_vlc.pas | 380 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_winamp.pas | 170 | ||||
-rw-r--r-- | plugins/Watrack/players/pl_wmp.pas | 128 |
19 files changed, 4062 insertions, 0 deletions
diff --git a/plugins/Watrack/players/mradio.ico b/plugins/Watrack/players/mradio.ico Binary files differnew file mode 100644 index 0000000000..7993fce57b --- /dev/null +++ b/plugins/Watrack/players/mradio.ico diff --git a/plugins/Watrack/players/mradio.rc b/plugins/Watrack/players/mradio.rc new file mode 100644 index 0000000000..ce858cbe82 --- /dev/null +++ b/plugins/Watrack/players/mradio.rc @@ -0,0 +1,3 @@ +LANGUAGE 0,0
+
+ICO_MRADIO ICON "mradio.ico"
diff --git a/plugins/Watrack/players/mradio.res b/plugins/Watrack/players/mradio.res Binary files differnew file mode 100644 index 0000000000..52d06f147d --- /dev/null +++ b/plugins/Watrack/players/mradio.res diff --git a/plugins/Watrack/players/pl_1by1.pas b/plugins/Watrack/players/pl_1by1.pas new file mode 100644 index 0000000000..630b825363 --- /dev/null +++ b/plugins/Watrack/players/pl_1by1.pas @@ -0,0 +1,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.
diff --git a/plugins/Watrack/players/pl_aimp.pas b/plugins/Watrack/players/pl_aimp.pas new file mode 100644 index 0000000000..17c52bc5b6 --- /dev/null +++ b/plugins/Watrack/players/pl_aimp.pas @@ -0,0 +1,376 @@ +{AIMP player}
+unit pl_AIMP;
+{$include compilers.inc}
+
+interface
+
+implementation
+uses windows,messages,common,srv_player,wat_api,winampapi;
+
+const
+ WM_AIMP_COMMAND = WM_USER + $75;
+ WM_AIMP_GET_VERSION = 4;
+ WM_AIMP_STATUS_GET = 1;
+ WM_AIMP_STATUS_SET = 2;
+ WM_AIMP_CALLFUNC = 3;
+const
+ AIMP_STS_Player = 4;
+ AIMP_STS_VOLUME = 1;
+ AIMP_STS_POS = 31;
+const
+ AIMP_PLAY = 15;
+ AIMP_PAUSE = 16;
+ AIMP_STOP = 17;
+ AIMP_NEXT = 18;
+ AIMP_PREV = 19;
+
+const
+ AIMP2_RemoteClass:PAnsiChar = 'AIMP2_RemoteInfo';
+const
+ AIMP2_RemoteFileSize = 2048;
+
+type
+ PAIMP2FileInfo = ^TAIMP2FileInfo;
+ TAIMP2FileInfo = packed record
+ cbSizeOF :dword;
+ //
+ nActive :LONGBOOL;
+ nBitRate :dword;
+ nChannels :dword;
+ nDuration :dword;
+ nFileSize :Int64;
+ nRating :dword;
+ nSampleRate :dword;
+ nTrackID :dword;
+ //
+ nAlbumLen :dword;
+ nArtistLen :dword;
+ nDateLen :dword;
+ nFileNameLen:dword;
+ nGenreLen :dword;
+ nTitleLen :dword;
+ //
+ sAlbum :dword; // size of pointer for 32 bit system
+ sArtist :dword;
+ sDate :dword;
+ sFileName :dword;
+ sGenre :dword;
+ sTitle :dword;
+ end;
+
+function Check(wnd:HWND;flags:integer):HWND;cdecl;
+begin
+ if wnd<>0 then
+ begin
+ result:=0;
+ exit;
+ end;
+ result:=FindWindowA(AIMP2_RemoteClass,AIMP2_RemoteClass);
+end;
+
+function GetVersionText(ver:integer):pWideChar;
+begin
+ if (ver and $F00)<>0 then
+ begin
+ mGetMem(result,8*SizeOf(WideChar));
+ result[0]:=WideChar((ver div 1000)+ORD('0'));
+ ver:=ver mod 1000;
+ result[1]:='.';
+ result[2]:=WideChar((ver div 100)+ORD('0'));
+ ver:=ver mod 100;
+ result[3]:='.';
+ result[4]:=WideChar((ver div 10)+ORD('0'));
+ result[5]:='.';
+ result[6]:=WideChar((ver mod 10)+ORD('0'));
+ result[7]:=#0;
+ end
+ else
+ result:=nil;
+end;
+
+function GetVersion(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_AIMP_COMMAND,WM_AIMP_GET_VERSION,0);
+end;
+
+function GetStatus(wnd:HWND):integer; cdecl;
+begin
+ result:=SendMessage(wnd,WM_AIMP_COMMAND,WM_AIMP_STATUS_GET,AIMP_STS_Player);
+end;
+
+function GetVolume(wnd:HWND):cardinal;
+begin
+ result:=SendMessage(wnd,WM_AIMP_COMMAND,WM_AIMP_STATUS_GET,AIMP_STS_VOLUME);
+ result:=(result shl 16)+round((result shl 4)/100);
+end;
+
+procedure SetVolume(wnd:HWND;value:cardinal);
+begin
+ SendMessage(wnd,WM_AIMP_COMMAND,WM_AIMP_STATUS_SET,
+ (AIMP_STS_VOLUME shl 16)+((value*100) shr 4));
+end;
+
+function VolDn(wnd:HWND):integer;
+var
+ val:dword;
+begin
+ result:=GetVolume(wnd);
+ val:=loword(result);
+ if val>0 then
+ SetVolume(wnd,val-1);
+end;
+
+function VolUp(wnd:HWND):integer;
+var
+ val:dword;
+begin
+ result:=GetVolume(wnd);
+ val:=loword(result);
+ if val<16 then
+ SetVolume(wnd,val+1);
+end;
+
+function GetFileName(wnd:HWND;flags:integer):pWideChar;cdecl;
+var
+ FFile:THANDLE;
+ pStr:pointer;
+ s:integer;
+ p:PAnsiChar;
+ pw,pw1:pWideChar;
+begin
+ result:=nil;
+ s:=AIMP2_RemoteFileSize;
+ p:=AIMP2_RemoteClass;
+ FFile:=OpenFileMappingA(FILE_MAP_READ,True,p);
+ pStr:=MapViewOfFile(FFile,FILE_MAP_READ,0,0,s);
+ try
+ if pStr<>nil then
+ begin
+ with PAIMP2FileInfo(pStr)^ do
+ begin
+ StrDupW(result,
+ pWideChar(PAnsiChar(pStr)+SizeOf(TAIMP2FileInfo)+
+ (nAlbumLen+nArtistLen+nDateLen)*SizeOf(WideChar)),
+ nFileNameLen);
+ // Delete rest index (like "filename.cue:3")
+ pw :=StrRScanW(result,':');
+ if pw<>nil then
+ begin
+ pw1:=StrScanW (result,':');
+ if pw<>pw1 then
+ pw^:=#0;
+ end;
+ end;
+ end;
+ finally
+ UnmapViewOfFile(pStr);
+ CloseHandle(FFile);
+ end;
+end;
+
+procedure TranslateRadio(var SongInfo:tSongInfo);
+var
+ pc,pc1:pWideChar;
+begin
+{
+ artist - album - title (radio)
+}
+ with SongInfo do
+ begin
+ if (artist=nil) and (title<>nil) then
+ begin
+ // Radio title
+ if (StrEndW(title)-1)^=')' then
+ begin
+ pc:=StrRScanW(title,'(');
+ if (pc<>nil) and (pc>title) and ((pc-1)^=' ') then
+ begin
+ if comment=nil then
+ begin
+ StrDupW(comment,pc+1);
+ (StrEndW(comment)-1)^:=#0;
+ end;
+ (pc-1)^:=#0;
+ end;
+ end;
+ // artist - title
+ pc:=StrPosW(title,' - ');
+ if pc<>nil then
+ begin
+ if artist=nil then
+ begin
+ pc^:=#0;
+ inc(pc,3);
+ StrDupW(artist,title);
+ end;
+ // artist - album - title
+ pc1:=StrPosW(pc,' - ');
+ if pc1<>nil then
+ begin
+ if album=nil then
+ begin
+ pc1^:=#0;
+ StrDupW(album,pc);
+ pc:=pc1+3;
+ end;
+ end;
+ pc1:=title;
+ StrDupW(title,pc);
+ mFreeMem(pc1);
+ end;
+ end;
+ end;
+end;
+
+function GetInfo(var SongInfo:tSongInfo;flags:integer):integer;cdecl;
+var
+ FFile:THANDLE;
+ s:integer;
+ p:PAnsiChar;
+ pStr:PAIMP2FileInfo;
+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;
+ if SongInfo.winampwnd=0 then
+ SongInfo.winampwnd:=WinampFindWindow(SongInfo.plwnd);
+ exit;
+ end;
+
+ if SongInfo.winampwnd<>0 then
+ WinampGetInfo(int_ptr(@SongInfo),flags);
+
+ if (flags and WAT_OPT_CHANGES)=0 then
+ begin
+ s:=AIMP2_RemoteFileSize;
+ p:=AIMP2_RemoteClass;
+ FFile:=OpenFileMappingA(FILE_MAP_READ,True,p);
+ pStr:=MapViewOfFile(FFile,FILE_MAP_READ,0,0,s);
+ try
+ if pStr<>nil then
+ begin
+ with SongInfo do
+ begin
+ with pStr^ do
+ begin
+ if channels=0 then channels:=nChannels;
+ if kbps =0 then kbps :=nBitRate div 1000;
+ if khz =0 then khz :=nSampleRate div 1000;
+ if total =0 then total :=nduration;
+ if fsize =0 then fsize :=nFileSize;
+ if track =0 then track :=nTrackID;
+
+ with PAIMP2FileInfo(pStr)^ do
+ begin
+ if (artist=nil) and (nArtistLen>0) then
+ begin
+ StrDupW(artist,
+ pWideChar(PAnsiChar(pStr)+SizeOf(TAIMP2FileInfo))+
+ nAlbumLen,nArtistLen);
+ end;
+ if (album=nil) and (nAlbumLen>0) then
+ begin
+ StrDupW(album,
+ pWideChar(PAnsiChar(pStr)+SizeOf(TAIMP2FileInfo)),
+ nAlbumLen);
+ end;
+ if (title=nil) and (nTitleLen>0) then
+ begin
+ StrDupW(title,
+ pWideChar(PAnsiChar(pStr)+SizeOf(TAIMP2FileInfo))+
+ nAlbumLen+nArtistLen+nDateLen+nFileNameLen+nGenreLen,
+ nTitleLen);
+ end;
+ if (year=nil) and (nDateLen>0) then
+ begin
+ StrDupW(year,
+ pWideChar(PAnsiChar(pStr)+SizeOf(TAIMP2FileInfo))+
+ nAlbumLen+nArtistLen,
+ nDateLen);
+ end;
+ if (genre=nil) and (nGenreLen>0) then
+ begin
+ StrDupW(genre,
+ pWideChar(PAnsiChar(pStr)+SizeOf(TAIMP2FileInfo))+
+ nAlbumLen+nArtistLen+nDateLen+nFileNameLen,
+ nGenreLen);
+ end;
+
+ if StrPosW(mfile,'://')<>nil then
+ TranslateRadio(SongInfo);
+ end;
+ end;
+ end;
+ end;
+ finally
+ UnmapViewOfFile(pStr);
+ CloseHandle(FFile);
+ end;
+ end
+ else // request AIMP changed data: volume
+ begin
+ SongInfo.time:=SendMessage(SongInfo.plwnd,WM_AIMP_COMMAND,WM_AIMP_STATUS_GET,AIMP_STS_POS);
+ SongInfo.volume:=GetVolume(SongInfo.plwnd);
+ end;
+end;
+
+function Command(wnd:HWND;cmd:integer;value:integer):integer;cdecl;
+var
+ WinampWindow:HWND;
+begin
+ WinampWindow:=WinampFindWindow(wnd);
+ if WinampWindow<>0 then
+ result:=WinampCommand(WinampWindow,cmd+(value shl 16))
+ else
+ begin
+ result:=0;
+ case cmd of
+ WAT_CTRL_PREV : SendMessage(wnd,WM_AIMP_COMMAND,WM_AIMP_CALLFUNC,AIMP_PREV);
+ WAT_CTRL_PLAY : SendMessage(wnd,WM_AIMP_COMMAND,WM_AIMP_CALLFUNC,AIMP_PLAY);
+ WAT_CTRL_PAUSE: SendMessage(wnd,WM_AIMP_COMMAND,WM_AIMP_CALLFUNC,AIMP_PAUSE);
+ WAT_CTRL_STOP : SendMessage(wnd,WM_AIMP_COMMAND,WM_AIMP_CALLFUNC,AIMP_STOP);
+ WAT_CTRL_NEXT : SendMessage(wnd,WM_AIMP_COMMAND,WM_AIMP_CALLFUNC,AIMP_NEXT);
+ WAT_CTRL_VOLDN: result:=VolDn(wnd);
+ WAT_CTRL_VOLUP: result:=VolUp(wnd);
+ WAT_CTRL_SEEK : begin
+ SendMessage(wnd,WM_AIMP_COMMAND,WM_AIMP_STATUS_SET,
+ (AIMP_STS_POS shl 16)+value);
+ end;
+ end;
+ end;
+end;
+
+const
+ plRec:tPlayerCell=(
+ Desc :'AIMP';
+ flags :WAT_OPT_APPCOMMAND or WAT_OPT_HASURL;
+ Icon :0;
+ Init :nil;
+ DeInit :nil;
+ Check :@Check;
+ GetStatus:@GetStatus;
+ GetName :@GetFileName;
+ GetInfo :@GetInfo;
+ Command :@Command;
+ URL :'http://www.aimp.ru/';
+ 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.
diff --git a/plugins/Watrack/players/pl_apollo.pas b/plugins/Watrack/players/pl_apollo.pas new file mode 100644 index 0000000000..360b23ab89 --- /dev/null +++ b/plugins/Watrack/players/pl_apollo.pas @@ -0,0 +1,263 @@ +{Apollo player}
+unit pl_Apollo;
+{$include compilers.inc}
+
+interface
+
+implementation
+uses windows,winampapi,messages,common,srv_player,wat_api;
+
+const
+ ApolloClass = 'Apollo - Main Window';
+
+const
+ WM_APOLLO_COMMAND = WM_USER+3;
+ APOLLO_GETVERSION = 0;
+ APOLLO_GETSTATUS = 1;
+ APOLLO_GETPLAYLISTPOSITION = 16;
+ APOLLO_GETCURRENTTRACKNUMBER = 17;
+ APOLLO_SETPLAYBACKPOSITION = 18;
+ APOLLO_GETPLAYBACKPOSITION = 19;
+ APOLLO_GETPLAYBACKCOUNTDOWN = 33;
+ APOLLO_GETCURRENTLYPLAYEDFILENAME = 24;
+ APOLLO_GETCURRENTLYPLAYEDTITLE = 25;
+ APOLLO_GETPLAYLISTENTRY = 26;
+ APOLLO_GETPLAYLISTTITLE = 27;
+// APOLLO_OPENURL = 4;
+ APOLLO_OPENFILE = 2;
+ APOLLO_PREVIOUSTRACK = 10;
+ APOLLO_STOP = 11;
+ APOLLO_PLAY = 12;
+ APOLLO_PAUSE = 13;
+ APOLLO_NEXTTRACK = 14;
+ APOLLO_SETVOLUME = 20;
+ APOLLO_GETVOLUME = 21;
+
+function Check(wnd:HWND;flags:integer):HWND;cdecl;
+begin
+ if wnd<>0 then
+ begin
+ result:=0;
+ exit;
+ end;
+ result:=FindWindow(ApolloClass,NIL)
+end;
+
+function GetVersion(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_GETVERSION,0);
+end;
+
+function GetVersionText(ver:integer):PWideChar;
+begin
+ mGetMem(result,5*SizeOf(WideChar));
+ IntToStr(result,ver);
+end;
+
+function GetStatus(wnd:HWND):integer; cdecl;
+begin
+ result:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_GETSTATUS,0);
+ if result>1 then
+ result:=2;
+end;
+
+function GetFileName(wnd:HWND;flags:integer):pWideChar;cdecl;
+var
+ tmpwnd:hwnd;
+ ps:array [0..255] of AnsiChar;
+begin
+ if GetStatus(wnd)<>WAT_MES_STOPPED then
+ begin
+ tmpwnd:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_GETCURRENTLYPLAYEDFILENAME,0);
+ ps[0]:=#0;
+ SendMessageA(tmpwnd,WM_GETTEXT,255,lparam(@ps));
+ if ps[0]<>#0 then
+ begin
+ mGetMem(result,(StrLen(ps)+1)*SizeOf(WideChar));
+ AnsiToWide(ps,result);
+ exit;
+ end;
+ end;
+ result:=nil;
+end;
+
+function GetWndText(wnd:HWND):pWideChar;
+var
+ tmpwnd:hwnd;
+ ps:array [0..255] of AnsiChar;
+begin
+ tmpwnd:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_GETCURRENTLYPLAYEDTITLE,0);
+ SendMessageA(tmpwnd,WM_GETTEXT,255,lparam(@ps));
+ mGetMem(result,(StrLen(ps)+1)*SizeOf(WideChar));
+ AnsiToWide(ps,result);
+end;
+
+function Play(wnd:HWND;fname:PWideChar=nil):integer;
+var
+ cds:COPYDATASTRUCT;
+begin
+ if (fname<>nil) and (fname^<>#0) then
+ begin
+ cds.dwData:=APOLLO_OPENFILE;
+ WideToAnsi(fname,PAnsiChar(cds.lpData));
+ cds.cbData:=StrLen(PAnsiChar(cds.lpData))+1;
+ SendMessage(wnd,WM_COPYDATA,0,lparam(@cds));
+ mFreeMem(cds.lpData);
+ end;
+ result:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_PLAY,0);
+end;
+
+function Pause(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_PAUSE,0);
+end;
+
+function Stop(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_STOP,0);
+end;
+
+function Next(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_NEXTTRACK,0);
+end;
+
+function Prev(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_PREVIOUSTRACK,0);
+end;
+
+function GetVolume(wnd:HWND):cardinal;
+begin
+ result:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_GETVOLUME,0);
+ result:=(result shl 16)+(result shr 12);
+end;
+
+procedure SetVolume(wnd:HWND;value:cardinal);
+begin
+ SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_SETVOLUME,value shl 12);
+end;
+
+function VolDn(wnd:HWND):integer;
+var
+ val:integer;
+begin
+ result:=GetVolume(wnd);
+ val:=loword(result);
+ if val>0 then
+ SetVolume(wnd,val-1);
+end;
+
+function VolUp(wnd:HWND):integer;
+var
+ val:integer;
+begin
+ result:=GetVolume(wnd);
+ val:=loword(result);
+ if val<16 then
+ SetVolume(wnd,val+1);
+end;
+
+function Seek(wnd:HWND;value:integer):integer;
+begin
+ result:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_GETPLAYBACKPOSITION,0);
+ if value>0 then
+ SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_SETPLAYBACKPOSITION,value);
+end;
+
+function GetRemoteTitle(wnd:HWND):pWideChar;
+var
+ tmpwnd:hwnd;
+ ps:array [0..255] of AnsiChar;
+ num:integer;
+begin
+ num :=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_GETPLAYLISTPOSITION,0);
+ tmpwnd:=SendMessage(wnd,WM_APOLLO_COMMAND,APOLLO_GETPLAYLISTTITLE ,num);
+ SendMessageA(tmpwnd,WM_GETTEXT,255,lparam(@ps));
+ mGetMem(result,(StrLen(ps)+1)*SizeOf(WideChar));
+ AnsiToWide(ps,result);
+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;
+ if SongInfo.winampwnd=0 then
+ SongInfo.winampwnd:=WinampFindWindow(SongInfo.plwnd);
+ exit;
+ end;
+
+ if SongInfo.winampwnd<>0 then
+ result:=WinampGetInfo(int_ptr(@SongInfo),flags);
+
+ if (flags and WAT_OPT_CHANGES)<>0 then
+ begin
+ with SongInfo do
+ begin
+ wndtext:=GetWndText(plwnd);
+ volume :=GetVolume (plwnd);
+ end
+ end
+ else
+ begin
+ with SongInfo do
+ begin
+ if (status<>WAT_MES_STOPPED) and
+ (mfile<>nil) and (StrPosW(mfile,'://')<>nil) and (album=nil) then
+ album:=GetRemoteTitle(plwnd);
+ end;
+ end;
+end;
+
+function Command(wnd:HWND;cmd:integer;value:int_ptr):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 :'Apollo';
+ flags :WAT_OPT_HASURL;
+ Icon :0;
+ Init :nil;
+ DeInit :nil;
+ Check :@Check;
+ GetStatus:@GetStatus;
+ GetName :@GetFileName;
+ GetInfo :@GetInfo;
+ Command :@Command;
+ URL :'http://www.iki.fi/hy/apollo/';
+ 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.
diff --git a/plugins/Watrack/players/pl_behold.pas b/plugins/Watrack/players/pl_behold.pas new file mode 100644 index 0000000000..977a021034 --- /dev/null +++ b/plugins/Watrack/players/pl_behold.pas @@ -0,0 +1,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.
diff --git a/plugins/Watrack/players/pl_bs.pas b/plugins/Watrack/players/pl_bs.pas new file mode 100644 index 0000000000..7fd2e9c5e5 --- /dev/null +++ b/plugins/Watrack/players/pl_bs.pas @@ -0,0 +1,252 @@ +{BSPlayer player}
+unit pl_BS;
+{$include compilers.inc}
+
+interface
+
+implementation
+uses windows,messages,common,srv_player,wat_api;
+
+const
+ HWND_MESSAGE = HWND(-3);
+const
+ BSPlayerClass = 'BSPlayer';
+const
+ WM_BSP_CMD = WM_USER+2;
+ BSP_GETVERSION = $10000;
+ BSP_GetMovLen = $10100;
+ BSP_GetMovPos = $10101;
+ BSP_GetStatus = $10102;
+ BSP_Seek = $10103;
+
+// BSP_LoadPlaylist = $1010C;
+ BSP_SetVol = $10104;
+ BSP_GetVol = $10105;
+ BSP_OpenFile = $10108;
+ BSP_GetFileName = $1010B;
+
+ BSP_VolUp = 1;
+ BSP_VolDown = 2;
+ BSP_Play = 20;
+ BSP_Pause = 21;
+ BSP_Stop = 22;
+ BSP_Prev = 25;
+ BSP_Next = 28;
+
+const
+ bspwnd:HWND = 0;
+
+function HiddenWindProc(wnd:HWnd; msg:UINT;wParam:WPARAM;lParam:LPARAM):integer; stdcall;
+begin
+ result:=DefWindowProc(wnd,msg,wParam,lParam);
+end;
+
+function Check(wnd:HWND;flags:integer):HWND;cdecl;
+begin
+ if wnd<>0 then
+ begin
+ result:=0;
+ exit;
+ end;
+ result:=FindWindow(BSPlayerClass,NIL);
+ if result=0 then
+ begin
+ if bspwnd<>0 then
+ begin
+ DestroyWindow(bspwnd);
+
+ bspwnd:=0;
+ end;
+ end
+ else if bspwnd=0 then
+ begin
+ bspwnd:=CreateWindowExW(0,'STATIC',nil,0,1,1,1,1,HWND_MESSAGE,0,hInstance,nil);
+ if bspwnd<>0 then
+ setwindowlongPtrW(bspwnd,GWL_WNDPROC,LONG_PTR(@HiddenWindProc));
+ end;
+end;
+
+function GetVersion(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_GETVERSION,0)
+end;
+
+function GetVersionText(ver:integer):pWideChar;
+begin
+ mGetMem(result,11*SizeOf(WideChar));
+ IntToHex(result,ver shr 24,2);
+ result[2]:='.';
+ IntToHex(result+3,(ver shr 16) and $FF,2);
+ result[5]:='.';
+ IntToHex(result+6,ver and $FFFF);
+end;
+
+function GetElapsedTime(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_GetMovPos,0) div 1000;
+end;
+
+function GetTotalTime(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_GetMovLen,0) div 1000;
+end;
+
+function GetStatus(wnd:HWND):integer; cdecl;
+begin
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_GetStatus,0);
+ if result=1 then result:=2
+ else if result=2 then result:=1;
+ if result>2 then result:=2;
+end;
+
+function GetFileName(wnd:HWND;flags:integer):pWideChar;
+var
+ cds:tcopyDataStruct;
+ buf:array [0..255] of AnsiChar;
+ adr:pointer;
+begin
+ adr:=@buf;
+ cds.dwData:=BSP_GetFileName;
+ cds.lpData:=@adr;
+ cds.cbData:=4;
+ SendMessage(wnd,WM_COPYDATA,bspwnd,lparam(@cds));
+
+ AnsiToWide(buf,result);
+end;
+
+function Play(wnd:HWND;fname:PWideChar=nil):integer;
+var
+ cds:COPYDATASTRUCT;
+begin
+ if (fname<>nil) and (fname^<>#0) then
+ begin
+ cds.dwData:=BSP_OpenFile;
+ WideToAnsi(fname,PAnsiChar(cds.lpData));
+ cds.cbData:=StrLen(PAnsiChar(cds.lpData))+1;
+ SendMessage(wnd,WM_COPYDATA,0{!!!},lparam(@cds));
+ mFreeMem(cds.lpData);
+ end;
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_Play,0);
+end;
+
+function Pause(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_Pause,0);
+end;
+
+function Stop(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_Stop,0);
+end;
+
+function Next(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_Next,0);
+end;
+
+function Prev(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_Prev,0);
+end;
+
+function VolDn(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_VolDown,0);
+end;
+
+function VolUp(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_VolUp,0);
+end;
+
+function GetVolume(wnd:HWND):cardinal;
+begin
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_GetVol,0);
+ result:=(result shl 16)+((result shl 4) div 25);
+end;
+
+procedure SetVolume(wnd:HWND;value:cardinal);
+begin
+ SendMessage(wnd,WM_BSP_CMD,BSP_SetVol,(value*25) shr 4);
+end;
+
+function Seek(wnd:HWND;value:integer):integer;
+begin
+ result:=SendMessage(wnd,WM_BSP_CMD,BSP_GetMovPos,0) div 1000;
+ SendMessage(wnd,WM_BSP_CMD,BSP_Seek,value*1000);
+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;
+
+ with SongInfo do
+ begin
+ if (flags and WAT_OPT_CHANGES)<>0 then
+ begin
+ volume:=GetVolume(plwnd);
+ if status<>WAT_MES_STOPPED then
+ time:=GetElapsedTime(plwnd);
+ end
+ else
+ begin
+ if total=0 then
+ total:=GetTotalTime(plwnd);
+ end;
+ end;
+end;
+
+function Command(wnd:HWND;cmd:integer;value:int_ptr):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 :'BSPlayer';
+ flags :WAT_OPT_HASURL;
+ Icon :0;
+ Init :nil;
+ DeInit :nil;
+ Check :@Check;
+ GetStatus:@GetStatus;
+ GetName :@GetFileName;
+ GetInfo :@GetInfo;
+ Command :@Command;
+ URL :'http://www.bsplayer.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.
diff --git a/plugins/Watrack/players/pl_cowon.pas b/plugins/Watrack/players/pl_cowon.pas new file mode 100644 index 0000000000..0977ea4b20 --- /dev/null +++ b/plugins/Watrack/players/pl_cowon.pas @@ -0,0 +1,392 @@ +{COWON JetAudio player}
+unit pl_cowon;
+{$include compilers.inc}
+
+interface
+
+implementation
+uses windows,winampapi,wrapper,messages,common,srv_player,wat_api;
+
+const
+ HWND_MESSAGE = HWND(-3);
+const
+ HOSTWND_CLASS = 'TLB_JETAUDIO';
+
+ CowonClass = 'COWON Jet-Audio MainWnd Class';
+ CowonTitle = 'Afx:400000:8:0:0:'; // for example 'Afx:400000:8:0:0:18c300fd'
+ ControlClass = 'COWON Jet-Audio Remocon Class';
+ ControlName = 'Jet-Audio Remote Control';
+ PluginClass = 'Streamzap.WMX';
+ PluginName = 'Jet-Audio Remote Plugin';
+const
+ MCI_STRING_OFFSET = 512;
+ MCI_MODE_NOT_READY = MCI_STRING_OFFSET + 12;
+ MCI_MODE_STOP = MCI_STRING_OFFSET + 13;
+ MCI_MODE_PLAY = MCI_STRING_OFFSET + 14;
+ MCI_MODE_RECORD = MCI_STRING_OFFSET + 15;
+ MCI_MODE_SEEK = MCI_STRING_OFFSET + 16;
+ MCI_MODE_PAUSE = MCI_STRING_OFFSET + 17;
+ MCI_MODE_OPEN = MCI_STRING_OFFSET + 18;
+
+ WM_REMOCON_GETSTATUS = WM_APP+740;
+ WM_REMOCON_SENDCOMMAND = WM_APP+741;
+
+ JRC_ID_STOP = 5102;
+ JRC_ID_PLAY = 5104; // Track Number (>=1). Use 0 for normal playback.
+ JRC_ID_PREV_TRACK = 5107;
+ JRC_ID_NEXT_TRACK = 5108;
+ JRC_ID_VOL_DOWN = 5134;
+ JRC_ID_VOL_UP = 5135;
+ JRC_ID_SET_VOLUME = 5180; // Volume Value (0 - 32)
+ JRC_ID_SEEK = 5192; // New position (second)
+ JRC_ID_RANDOMMODE = 5117;
+
+ GET_STATUS_STATUS = 1;
+ GET_STATUS_CUR_TRACK = 8;
+ GET_STATUS_CUR_TIME = 9;
+ GET_STATUS_MAX_TIME = 10;
+ GET_STATUS_TRACK_FILENAME = 11;
+ GET_STATUS_TRACK_TITLE = 12;
+ GET_STATUS_TRACK_ARTIST = 13;
+
+ GET_STATUS_VOLUME = 127;
+
+ JRC_COPYDATA_ID_ALBUMNAME = $1000;
+ JRC_COPYDATA_ID_GETVER = $1002;
+ JRC_COPYDATA_ID_TRACK_FILENAME = $3000;
+ JRC_COPYDATA_ID_TRACK_TITLE = $3001;
+ JRC_COPYDATA_ID_TRACK_ARTIST = $3002;
+
+ PLAY_NORMAL = 0;
+ PLAY_RANDOM = 1;
+
+ GET_STATUS_JETAUDIO_VER1 = 995;
+ GET_STATUS_JETAUDIO_VER2 = 996;
+ GET_STATUS_JETAUDIO_VER3 = 997;
+
+const
+ titlewnd:HWND = 0;
+ hostwnd :HWND = 0;
+ tmpstr :pWideChar=nil;
+
+function HiddenWindProc(wnd:HWnd; msg:UINT;wParam:WPARAM;lParam:LPARAM):integer; stdcall;
+var
+ cds:PCOPYDATASTRUCT;
+begin
+ case msg of
+ WM_COPYDATA: begin
+ cds:=PCOPYDATASTRUCT(lParam);
+ case cds^.dwData of
+ JRC_COPYDATA_ID_TRACK_FILENAME,
+ JRC_COPYDATA_ID_TRACK_TITLE ,
+ JRC_COPYDATA_ID_TRACK_ARTIST : AnsiToWide(cds^.lpData,tmpstr);
+ end;
+ result:=1;
+ exit;
+ end;
+ end;
+ result:=DefWindowProc(wnd,msg,wParam,lParam);
+end;
+
+function Init:integer;cdecl;
+begin
+ hostwnd:=CreateWindowExW(0,'STATIC',nil,0,1,1,1,1,HWND_MESSAGE,0,hInstance,nil);
+ if hostwnd<>0 then
+ SetWindowLongPtrW(hostwnd,GWL_WNDPROC,LONG_PTR(@HiddenWindProc));
+ result:=hostwnd;
+end;
+
+function DeInit:integer;cdecl;
+begin
+ result:=0;
+ if hostwnd<>0 then
+ begin
+ DestroyWindow(hostwnd);
+ hostwnd:=0;
+ end;
+end;
+
+function chwnd(awnd:hwnd;param:pdword):boolean; stdcall;
+var
+ s:array [0..255] of AnsiChar;
+begin
+ result:=true;
+ if GetClassNameA(awnd,s,255)>0 then
+ begin
+ if StrCmp(s,CowonTitle,Length(CowonTitle))=0 then
+ begin
+ param^:=awnd;
+ 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(ControlClass,ControlName);
+{
+ if result=0 then
+ result:=FindWindow(PluginClass,PluginName);
+}
+ if (result<>0) {and (result<>wnd)} then
+ if EnumWindows(@chwnd,int_ptr(@titlewnd)) then
+ titlewnd:=0;
+end;
+
+function GetWndText:pWideChar;
+var
+ p:pWideChar;
+begin
+ result:=nil;
+ if titlewnd<>0 then
+ begin
+ result:=GetDlgText(titlewnd);
+ if result<>nil then
+ begin
+ if StrScanW(result,'[')<>nil then
+ begin
+ p:=StrScanW(result,']');
+ if p<>nil then
+ begin
+ StrCopyW(result,p+1);
+ end;
+ end;
+ end;
+ end;
+end;
+
+function GetVersion(wnd:HWND):integer;
+begin
+ result:= SendMessage(wnd,WM_REMOCON_GETSTATUS,0,GET_STATUS_JETAUDIO_VER1);
+ result:=(result shl 8)+SendMessage(wnd,WM_REMOCON_GETSTATUS,0,GET_STATUS_JETAUDIO_VER2);
+ result:=(result shl 8)+SendMessage(wnd,WM_REMOCON_GETSTATUS,0,GET_STATUS_JETAUDIO_VER3);
+end;
+
+function GetVersionText(ver:integer):PWideChar;
+{var
+ ver:integer;
+begin
+ ver:=GetVersion;
+ mGetMem(result,11*SizeOf(WideChar));
+ IntToHex(result,ver shr 16,2);
+ result[2]:='.';
+ IntToHex(result+3,(ver shr 8) and $FF,2);
+ result[5]:='.';
+ IntToHex(result+6,ver and $FF);
+}
+var
+ s:array [0..31] of WideChar;
+ i:integer;
+begin
+ i:=StrLenW(IntToStr(s,ver shr 16));
+ s[i]:='.';
+ i:=integer(StrLenW(IntToStr(pWideChar(@s[i+1]),(ver shr 8) and $FF)))+i+1;
+ s[i]:='.';
+ IntToStr(pWideChar(@s[i+1]),ver and $FF);
+ StrDupW(result,PWideChar(@s));
+end;
+
+function GetStatus(wnd:HWND):integer; cdecl;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_GETSTATUS,0,GET_STATUS_STATUS);
+ case result of
+ MCI_MODE_STOP : result:=WAT_MES_STOPPED;
+ MCI_MODE_PAUSE: result:=WAT_MES_PAUSED;
+ MCI_MODE_PLAY : result:=WAT_MES_PLAYING;
+ else
+ result:=WAT_MES_UNKNOWN;
+ end;
+end;
+
+function GetFileName(wnd:HWND;flags:integer):pWideChar;cdecl;
+begin
+ SendMessage(wnd,WM_REMOCON_GETSTATUS,hostwnd,GET_STATUS_TRACK_FILENAME);
+ result:=tmpstr;
+end;
+
+function GetArtist(wnd:HWND):pWideChar;
+begin
+ SendMessage(wnd,WM_REMOCON_GETSTATUS,hostwnd,GET_STATUS_TRACK_ARTIST);
+ result:=tmpstr;
+end;
+
+function GetTitle(wnd:HWND):pWideChar;
+begin
+ SendMessage(wnd,WM_REMOCON_GETSTATUS,hostwnd,GET_STATUS_TRACK_TITLE);
+ result:=tmpstr;
+end;
+
+function GetTrack(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_GETSTATUS,0,GET_STATUS_CUR_TRACK);
+end;
+
+function GetTotalTime(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_GETSTATUS,0,GET_STATUS_MAX_TIME) div 1000;
+end;
+
+function GetElapsedTime(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_GETSTATUS,0,GET_STATUS_CUR_TIME) div 1000;
+end;
+
+function Play(wnd:HWND;fname:PWideChar=nil):integer;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_SENDCOMMAND,0,JRC_ID_PLAY);
+end;
+
+function Pause(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_SENDCOMMAND,0,JRC_ID_PLAY);
+end;
+
+function Stop(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_SENDCOMMAND,0,JRC_ID_STOP);
+end;
+
+function Next(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_SENDCOMMAND,0,JRC_ID_NEXT_TRACK);
+end;
+
+function Prev(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_SENDCOMMAND,0,JRC_ID_PREV_TRACK);
+end;
+
+function VolDn(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_SENDCOMMAND,0,JRC_ID_VOL_DOWN);
+end;
+
+function VolUp(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_SENDCOMMAND,0,JRC_ID_VOL_UP);
+end;
+
+function GetVolume(wnd:HWND):cardinal;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_GETSTATUS,0,GET_STATUS_VOLUME);
+ result:=(result shl 16)+(result shr 1);
+end;
+
+procedure SetVolume(wnd:HWND;value:cardinal);
+begin
+ SendMessage(wnd,WM_REMOCON_SENDCOMMAND,0,JRC_ID_SET_VOLUME+(value shl 17));
+end;
+
+function Seek(wnd:HWND;value:integer):integer;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_SENDCOMMAND,0,JRC_ID_SEEK+(value shl 16));
+end;
+{
+function Shuffle(setOn:integer):integer;
+begin
+ result:=SendMessage(wnd,WM_REMOCON_GETSTATUS,0,GETSTATUS_COMPONENT_RANDOMMODE);
+ SendMessage(wnd,WM_REMOCON_SENDCOMMAND,JRC_ID_RANDOMMODE+(SetOn shl 16));
+end;
+}
+
+function GetInfo(var SongInfo:tSongInfo;flags:integer):integer;cdecl;
+var
+ p:pWideChar;
+begin
+ result:=0;
+// result:=CallService(MS_WAT_WINAMPINFO,integer(@SongInfo),flags);
+// result:=WinampGetInfo(integer(@SongInfo),flags);
+ 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;
+
+ with SongInfo do
+ begin
+ if (flags and WAT_OPT_CHANGES)<>0 then
+ begin
+ wndtext:=GetWndText;
+ volume :=GetVolume(plwnd);
+ if status<>WAT_MES_STOPPED then
+// if time=0 then
+ time:=GetElapsedTime(plwnd);
+ end
+ else
+ begin
+
+ if artist=NIL then
+ begin
+ artist:=GetArtist(plwnd);
+ if artist^=#0 then
+ mFreeMem(artist);
+ end;
+ if title =NIL then
+ begin
+ title:=GetTitle(plwnd);
+ p:=ExtractW(mfile,true);
+ if (title^=#0) or (StrCmpW(title,p)=0) then
+ mFreeMem(title);
+ mFreeMem(p);
+ end;
+
+ if total=0 then
+ total:=GetTotalTime(plwnd);
+ end;
+ end;
+end;
+
+function Command(wnd:HWND;cmd:integer;value:int_ptr):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 :'Cowon JetAudio';
+ flags :WAT_OPT_HASURL;
+ Icon :0;
+ Init :@Init;
+ DeInit :@DeInit;
+ Check :@Check;
+ GetStatus:@GetStatus;
+ GetName :@GetFileName;
+ GetInfo :@GetInfo;
+ Command :@Command;
+ URL :'http://www.jetaudio.com/';
+ 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.
diff --git a/plugins/Watrack/players/pl_foobar.pas b/plugins/Watrack/players/pl_foobar.pas new file mode 100644 index 0000000000..f861db6327 --- /dev/null +++ b/plugins/Watrack/players/pl_foobar.pas @@ -0,0 +1,534 @@ +{Foobar2000 player}
+unit pl_Foobar;
+{$include compilers.inc}
+
+interface
+
+implementation
+uses {$IFDEF KOL_MCK}err,{$ENDIF}
+ windows,common,syswin,wrapper,srv_player,messages,wat_api,winampapi
+ {$IFDEF DELPHI_7_UP}
+ ,variants
+ {$ENDIF}
+ {$IFDEF KOL_MCK}
+ ,kolcomobj
+ {$ELSE}
+ ,ComObj
+ {$ENDIF}
+;
+
+const
+ COMName:PAnsiChar = 'Foobar2000.Application.0.7';
+const
+ dummywnd = 'uninteresting';
+const
+ FooExe = 'FOOBAR2000.EXE';
+ FooPrefix = 'foobar2000 v';
+const
+ FooBarClassExt = '{97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}';
+ FooBarClassNew = '{DA7CD0DE-1602-45e6-89A1-C2CA151E008E}';
+ FooBarClassAdd = '{E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}';
+(*
+ class1='{B73733CA-9B0A-4f53-93FA-AC95D4FF2166}';
+ text1='Cthulhu fhtagn!';
+
+ '{53229DFC-A273-45cd-A3A4-161FA9FC6414}';
+ '{641C2469-355C-4d6f-9663-E714382DA462}';
+*)
+var
+ WinampWindow:HWND;
+
+function proc(awnd:hwnd;param:pdword):boolean; stdcall;
+var
+ s:array [0..255] of AnsiChar;
+begin
+ result:=true;
+ if (awnd<>param^) and (GetClassNameA(awnd,s,255)>0) then
+ begin
+ s[Length(FooBarClassNew)]:=#0;
+ if (StrCmp(s,FooBarClassExt)=0) or
+ (StrCmp(s,FooBarClassNew)=0) or
+ (StrCmp(s,FooBarClassAdd)=0) then
+ begin
+ GetWindowTextA(awnd,s,255);
+ if StrCmp(s,dummywnd)<>0 then
+ param^:=awnd;
+// if WinampWindow<>0 then
+// result:=false;
+ end
+
+ else if (WinampWindow=0) and (StrCmp(s,WinampClass)=0) then
+ begin
+ WinampWindow:=awnd;
+ end;
+
+ end;
+end;
+
+function Check(wnd:HWND;flags:integer):HWND;cdecl;
+var
+ tmp,EXEName:PAnsiChar;
+ lwnd:HWND;
+ ltmp:bool;
+begin
+ if wnd<>0 then
+ begin
+ result:=0;
+ exit;
+ end;
+ lwnd:=0;
+ repeat
+ lwnd:=FindWindowEx(0,lwnd,nil,dummywnd);
+ if lwnd=0 then
+ break;
+ tmp:=Extract(GetEXEByWnd(lwnd,EXEName),true);
+ mFreeMem(EXEName);
+ ltmp:=lstrcmpia(tmp,FooExe)=0;
+ mFreeMem(tmp);
+ if ltmp then
+ begin
+ WinampWindow:=0;
+ EnumThreadWindows(GetWindowThreadProcessId(lwnd,nil),@proc,int_ptr(@lwnd));
+ break;
+ end;
+ until false;
+ result:=lwnd;
+end;
+
+function GetYear(const v:variant):PWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.Playback.FormatTitle('[%year%]'))));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetArtist(const v:variant):PWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.Playback.FormatTitle('[%artist%]'))));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetTitle(const v:variant):PWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.Playback.FormatTitle('[%title%]'))));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetAlbum(const v:variant):PWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.Playback.FormatTitle('[%album%]'))));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetGenre(const v:variant):PWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.Playback.FormatTitle('[%genre%]'))));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetBitrate(const v:variant):integer;
+begin
+ try
+ result:=v.Playback.FormatTitle('%bitrate%');
+ except
+ result:=0;
+ end;
+end;
+
+function GetSamplerate(const v:variant):integer;
+begin
+ try
+ result:=v.Playback.FormatTitle('%samplerate%');
+ except
+ result:=0;
+ end;
+end;
+
+function GetChannels(const v:variant):integer;
+var
+ s:WideString;
+begin
+ result:=0;
+ try
+ s:=v.Playback.FormatTitle('%channels%');
+ if StrCmpW(pWideChar(s),'mono')=0 then
+ result:=1
+ else if StrCmpW(pWideChar(s),'Stereo')=0 then
+ result:=2;
+ except
+ end;
+end;
+
+function GetCodec(const v:variant):integer;
+var
+ s:WideString;
+ i:integer;
+begin
+ result:=0;
+ try
+ s:=v.Playback.FormatTitle('%codec%');
+ i:=Length(s);
+ if i>0 then result:=ORD(s[1]);
+ if i>1 then result:=result+(ORD(s[2]) shl 8);
+ if i>2 then result:=result+(ORD(s[3]) shl 16);
+ if i>3 then result:=result+(ORD(s[4]) shl 24);
+ except
+ end;
+end;
+
+function SplitVersion(p:pWideChar):integer;
+begin
+ result:=StrToInt(p);
+ while (p^>='0') and (p^<='9') do inc(p); inc(p);
+ result:=result*16+StrToInt(p);
+ while (p^>='0') and (p^<='9') do inc(p); inc(p);
+ result:=result*16+StrToInt(p);
+ while (p^>='0') and (p^<='9') do inc(p);
+ if p^<>#0 then inc(p);
+ if (p^>='0') and (p^<='9') then
+ begin
+ result:=result*16+StrToInt(p);
+ while (p^>='0') and (p^<='9') do inc(p);
+ end;
+ if p^<>#0 then
+ begin
+ inc(p);
+ while (p^<>#0) and (p^<>' ') do inc(p);
+ if p^=' ' then
+ begin
+ inc(p);
+ result:=result*16+StrToInt(p);
+ end;
+ end;
+end;
+
+function GetVersion(const ver:pWideChar):integer;
+begin
+ if (ver=nil) or (ver^=#0) then
+ result:=0
+ else
+ result:=SplitVersion(ver);
+end;
+
+function GetVersionText(const v:variant):PWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.Name))+length(FooPrefix));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetTotalTime(const v:variant):integer;
+begin
+ try
+ result:=v.Playback.Length;
+ except
+ result:=0;
+ end;
+end;
+
+function GetElapsedTime(const v:variant):integer;
+begin
+ try
+ result:=v.Playback.Position;
+ except
+ result:=0;
+ end;
+end;
+
+function GetStatus(wnd:HWND):integer; cdecl;
+var
+ tmp:boolean;
+ v:variant;
+ winampwnd:HWND;
+begin
+ try
+ result:=WAT_MES_STOPPED;
+ v:=GetActiveOleObject(COMName);
+ tmp:=v.Playback.IsPaused;
+ if tmp then
+ result:=WAT_MES_PAUSED
+ else
+ begin
+ tmp:=v.Playback.IsPlaying;
+ if tmp then
+ result:=WAT_MES_PLAYING;
+ end;
+ except
+ winampwnd:=WinampFindWindow(wnd);
+ if winampwnd<>0 then
+ result:=WinampGetStatus(winampwnd)
+ else
+ result:=WAT_MES_UNKNOWN;
+ end;
+ v:=null;
+end;
+
+function GetWndText(wnd:HWND):pWideChar;
+var
+ i:integer;
+begin
+ result:=GetDlgText(wnd);
+ if result<>nil then
+ begin
+ i:=StrIndexW(result,'[foobar');
+ if i<>0 then
+ begin
+ dec(i);
+ repeat
+ dec(i);
+ if ord(result[i])>ord(' ') then break;
+ until i<0;
+ result[i+1]:=#0;//if at end
+ end;
+ end;
+end;
+
+function GetFileName(wnd:HWND;flags:integer):PWideChar;cdecl;
+var
+ v:variant;
+begin
+ try
+ v:=GetActiveOleObject(COMName);
+// v:=CreateOleObject(COMName);
+ StrDupW(result,PWideChar(WideString(v.Playback.FormatTitle('%path%'))));
+ except
+ result:=nil;
+ end;
+ v:=Null;
+end;
+
+function Play(const v:variant;fname:PWideChar=nil):integer;
+begin
+ try
+ result:=v.Playback.Start(false);
+ except
+ result:=0;
+ end;
+end;
+
+function Pause(const v:variant):integer;
+begin
+ try
+ result:=v.Playback.Pause;
+ except
+ result:=0;
+ end;
+end;
+
+function Stop(const v:variant):integer;
+begin
+ try
+ result:=v.Playback.Stop;
+ except
+ result:=0;
+ end;
+end;
+
+function Next(const v:variant):integer;
+begin
+ try
+ result:=v.Playback.Next;
+ except
+ result:=0;
+ end;
+end;
+
+function Prev(const v:variant):integer;
+begin
+ try
+ result:=v.Playback.Previous;
+ except
+ result:=0;
+ end;
+end;
+
+function GetVolume(const v:variant):cardinal;
+begin
+ try
+ result:=v.Playback.Settings.Volume+100;
+ result:=(result shl 16)+round((result shl 4) / 100);
+ except
+ result:=0;
+ end;
+end;
+
+procedure SetVolume(const v:variant;value:cardinal);
+begin
+ try
+ v.Playback.Settings.Volume:=integer(((loword(value)*100) shr 4)-100);
+ except
+ end;
+end;
+
+function VolDn(const v:variant):integer;
+var
+ val:integer;
+begin
+ result:=GetVolume(v);
+ val:=loword(result);
+ if val>0 then
+ SetVolume(v,val-1);
+end;
+
+function VolUp(const v:variant):integer;
+var
+ val:integer;
+begin
+ result:=GetVolume(v);
+ val:=loword(result);
+ if val<16 then
+ SetVolume(v,val+1);
+end;
+
+function Seek(const v:variant;value:integer):integer;
+begin
+ try
+ result:=v.Playback.Position;
+ if (value>0) and (v.Playback.CanSeek) and (value<v.Playback.Length) then
+ v.Playback.Seek(value)
+ else
+ result:=0;
+ except
+ result:=0;
+ end;
+end;
+
+function GetInfo(var SongInfo:tSongInfo;flags:integer):integer;cdecl;
+var
+ v:variant;
+begin
+ result:=0;
+ with SongInfo do
+ begin
+ try
+ v:=GetActiveOleObject(COMName);
+// v:=CreateOleObject(COMName);
+ if (flags and WAT_OPT_PLAYERDATA)<>0 then
+ begin
+ if SongInfo.plyver=0 then
+ begin
+ SongInfo.txtver:=GetVersionText(v);
+ SongInfo.plyver:=GetVersion(txtver);
+ end;
+ end
+ else if (flags and WAT_OPT_CHANGES)<>0 then
+ begin
+ volume:=GetVolume(v);
+ if status<>WAT_MES_STOPPED then
+ time:=GetElapsedTime(v);
+ end
+ else
+ begin
+ if kbps =0 then kbps :=GetBitrate(v);
+ if khz =0 then khz :=GetSamplerate(v);
+ if channels=0 then channels:=GetChannels(v);
+ if codec =0 then codec :=GetCodec(v);
+ if total =0 then total :=GetTotalTime(v);
+ if year =NIL then year :=GetYear(v);
+ if artist =NIL then artist :=GetArtist(v);
+ if title =NIL then title :=GetTitle(v);
+ if album =NIL then album :=GetAlbum(v);
+ if genre =NIL then genre :=GetGenre(v);
+ end;
+ except
+ SongInfo.winampwnd:=WinampWindow;
+ if SongInfo.winampwnd<>0 then
+ begin
+ result:=WinampGetInfo(int_ptr(@SongInfo),flags);
+ end;
+ end;
+ v:=Null;
+ if (flags and WAT_OPT_CHANGES)<>0 then
+ wndtext:=GetWndText(SongInfo.plwnd);
+ end;
+end;
+
+function Command(wnd:HWND;cmd:integer;value:int_ptr):integer;cdecl;
+//var
+// c:integer;
+var
+ v:Variant;
+begin
+ result:=0;
+ try
+ v:=GetActiveOleObject(COMName);
+ case cmd of
+ WAT_CTRL_PREV : result:=Prev (v);
+ WAT_CTRL_PLAY : result:=Play (v,pWideChar(value));
+ WAT_CTRL_PAUSE: result:=Pause(v);
+ WAT_CTRL_STOP : result:=Stop (v);
+ WAT_CTRL_NEXT : result:=Next (v);
+ WAT_CTRL_VOLDN: result:=VolDn(v);
+ WAT_CTRL_VOLUP: result:=VolUp(v);
+ WAT_CTRL_SEEK : result:=Seek (v,value);
+ end;
+ except
+ if WinampWindow<>0 then
+ result:=WinampCommand(WinampWindow,cmd+(value shl 16))
+{
+ else
+ begin
+ case cmd of
+ WAT_CTRL_PREV : c:=ORD('B');
+ WAT_CTRL_PLAY : c:=ORD('C');
+ WAT_CTRL_PAUSE: c:=ORD('X');
+ WAT_CTRL_STOP : c:=ORD('Z');
+ WAT_CTRL_NEXT : c:=ORD('V');
+ WAT_CTRL_VOLDN: c:=VK_SUBTRACT;
+ WAT_CTRL_VOLUP: c:=VK_ADD;
+ else
+ exit;
+ end;
+ PostMessageW(wnd,WM_KEYDOWN,c,1);
+ end;
+}
+ end;
+ v:=Null;
+end;
+
+const
+ plRec:tPlayerCell=(
+ Desc :'foobar2000';
+ flags :WAT_OPT_SINGLEINST or WAT_OPT_HASURL;
+ Icon :0;
+ Init :nil;
+ DeInit :nil;
+ Check :@Check;
+ GetStatus:@GetStatus;
+ GetName :@GetFileName;
+ GetInfo :@GetInfo;
+ Command :@Command;
+ URL :'http://www.foobar2000.org/';
+ Notes :'For more full info WinampSpam or foo_comserver (more powerful) '#13#10+
+ 'components needs to be installed.');
+
+var
+ LocalPlayerLink:twPlayer;
+
+procedure InitLink;
+begin
+ LocalPlayerLink.Next:=PlayerLink;
+ LocalPlayerLink.This:=@plRec;
+ PlayerLink :=@LocalPlayerLink;
+end;
+
+initialization
+// ServicePlayer(WAT_ACT_REGISTER,dword(@plRec));
+ InitLink;
+end.
diff --git a/plugins/Watrack/players/pl_itunes.pas b/plugins/Watrack/players/pl_itunes.pas new file mode 100644 index 0000000000..f43e6bac91 --- /dev/null +++ b/plugins/Watrack/players/pl_itunes.pas @@ -0,0 +1,392 @@ +{iTunes player}
+unit pl_iTunes;
+{$include compilers.inc}
+
+interface
+
+implementation
+uses windows,common,srv_player,wat_api
+ {$IFDEF DELPHI_7_UP}
+ ,variants
+ {$ENDIF}
+ {$IFDEF KOL_MCK}
+ ,kolcomobj
+ {$ELSE}
+ ,ComObj
+ {$ENDIF}
+;
+
+const
+ iTunesClass = 'iTunes';
+ iTunesTitle = 'iTunes';
+ COMName = 'iTunes.Application';
+
+function Check(wnd:HWND;flags:integer):HWND;cdecl;
+begin
+ if wnd<>0 then
+ begin
+ result:=0;
+ exit;
+ end;
+ result:=FindWindow(iTunesClass,iTunesTitle);
+end;
+
+function GetFileName(wnd:HWND;flags:integer):PWideChar;cdecl;
+var
+ v:variant;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ StrDupW(result,PWideChar(WideString(v.CurrentTrack.Location)));
+ except
+ result:=nil;
+ end;
+ v:=Null;
+end;
+
+function SplitVersion(p:pWideChar):integer;
+begin
+ result:=StrToInt(p);
+ while (p^>='0') and (p^<='9') do inc(p); inc(p);
+ result:=result*16+StrToInt(p);
+ while (p^>='0') and (p^<='9') do inc(p); inc(p);
+ result:=(result*16+StrToInt(p))*16;
+ while (p^>='0') and (p^<='9') do inc(p); inc(p);
+ result:=result*16+StrToInt(p);
+end;
+
+function GetVersion(const ver:pWideChar):integer;
+begin
+ if (ver<>nil) and (ver^<>#0) then
+ result:=SplitVersion(ver)
+ else
+ result:=0;
+end;
+
+function GetVersionText(const v:variant):PWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.Version)));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetTotalTime(const v:variant):integer;
+begin
+ try
+ result:=v.CurrentTrack.Duration;
+ except
+ result:=0;
+ end;
+end;
+
+function GetElapsedTime(const v:variant):integer;
+begin
+ try
+ result:=v.PlayerPosition;
+ except
+ result:=0;
+ end;
+end;
+
+function GetStatus(wnd:HWND):integer; cdecl;
+var
+ tmp:integer;
+ v:variant;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ tmp:=v.PlayerState;
+ if tmp=1 then
+ result:=WAT_MES_PLAYING
+ else
+ result:=WAT_MES_STOPPED;
+ except
+ result:=WAT_MES_UNKNOWN;
+ end;
+ v:=Null;
+end;
+
+function GetKbps(const v:variant):integer;
+begin
+ try
+ result:=v.CurrentTrack.BitRate;
+ except
+ result:=0;
+ end;
+end;
+
+function GetKhz(const v:variant):integer;
+begin
+ try
+ result:=v.CurrentTrack.SampleRate;
+ except
+ result:=0;
+ end;
+end;
+
+function GetTrack(const v:variant):integer;
+begin
+ try
+ result:=v.CurrentTrack.TrackNumber;
+ except
+ result:=0;
+ end;
+end;
+
+function GetAlbum(const v:variant):pWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.CurrentTrack.Album)));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetYear(const v:variant):pWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.CurrentTrack.Year)));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetGenre(const v:variant):pWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.CurrentTrack.Genre)));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetArtist(const v:variant):pWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.CurrentTrack.Artist)));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetTitle(const v:variant):pWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.CurrentStreamTitle)));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetComment(const v:variant):pWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.CurrentTrack.Comment)));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetWndText(const v:variant):pWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.Windows.Name)));
+ except
+ result:=nil;
+ end;
+end;
+
+function Play(const v:variant;fname:PWideChar=nil):integer;
+begin
+ try
+// v.PlayFile(fname);
+ v.BackTrack;
+ result:=v.Play;
+ except
+ result:=0;
+ end;
+end;
+
+function Pause(const v:variant):integer;
+begin
+ try
+ result:=v.PlayPause;
+ except
+ result:=0;
+ end;
+end;
+
+function Stop(const v:variant):integer;
+begin
+ try
+ result:=v.Stop;
+ except
+ result:=0;
+ end;
+end;
+
+function Next(const v:variant):integer;
+begin
+ try
+ result:=v.NextTrack;
+ except
+ result:=0;
+ end;
+end;
+
+function Prev(const v:variant):integer;
+begin
+ try
+ result:=v.PreviousTrack;
+ except
+ result:=0;
+ end;
+end;
+
+function Seek(const v:variant;value:integer):integer;
+begin
+ try
+ result:=v.PlayerPosition;
+ if value>0 then
+ v.PlayerPosition:=value
+ else
+ result:=0;
+ except
+ result:=0;
+ end;
+end;
+
+function GetVolume(const v:variant):cardinal;
+begin
+ try
+ result:=v.SoundVolume;
+ result:=(result shl 16)+round((result shl 4)/100);
+ except
+ result:=0;
+ end;
+end;
+
+procedure SetVolume(const v:variant;value:cardinal);
+begin
+ try
+ v.SoundVolume:=integer((value*100) shr 4);
+ except
+ end;
+end;
+
+function VolDn(const v:variant):integer;
+var
+ val:integer;
+begin
+ result:=GetVolume(v);
+ val:=loword(result);
+ if val>0 then
+ SetVolume(v,val-1);
+end;
+
+function VolUp(const v:variant):integer;
+var
+ val:integer;
+begin
+ result:=GetVolume(v);
+ val:=loword(result);
+ if val<16 then
+ SetVolume(v,val+1);
+end;
+
+function GetInfo(var SongInfo:tSongInfo;flags:integer):integer;cdecl;
+var
+ v:variant;
+begin
+ result:=0;
+ with SongInfo do
+ begin
+ try
+ v:=CreateOleObject(COMName);
+ if (flags and WAT_OPT_PLAYERDATA)<>0 then
+ begin
+ if plyver=0 then
+ begin
+ txtver:=GetVersionText(v);
+ plyver:=GetVersion(txtver);
+ end;
+ end
+ else if (flags and WAT_OPT_CHANGES)<>0 then
+ begin
+ volume:=GetVolume(v);
+ if status<>WAT_MES_STOPPED then
+ time:=GetElapsedTime(v);
+ end
+ else
+ begin
+ if total =0 then total :=GetTotalTime(v);
+ if track =0 then track :=GetTrack(v);
+ if year =NIL then year :=GetYear(v);
+ if genre =NIL then genre :=GetGenre(v);
+ if artist =NIL then artist :=GetArtist(v);
+ if album =NIL then album :=GetAlbum(v);
+ if comment=NIL then comment:=GetComment(v);
+ if kbps =0 then kbps :=GetKbps(v);
+ if khz =0 then khz :=GetKhz(v);
+ end;
+// wndtext:=GetWndText(v);
+ except
+ end;
+ v:=Null;
+// if title=NIL then title:=GetTitle; // only for streaming audio
+ end;
+end;
+
+function Command(wnd:HWND;cmd:integer;value:int_ptr):integer;cdecl;
+var
+ v:Variant;
+begin
+ result:=0;
+ try
+ v:=CreateOleObject(COMName);
+ case cmd of
+ WAT_CTRL_PREV : result:=Prev (v);
+ WAT_CTRL_PLAY : result:=Play (v,pWideChar(value));
+ WAT_CTRL_PAUSE: result:=Pause(v);
+ WAT_CTRL_STOP : result:=Stop (v);
+ WAT_CTRL_NEXT : result:=Next (v);
+ WAT_CTRL_VOLDN: result:=VolDn(v);
+ WAT_CTRL_VOLUP: result:=VolUp(v);
+ WAT_CTRL_SEEK : result:=Seek (v,value);
+ end;
+ except
+ end;
+ v:=Null;
+end;
+
+const
+ plRec:tPlayerCell=(
+ Desc :'iTunes';
+ flags :WAT_OPT_SINGLEINST or WAT_OPT_HASURL;
+ Icon :0;
+ Init :nil;
+ DeInit :nil;
+ Check :@Check;
+ GetStatus:@GetStatus;
+ GetName :@GetFileName;
+ GetInfo :@GetInfo;
+ Command :@Command;
+ URL :'http://www.itunes.com/';
+ 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.
diff --git a/plugins/Watrack/players/pl_la.pas b/plugins/Watrack/players/pl_la.pas new file mode 100644 index 0000000000..1945cf6580 --- /dev/null +++ b/plugins/Watrack/players/pl_la.pas @@ -0,0 +1,141 @@ +{LightAlloy player}
+unit pl_la;
+{$include compilers.inc}
+
+interface
+
+implementation
+uses windows,messages,common,srv_player,wat_api;
+
+const
+ LAClass = 'LightAlloyFront';
+const
+ WM_LACMD = WM_APP + 2504;
+ LAC_VERSION = 000;
+
+ LAC_FILE_OPEN = 050;
+ LAC_PLAYBACK_STOP = 100;
+ LAC_PLAYBACK_PLAY = 101;
+ LAC_PLAYBACK_STOP_PLAY = 102;
+ LAC_PLAYLIST_NEXT = 250;
+ LAC_PLAYLIST_PREV = 251;
+ LAC_PLAYLIST_PLAY = 252;
+ LAC_SOUND_VOLUME_INC = 401;
+ LAC_SOUND_VOLUME_DEC = 402;
+
+function Check(wnd:HWND;flags:integer):HWND;cdecl;
+begin
+ if wnd<>0 then
+ begin
+ result:=0;
+ exit;
+ end;
+ result:=FindWindow(LAClass,NIL);
+end;
+
+function GetVersion(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_LACMD,LAC_VERSION,0)
+end;
+
+function Play(wnd:HWND;fname:PWideChar=nil):integer;
+var
+ cds:COPYDATASTRUCT;
+begin
+ if (fname<>nil) and (fname^<>#0) then
+ begin
+ cds.dwData:=LAC_FILE_OPEN;
+ WideToAnsi(fname,PAnsiChar(cds.lpData));
+ cds.cbData:=StrLen(PAnsiChar(cds.lpData))+1;
+ SendMessage(wnd,WM_COPYDATA,0,lparam(@cds));
+ mFreeMem(cds.lpData);
+ end;
+ result:=SendMessage(wnd,WM_LACMD,LAC_PLAYLIST_PLAY,0) // LAC_PLAYLIST_PLAY
+end;
+
+function Pause(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_LACMD,LAC_PLAYBACK_STOP_PLAY,0)
+end;
+
+function Stop(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_LACMD,LAC_PLAYBACK_STOP,0)
+end;
+
+function Next(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_LACMD,LAC_PLAYLIST_NEXT,0)
+end;
+
+function Prev(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_LACMD,LAC_PLAYLIST_PREV,0)
+end;
+
+function VolDn(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_LACMD,LAC_SOUND_VOLUME_DEC,0);
+end;
+
+function VolUp(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_LACMD,LAC_SOUND_VOLUME_INC,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);
+ end;
+ end;
+end;
+
+function Command(wnd:HWND;cmd:integer;value:int_ptr):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);
+ else
+ result:=0;
+ end;
+end;
+
+const
+ plRec:tPlayerCell=(
+ Desc :'LightAlloy';
+ flags :WAT_OPT_HASURL;
+ Icon :0;
+ Init :nil;
+ DeInit :nil;
+ Check :@Check;
+ GetStatus:nil;
+ GetName :nil;
+ GetInfo :@GetInfo;
+ Command :@Command;
+ URL :'http://www.softella.com/';
+ 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.
diff --git a/plugins/Watrack/players/pl_lastfm.pas b/plugins/Watrack/players/pl_lastfm.pas new file mode 100644 index 0000000000..56ed3c7d4b --- /dev/null +++ b/plugins/Watrack/players/pl_lastfm.pas @@ -0,0 +1,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.
diff --git a/plugins/Watrack/players/pl_mmonkey.pas b/plugins/Watrack/players/pl_mmonkey.pas new file mode 100644 index 0000000000..bb826b9851 --- /dev/null +++ b/plugins/Watrack/players/pl_mmonkey.pas @@ -0,0 +1,181 @@ +{MediaMonkey player}
+unit pl_mmonkey;
+{$include compilers.inc}
+
+interface
+
+implementation
+uses windows,messages,winampapi,common,srv_player,wat_api
+ {$IFDEF DELPHI_7_UP}
+ ,variants
+ {$ENDIF}
+ {$IFDEF KOL_MCK}
+ ,kolcomobj
+ {$ELSE}
+ ,ComObj
+ {$ENDIF}
+;
+
+const
+ COMName:PAnsiChar = 'SongsDB.SDBApplication';
+
+const
+ WM_WA_IPC = WM_USER;
+ IPC_GETVERSION = 0;
+
+{
+const
+ MMonkeyName = 'MediaMonkey';
+}
+function Check(wnd:HWND;flags:integer):HWND;cdecl;
+//var
+// i:integer;
+{
+ EXEName:pWideChar;
+ tmp:pWideChar;
+}
+// v:Variant;
+begin
+ if wnd<>0 then
+ begin
+ result:=0;
+ exit;
+ end;
+ result:=FindWindow('TFMainWindow','MediaMonkey');
+ if result=0 then
+ result:=FindWindow('TFMainWindow.UnicodeClass','MediaMonkey');
+{
+ wnd:=FindWindow(WinAmpClass,NIL);
+ if wnd<>0 then
+ begin
+ if (SendMessage(wnd,WM_WA_IPC,0,IPC_GETVERSION) and $FF0F)<>$990B then
+ wnd:=result;
+ end;
+}
+{
+ wnd:=FindWindow(WinAmpClass,NIL);
+ if wnd<>0 then
+ begin
+ i:=SendMessage(wnd,WM_WA_IPC,0,IPC_GETVERSION) and $FF0F;
+ if i=$990B then
+ begin
+
+ try
+// v:=GetActiveOleObject(COMName);
+ v:=CreateOleObject(COMName);
+ if not v.IsRunning then
+ wnd:=0;
+ except
+ end;
+ v:=Null;
+
+ end
+ else
+ wnd:=0;
+ end;
+ result:=wnd;
+{
+ begin
+ EXEName:=GetEXEByWnd(wnd);
+ tmp:=Extract(EXEName,true);
+ mFreeMem(EXEName);
+ result:=StrCmpW(tmp,MMonkeyName,length(MMonkeyName))=0;
+ mFreeMem(tmp);
+ end;
+}
+end;
+
+function GetVersion(const v:variant):integer;
+begin
+ try
+ result:=(v.VersionHi shl 8)+(v.VersionLo shl 4)+v.VersionRelease;
+ except
+ result:=0;
+ end;
+end;
+
+function GetVersionText(const v:variant):PWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.VersionString)));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetFileName(wnd:HWND;flags:integer):pWideChar;cdecl;
+var
+ v:Variant;
+begin
+ try
+// SDB:=GetActiveOleObject(COMName);
+ v:=CreateOleObject(COMName);
+ StrDupW(result,PWideChar(WideString(v.Player.CurrentSong.Path)));
+ except
+ result:=nil;
+ end;
+ v:=Null;
+end;
+
+function GetStatus(wnd:HWND):integer; cdecl;
+begin
+ result:=WinampGetStatus(wnd)
+end;
+
+function GetInfo(var SongInfo:tSongInfo;flags:integer):integer;cdecl;
+var
+ v:variant;
+begin
+ if (flags and WAT_OPT_PLAYERDATA)<>0 then
+ begin
+ if SongInfo.plyver=0 then
+ begin
+ try
+ v:=CreateOleObject(COMName);
+ with SongInfo do
+ begin
+ plyver:=GetVersion(v);
+ txtver:=GetVersionText(v);
+ end;
+ except
+ end;
+ v:=Null;
+ end;
+ end;
+ result:=WinampGetInfo(int_ptr(@SongInfo),flags);
+end;
+
+function Command(wnd:HWND;cmd:integer;value:integer):integer;cdecl;
+begin
+ result:=WinampCommand(wnd,cmd+(value shl 16));
+end;
+
+const
+ plRec:tPlayerCell=(
+ Desc :'MediaMonkey';
+ flags :WAT_OPT_SINGLEINST or WAT_OPT_HASURL;
+ Icon :0;
+ Init :nil;
+ DeInit :nil;
+ Check :@Check;
+ GetStatus:@GetStatus;
+ GetName :@GetFileName;
+ GetInfo :@GetInfo;
+ Command :@Command;
+ URL :'http://www.mediamonkey.com/';
+ 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.
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.
diff --git a/plugins/Watrack/players/pl_mradio.pas b/plugins/Watrack/players/pl_mradio.pas new file mode 100644 index 0000000000..3d97037fbb --- /dev/null +++ b/plugins/Watrack/players/pl_mradio.pas @@ -0,0 +1,345 @@ +{mRadio protocol support}
+unit pl_mradio;
+{$include compilers.inc}
+{$r mradio.res}
+interface
+
+implementation
+uses m_api,dbsettings,windows,common,srv_player,wat_api,io;
+
+const
+ strUnknown:PwideChar = 'Unknown';
+ playername:PAnsiChar = 'mRadio';
+const
+ CurrentStation:THANDLE=THANDLE(-1);
+const
+ ChangesHook:THANDLE=0;
+const
+ MS_RADIO_COMMAND = 'mRadio/Command';
+ MS_RADIO_SETVOL = 'mRadio/SetVol';
+ ME_RADIO_STATUS:PAnsiChar = 'mRadio/Status';
+const
+ MRC_STOP = 0;
+ MRC_PLAY = 1;
+ MRC_PAUSE = 2;
+ MRC_PREV = 3;
+ MRC_NEXT = 4;
+ MRC_STATUS = 5;
+ MRC_SEEK = 6;
+const
+ RD_STATUS_NOSTATION = 0; // no active station found
+ RD_STATUS_PLAYING = 1; // media is playing
+ RD_STATUS_PAUSED = 2; // media is paused
+ RD_STATUS_STOPPED = 3; // media is stopped (only for playlists)
+ RD_STATUS_CONNECT = 4; // plugin try to connect to the station
+ RD_STATUS_ABORT = 5; // plugin want to abort while try to connect
+ // next is for events only
+ RD_STATUS_POSITION = 107; // position was changed
+ RD_STATUS_MUTED = 108; // Mute/Unmute command was sent
+ RD_STATUS_RECORD = 109; // "Record" action called
+ RD_STATUS_NEWTRACK = 110; // new track/station
+ RD_STATUS_NEWTAG = 111; // tag data changed
+ RD_STATUS_NEWSTATION = 112; // new station (contact)
+ // next command is for users
+ RD_STATUS_GET = 6; // to get current status
+const
+ prevfile:PWideChar=nil;
+
+function ClearmRadio:integer; cdecl;
+begin
+ result:=0;
+ if ChangesHook>0 then
+ begin
+ UnhookEvent(ChangesHook);
+ ChangesHook:=0;
+ CurrentStation:=THANDLE(-1);
+ end;
+ mFreeMem(prevfile);
+end;
+
+function SettingsChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+begin
+ result:=0;
+ case wParam of
+ // clear station
+ RD_STATUS_NOSTATION: CurrentStation:=THANDLE(-1);
+ // get new url
+ RD_STATUS_NEWSTATION: CurrentStation:=lParam;
+ end;
+end;
+
+function Fill:integer;
+var
+ i:integer;
+begin
+ CurrentStation:=CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ while CurrentStation<>0 do
+ begin
+ i:=DBReadWord(CurrentStation,playername,'Status',WORD(-1));
+ if i=ID_STATUS_ONLINE then
+ begin
+ result:=1;
+ exit;
+ end;
+ CurrentStation:=CallService(MS_DB_CONTACT_FINDNEXT,CurrentStation,0);
+ end;
+ result:=WAT_RES_NOTFOUND;
+end;
+
+function InitmRadio:integer;
+begin
+ if ChangesHook=0 then
+ begin
+ ChangesHook:=HookEvent(ME_RADIO_STATUS,@SettingsChanged);
+ result:=Fill;
+ end
+ else if (CurrentStation<>0) and (CurrentStation<>THANDLE(-1)) then
+ result:=1
+ else
+ result:=WAT_RES_NOTFOUND;
+end;
+
+function Check(wnd:HWND;flags:integer):HWND;cdecl;
+begin
+ if CallProtoService(playername,PS_GETSTATUS,0,0)=ID_STATUS_ONLINE then
+ begin
+ result:=InitmRadio
+ end
+ else
+ begin
+ result:=HWND(WAT_RES_NOTFOUND);
+ ClearmRadio;
+ end;
+end;
+
+function GetKbps:integer;
+var
+ pc:PWideChar;
+begin
+ pc:=DBReadUnicode(CurrentStation,playername,'Bitrate','0');
+ result:=StrToInt(pc);
+ mFreeMem(pc);
+end;
+
+function GetFileName(wnd:HWND;flags:integer):pWideChar; cdecl;
+begin
+ result:=DBReadUnicode(0,playername,'ActiveURL',nil)
+end;
+
+function GetGenre:pWideChar;
+begin
+ result:=DBReadUnicode(CurrentStation,playername,'Genre',nil);
+end;
+
+function GetWndText:pWideChar;
+begin
+ result:=DBReadUnicode(CurrentStation,strCList,'StatusMsg',strUnknown);
+end;
+
+function GetTitle:pWideChar;
+begin
+ result:=DBReadUnicode(0,playername,'Title');
+ if result=nil then
+ result:=DBReadUnicode(CurrentStation,strCList,'StatusMsg',strUnknown);
+end;
+
+function GetArtist:pWideChar;
+begin
+ result:=DBReadUnicode(0,playername,'Artist');
+ if result=nil then
+ result:=DBReadUnicode(CurrentStation,strCList,'MyHandle',strUnknown);
+end;
+
+function GetVolume:cardinal;
+begin
+ result:=DBReadByte(0,playername,'Volume',0);
+ result:=(result shl 16)+round((result shl 4)/100);
+end;
+
+procedure SetVolume(value:cardinal);
+begin
+ CallService(MS_RADIO_SETVOL,(value*100) shr 4,0);
+end;
+
+function VolDn:integer;
+var
+ val:dword;
+begin
+ result:=GetVolume;
+ val:=loword(result);
+ if val>0 then
+ SetVolume(val-1);
+end;
+
+function VolUp:integer;
+var
+ val:dword;
+begin
+ result:=GetVolume;
+ val:=loword(result);
+ if val<16 then
+ SetVolume(val+1);
+end;
+
+function GetCover:pWideChar;
+var
+ ptr:PavatarCacheEntry;
+begin
+ result:=nil;
+ if ServiceExists(MS_AV_GETAVATARBITMAP)<>0 then
+ begin
+ ptr:=PavatarCacheEntry(CallService(MS_AV_GETAVATARBITMAP,CurrentStation,0));
+ if ptr<>nil then
+ AnsiToWide(ptr^.szFilename,result)
+ end;
+end;
+
+function GetVersionText(ver:dword):pWideChar;
+var
+ s:array [0..31] of WideChar;
+ p:pWideChar;
+begin
+ p:=@s;
+ IntToStr(p,ver shr 12);
+ while p^<>#0 do inc(p);
+ p^:='.';
+ IntToStr(p+1,(ver shr 8) and $F);
+ while p^<>#0 do inc(p);
+ p^:='.';
+ IntToStr(p+1,(ver shr 4) and $F);
+ while p^<>#0 do inc(p);
+ p^:='.';
+ IntToStr(p+1,ver and $F);
+ StrDupW(result,PWideChar(@s));
+end;
+
+function GetStatus:integer; cdecl;
+begin
+ if CurrentStation<>0 then
+ begin
+ result:=WAT_MES_PLAYING;
+ case CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_GET) of
+ RD_STATUS_PAUSED : result:=WAT_MES_PAUSED;
+ RD_STATUS_STOPPED: begin
+ result:=WAT_MES_STOPPED;
+ mFreeMem(prevfile);
+ end;
+ RD_STATUS_NOSTATION,
+ RD_STATUS_ABORT : result:=WAT_MES_UNKNOWN;
+ end;
+ end
+ else
+ result:=WAT_MES_STOPPED;
+end;
+
+function GetInfo(var SongInfo:tSongInfo;flags:integer):integer;cdecl;
+var
+ lfile:pWideChar;
+ isRemote:bool;
+ isChanging:bool;
+begin
+ result:=0;
+ if (flags and WAT_OPT_PLAYERDATA)<>0 then
+ begin
+ if SongInfo.plyver=0 then
+ begin
+ SongInfo.plyver:=DBReadDWord(0,playername,'version');
+ SongInfo.txtver:=GetVersionText(SongInfo.plyver);
+ end;
+ end
+ else if CurrentStation<>0 then
+ with SongInfo do
+ begin
+ if (flags and WAT_OPT_CHANGES)<>0 then
+ begin
+ volume:=GetVolume;
+ mFreeMem(wndtext);
+ wndtext:=GetWndText;
+ time:=CallService(MS_RADIO_COMMAND,MRC_SEEK,-1);
+ end
+ else
+ begin
+ lfile:=GetFileName(plwnd,flags);
+ isRemote:=StrPosW(lfile,'://')<>nil;
+ if (prevfile=nil) or isRemote or (StrCmpW(prevfile,lfile)<>0) then
+ begin
+ ClearTrackInfo(SongInfo,false);
+ mfile:=lfile;
+ mFreeMem(prevfile);
+ StrDupW(prevfile,mfile);
+ isChanging:=true;
+ end
+ else
+ begin
+ isChanging:=false;
+ mFreeMem(lfile);
+ end;
+
+ if not isRemote then
+ begin
+ if isChanging then
+ begin
+ CallService(MS_WAT_GETFILEINFO,0,lparam(@SongInfo));
+ fsize:=GetFSize(mfile);
+ mFreeMem(prevfile);
+ StrDupW(prevfile,mfile);
+ end;
+ end;
+//!!
+ if kbps =0 then kbps :=GetKbps;
+ if genre =nil then genre :=GetGenre;
+ if title =nil then title :=GetTitle;
+ if artist=nil then artist:=GetArtist;
+ if cover =nil then cover :=GetCover;
+ end;
+ end;
+end;
+
+function Command(wnd:HWND;cmd:integer;value:integer):integer;cdecl;
+begin
+ result:=0;
+ case cmd of
+ WAT_CTRL_PREV : result:=CallService(MS_RADIO_COMMAND,MRC_PREV,0);
+ WAT_CTRL_PLAY : result:=CallService(MS_RADIO_COMMAND,MRC_PLAY,0);
+ WAT_CTRL_PAUSE: result:=CallService(MS_RADIO_COMMAND,MRC_PAUSE,0);
+ WAT_CTRL_STOP : result:=CallService(MS_RADIO_COMMAND,MRC_STOP,0);
+ WAT_CTRL_NEXT : result:=CallService(MS_RADIO_COMMAND,MRC_NEXT,0);
+ WAT_CTRL_VOLDN: result:=VolDn;
+ WAT_CTRL_VOLUP: result:=VolUp;
+ WAT_CTRL_SEEK : result:=CallService(MS_RADIO_COMMAND,MRC_SEEK,value);
+ end;
+end;
+
+const
+ plRec:tPlayerCell=(
+ Desc :'mRadio';
+ flags :WAT_OPT_PLAYERINFO or WAT_OPT_SINGLEINST or WAT_OPT_HASURL or WAT_OPT_LAST;
+ Icon :0;
+ Init :nil;
+ DeInit :@ClearmRadio;
+ Check :@Check;
+ GetStatus:@GetStatus;
+ GetName :@GetFileName;
+ GetInfo :@GetInfo;
+ Command :@Command;
+ URL :'https://code.google.com/p/delphi-miranda-plugins/';
+ Notes :nil);
+
+var
+ LocalPlayerLink:twPlayer;
+
+procedure InitLink;
+begin
+ if plRec.Icon=0 then
+ plRec.Icon:=LoadImage(hInstance,'ICO_MRADIO',IMAGE_ICON,16,16,0);
+
+ LocalPlayerLink.Next:=PlayerLink;
+ LocalPlayerLink.This:=@plRec;
+ PlayerLink :=@LocalPlayerLink;
+end;
+
+initialization
+ InitLink;
+finalization
+ if plRec.Icon<>0 then DestroyIcon(plRec.Icon);
+end.
diff --git a/plugins/Watrack/players/pl_vlc.pas b/plugins/Watrack/players/pl_vlc.pas new file mode 100644 index 0000000000..9d3a2ad57d --- /dev/null +++ b/plugins/Watrack/players/pl_vlc.pas @@ -0,0 +1,380 @@ +{Video Lan player}
+unit pl_VLC;
+{$include compilers.inc}
+
+interface
+
+implementation
+uses windows,common,srv_player,wat_api,syswin,wrapper
+ {$IFDEF DELPHI_7_UP}
+ ,variants
+ {$ENDIF}
+ {$IFDEF KOL_MCK}
+ ,kolcomobj
+ {$ELSE}
+ ,ComObj
+ {$ENDIF}
+;
+
+{
+ procedure play; safecall;
+ procedure pause; safecall;
+ procedure stop; safecall;
+ procedure playlistNext; safecall;
+ procedure playlistPrev; safecall;
+ property Playing: WordBool read Get_Playing;
+ property Position: Single read Get_Position write Set_Position;
+ property Time: SYSINT read Get_Time write Set_Time;
+ property Length: SYSINT read Get_Length;
+ (0)1-97(100)
+ property Volume: SYSINT read Get_Volume write Set_Volume;
+ property VersionInfo: WideString read Get_VersionInfo;
+}
+
+const
+// GuidOld: TGUID = '{E23FE9C6-778E-49D4-B537-38FCDE4887D8}';
+ VLCClass = 'wxWindowClassNR';
+ VLCName = 'VLC media player';
+ COMName = 'VideoLAN.VLCPlugin.1'; // IVLCControl
+
+// GuidNew: TGUID = '{9BE31822-FDAD-461B-AD51-BE1D1C159921}';
+ VLCClassSkin = 'SkinWindowClass';
+ VLCClassNew = 'QWidget';
+ VLCEXEName = 'VLC.EXE';
+ COMNameNew = 'VideoLAN.VLCPlugin2'; // IVLCControl2
+
+function Check(wnd:HWND;flags:integer):HWND;cdecl;
+var
+ tmp,EXEName:PAnsiChar;
+begin
+ if wnd<>0 then
+ begin
+ result:=0;
+ exit;
+ end;
+ result:=FindWindow(VLCClass,VLCName);
+ if result=0 then
+ result:=FindWindow(VLCClassSkin,nil); // VLCName
+ if result=0 then
+ result:=FindWindow(VLCClassNew,nil);
+ if result<>0 then
+ begin
+ tmp:=Extract(GetEXEByWnd(result,EXEName),true);
+ if lstrcmpia(tmp,VLCEXEName)<>0 then
+ result:=0;
+ mFreeMem(tmp);
+ mFreeMem(EXEName);
+ end;
+{ if result<>0 then
+ begin
+ tmp:=Extract(GetEXEByWnd(result,EXEName),true);
+ if lstrcmpia(tmp,'VLC.EXE')<>0 then
+ result:=0;
+ mFreeMem(tmp);
+ mFreeMem(EXEName);
+ end;
+}
+end;
+
+function SplitVersion(p:pWideChar):integer;
+begin
+ result:=StrToInt(p);
+ while (p^>='0') and (p^<='9') do inc(p); inc(p);
+ result:=result*16+StrToInt(p);
+ while (p^>='0') and (p^<='9') do inc(p); inc(p);
+ result:=(result*16+StrToInt(p))*16;
+ while (p^>='0') and (p^<='9') do inc(p); inc(p);
+ result:=result*16+StrToInt(p);
+end;
+
+function GetVersion(const ver:pWideChar):integer;
+begin
+ try
+ result:=SplitVersion(ver);
+ except
+ result:=0;
+ end;
+end;
+
+function GetVersionText(const v:variant):PWideChar;
+begin
+ try
+ StrDupW(result,PWideChar(WideString(v.VersionInfo)));
+ except
+ result:=nil;
+ end;
+end;
+
+function GetWndText(wnd:HWND):pWideChar;
+var
+ p:pWideChar;
+begin
+ result:=GetDlgText(wnd);
+{
+need to clear " - lalala VLC" at the end
+}
+ if result<>nil then
+ begin
+ p:=StrRScanW(result,'-');
+ if p<>nil then // found
+ begin
+ if (p>result) and ((p-1)^=' ') and ((p+1)^=' ') then
+ (p-1)^:=#0;
+ end;
+ end;
+end;
+
+{
+function GetTotalTime:integer;
+var
+ v:variant;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ result:=v.Length;
+ except
+ result:=inherited GetTotalTime;
+ end;
+ v:=Null;
+end;
+
+function GetElapsedTime:integer;
+var
+ v:variant;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ result:=v.Time;
+ except
+ result:=inherited GetElapsedTime;
+ end;
+ v:=Null;
+end;
+
+function GetStatus:integer; cdecl;
+var
+ v:variant;
+ tmp:boolean;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ tmp:=v.Playing;
+ if tmp then
+ result:=WAT_MES_PLAYING
+ else
+ result:=WAT_MES_STOPPED;
+ except
+ result:=inherited GetStatus;
+ end;
+ v:=Null;
+end;
+
+function Play(fname:PWideChar=nil):integer;
+var
+ v:variant;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ result:=v.play;
+ except
+ result:=inherited Play(fname);
+ end;
+ v:=Null;
+end;
+
+function Pause:integer;
+var
+ v:variant;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ result:=v.pause;
+ except
+ result:=inherited Pause;
+ end;
+ v:=Null;
+end;
+
+function Stop:integer;
+var
+ v:variant;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ result:=v.stop;
+ except
+ result:=inherited Stop;
+ end;
+ v:=Null;
+end;
+
+function Next:integer;
+var
+ v:variant;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ result:=v.playlistNext;
+ except
+ result:=inherited Next;
+ end;
+ v:=Null;
+end;
+
+function Prev:integer;
+var
+ v:variant;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ result:=v.playlistPrev;
+ except
+ result:=inherited Prev;
+ end;
+ v:=Null;
+end;
+
+function Seek(value:integer):integer;
+var
+ v:variant;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ result:=v.Position;
+ if value>0 then
+ v.Position:=value
+ else
+ result:=0;
+ except
+ result:=inherited Seek(value);
+ end;
+ v:=Null;
+end;
+
+function GetVolume:cardinal;
+var
+ v:variant;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ result:=v.Volume;
+ result:=(result shl 16)+((result shl 4) div 100);
+ except
+ result:=0;
+ end;
+ v:=Null;
+end;
+
+procedure SetVolume(value:cardinal);
+var
+ v:variant;
+begin
+ try
+ v:=CreateOleObject(COMName);
+ v.Volume:=(value*100) shr 4;
+ end;
+ except
+ result:=inherited SetVolume(value);
+ end;
+ v:=Null;
+end;
+
+function VolDn:integer;
+var
+ val:integer;
+begin
+ result:=GetVolume;
+ val:=loword(result);
+ if val>0 then
+ SetVolume(val-1);
+end;
+
+function VolUp:integer;
+var
+ val:integer;
+begin
+ result:=GetVolume;
+ val:=loword(result);
+ if val<16 then
+ SetVolume(val+1);
+end;
+
+}
+function GetInfo(var SongInfo:tSongInfo;flags:integer):integer;cdecl;
+var
+ v:variant;
+begin
+ result:=0;
+ if (flags and WAT_OPT_PLAYERDATA)<>0 then
+ begin
+ if SongInfo.plyver=0 then
+ begin
+ try
+ try
+ v:=CreateOleObject(COMName);
+ except
+ try
+ v:=CreateOleObject(COMNameNew);
+ except
+ v:=Null;
+ end;
+ end;
+ if v<>Null then
+ with SongInfo do
+ begin
+ txtver:=GetVersionText(v);
+ plyver:=GetVersion(txtver);
+ end;
+ except
+ end;
+ v:=Null;
+ if (flags and WAT_OPT_CHANGES)<>0 then
+ SongInfo.wndtext:=GetWndText(SongInfo.plwnd);
+ end;
+ end;
+end;
+{
+function Command(wnd:HWND;cmd:integer;value:integer):integer;cdecl;
+begin
+ result:=0;
+ case cmd of
+ WAT_CTRL_PREV : result:=Prev;
+ WAT_CTRL_PLAY : result:=Play(pWideChar(value));
+ WAT_CTRL_PAUSE: result:=Pause;
+ WAT_CTRL_STOP : result:=Stop;
+ WAT_CTRL_NEXT : result:=Next;
+ WAT_CTRL_VOLDN: result:=VolDn;
+ WAT_CTRL_VOLUP: result:=VolUp;
+ WAT_CTRL_SEEK : result:=Seek(value);
+ end;
+end;
+}
+const
+ plRec:tPlayerCell=(
+ Desc :'VideoLAN player';
+ flags :WAT_OPT_HASURL;
+ Icon :0;
+ Init :nil;
+ DeInit :nil;
+ Check :@Check;
+ GetStatus:nil;
+ GetName :nil;
+ GetInfo :@GetInfo;
+ Command :nil;
+ URL :'http://www.videolan.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.
diff --git a/plugins/Watrack/players/pl_winamp.pas b/plugins/Watrack/players/pl_winamp.pas new file mode 100644 index 0000000000..254475e09a --- /dev/null +++ b/plugins/Watrack/players/pl_winamp.pas @@ -0,0 +1,170 @@ +{Winamp-like - base class}
+unit pl_WinAmp;
+{$include compilers.inc}
+
+interface
+
+implementation
+
+uses winampapi,windows,common,messages,syswin,srv_player,wat_api;
+
+{
+#define IPC_GETPLAYLISTTITLE 212
+/* (requires Winamp 2.04+, only usable from plug-ins (not external apps))
+** char *name=SendMessage(hwnd_winamp,WM_WA_IPC,index,IPC_GETPLAYLISTTITLE);
+**
+** IPC_GETPLAYLISTTITLE gets the title of the playlist entry [index].
+** returns a pointer to it. returns NULL on error.
+*/
+}
+// class = BaseWindow_RootWnd
+// title = Main Window
+
+// ---------- check player ------------
+
+function Check(wnd:HWND;aflags:integer):HWND;cdecl;
+var
+ tmp,EXEName:PAnsiChar;
+begin
+ result:=FindWindowEx(0,wnd,WinampClass,NIL);
+ if result<>0 then
+ begin
+ tmp:=Extract(GetEXEByWnd(result,EXEName),true);
+ if lstrcmpia(tmp,'WINAMP.EXE')<>0 then
+ result:=0;
+ mFreeMem(tmp);
+ mFreeMem(EXEName);
+ end;
+end;
+
+function WAnyCheck(wnd:HWND;aflags:integer):HWND;cdecl;
+begin
+ result:=FindWindowEx(0,wnd,WinampClass,NIL);
+end;
+
+// ----------- Get info ------------
+
+function GetStatus(wnd:HWND):integer; cdecl;
+begin
+ result:=WinampGetStatus(wnd)
+end;
+
+function GetWidth(wnd:HWND):integer;
+begin
+ result:=LOWORD(SendMessage(wnd,WM_WA_IPC,3,IPC_GETINFO));
+end;
+
+function GetHeight(wnd:HWND):integer;
+begin
+ result:=SendMessage(wnd,WM_WA_IPC,3,IPC_GETINFO) shr 16;
+end;
+
+function GetInfo(var SongInfo:tSongInfo;aflags:integer):integer;cdecl;
+begin
+ SongInfo.winampwnd:=SongInfo.plwnd;
+ result:=WinampGetInfo(int_ptr(@SongInfo),aflags);
+ with SongInfo do
+ begin
+ if (aflags and WAT_OPT_CHANGES)<>0 then
+ wndtext:=WinampGetWindowText(winampwnd)
+ else
+ begin
+{
+ if ((loword(plyver) shr 12)>=5) and
+ (SendMessage(wnd,WM_WA_IPC,0,IPC_IS_PLAYING_VIDEO)>1) then
+ begin
+ if width =0 then width :=GetWidth(wnd);
+ if height=0 then Height:=GetHeight(wnd);
+ end;
+}
+ end;
+ end;
+end;
+
+// ------- Commands ----------
+
+function Command(wnd:HWND;cmd:integer;value:integer):integer;cdecl;
+begin
+ result:=WinampCommand(wnd,cmd+(value shl 16));
+end;
+
+// ------- In-process code -------
+
+function GetFileName(wnd:HWND;flags:integer):pWideChar;cdecl;
+var
+ fpos,fname:int_ptr;
+ pid:dword;
+ op:THANDLE;
+ buf:array [0..1023] of AnsiChar;
+ tmp:{$IFDEF FPC}LongWord{$ELSE}ulong_ptr{$ENDIF};
+begin
+ result:=nil;
+ if (flags and WAT_OPT_IMPLANTANT)<>0 then
+ begin
+ if SendMessage(wnd,WM_WA_IPC,0,IPC_ISPLAYING)<>WAT_MES_STOPPED then
+ begin
+ fpos :=SendMessage(wnd,WM_USER,0 ,IPC_GETLISTPOS);
+ fname:=SendMessage(wnd,WM_USER,fpos,IPC_GETPLAYLISTFILE);
+ GetWindowThreadProcessId(wnd,@pid);
+ op:=OpenProcess(PROCESS_VM_READ,false,pid);
+ if op<>0 then
+ begin
+ ReadProcessMemory(op,PByte(fname),@buf,SizeOf(buf),tmp);
+ CloseHandle(op);
+ if tmp>0 then
+ AnsiToWide(buf,result);
+ end;
+ end;
+ end;
+end;
+
+const
+ plRec:tPlayerCell=(
+ Desc :'Winamp';
+ flags :WAT_OPT_ONLYONE or WAT_OPT_WINAMPAPI or WAT_OPT_HASURL;
+ Icon :0;
+ Init :nil;
+ DeInit :nil;
+ Check :@Check;
+ GetStatus:@GetStatus;
+ GetName :@GetFileName;
+ GetInfo :@GetInfo;
+ Command :@Command;
+ URL :'http://www.winamp.com/';
+ Notes :nil);
+
+const
+ plRecClone:tPlayerCell=(
+ Desc :'Winamp Clone';
+ flags :WAT_OPT_ONLYONE or WAT_OPT_WINAMPAPI or WAT_OPT_LAST;
+ Icon :0;
+ Init :nil;
+ DeInit :nil;
+ Check :@WAnyCheck;
+ GetStatus:@GetStatus;
+ GetName :nil;
+ GetInfo :@WinampGetInfo;
+ Command :@Command;
+ URL :nil;
+ Notes :'All "unknown" players using Winamp API');
+
+var
+ LocalPlayerLink,
+ LocalPlayerLinkC:twPlayer;
+
+procedure InitLink;
+begin
+ LocalPlayerLink.Next:=PlayerLink;
+ LocalPlayerLink.This:=@plRec;
+ PlayerLink :=@LocalPlayerLink;
+
+ LocalPlayerLinkC.Next:=PlayerLink;
+ LocalPlayerLinkC.This:=@plRecClone;
+ PlayerLink :=@LocalPlayerLinkC;
+end;
+
+initialization
+// ServicePlayer(WAT_ACT_REGISTER,dword(@plRec));
+// ServicePlayer(WAT_ACT_REGISTER,dword(@plRecClone));
+ InitLink;
+end.
diff --git a/plugins/Watrack/players/pl_wmp.pas b/plugins/Watrack/players/pl_wmp.pas new file mode 100644 index 0000000000..971cb28ac6 --- /dev/null +++ b/plugins/Watrack/players/pl_wmp.pas @@ -0,0 +1,128 @@ +{Windows Media Player}
+unit pl_WMP;
+{$include compilers.inc}
+
+interface
+
+implementation
+uses windows,common,messages,srv_player,wat_api
+ {$IFDEF DELPHI_7_UP}
+ ,variants
+ {$ENDIF}
+ {$IFDEF KOL_MCK}
+ ,kolcomobj
+ {$ELSE}
+ ,ComObj
+ {$ENDIF}
+;
+
+const
+ WMPOld:boolean=false;
+
+const
+// CLASS_MP :TGUID = '{22D6F312-B0F6-11D0-94AB-0080C74C7E95}';
+// CLASS_WMP:TGUID = '{6BF52A52-394A-11D3-B153-00C04F79FAA6}'; CLASS_WindowsMediaPlayer
+ MPCOMName = 'MediaPlayer.MediaPlayer.1';
+ WMPCOMName = 'WMPlayer.OCX.7';
+const
+ MPClass = 'Media Player 2';
+ WMPClass = 'WMPlayerApp';
+
+function Check(wnd:HWND;flags:integer):HWND;cdecl;
+begin
+ result:=FindWindowEx(0,wnd,MPClass,NIL);
+ if result=0 then
+ begin
+ result:=FindWindowEx(0,wnd,WMPClass,NIL); //?
+ WMPOld:=false;
+ end
+ else
+ WMPOld:=true;
+end;
+
+{ Version detect
+ fHasWMP64 = (WMP64.FileName="") ' WMP64 was create above via OBJECT tag else this returns False.
+ fHasWMP7 = (WMP7.URL = "") ' WMP7 or later was create above via OBJECT tag else this returns False.
+}
+
+const
+ MPVersion:PWideChar = '6.4';
+
+function GetVersionText(flags:integer):PWideChar;
+var
+ v:variant;
+begin
+ if WMPOld then
+ StrDupW(result,MPVersion)
+ else
+ begin
+ try
+ v:=CreateOleObject(WMPCOMName);
+ StrDupW(result,pWideChar(Widestring(v.versionInfo)));
+ except
+ result:=nil;
+ end;
+// VarClear(v);
+ v:=Null;
+ end;
+end;
+
+function GetInfo(var SongInfo:tSongInfo;flags:integer):integer;cdecl;
+begin
+ result:=0;
+ if (flags and WAT_OPT_PLAYERDATA)<>0 then
+ begin
+ if SongInfo.txtver=nil then
+ SongInfo.txtver:=GetVersionText(flags);
+ end;
+end;
+
+{
+function Command(wnd:HWND;cmd:integer;value:integer):integer;cdecl;
+var
+ c:integer;
+begin
+ result:=0;
+ case cmd of
+// WAT_CTRL_PREV : c:=VK_B;
+// WAT_CTRL_PLAY : c:=VK_C;
+// WAT_CTRL_PAUSE: c:=VK_X;
+// WAT_CTRL_STOP : c:=VK_Z;
+// WAT_CTRL_NEXT : c:=VK_V;
+ WAT_CTRL_VOLDN: c:=VK_F9;
+ WAT_CTRL_VOLUP: c:=VK_F10;
+ else
+ exit;
+ end;
+ PostMessageW(wnd,WM_KEYDOWN,c,1);
+end;
+}
+const
+ plRec:tPlayerCell=(
+ Desc :'WMP';
+ flags :WAT_OPT_APPCOMMAND or WAT_OPT_SINGLEINST;
+ Icon :0;
+ Init :nil;
+ DeInit :nil;
+ Check :@Check;
+ GetStatus:nil;
+ GetName :nil;
+ GetInfo :@GetInfo;
+ Command :nil;
+ URL :'http://www.microsoft.com/windows/windowsmedia/players.aspx';
+ 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.
|