NowPlayingPlugin:

- Added PlayerType=STATUS (returns 1 when player is open, 0 when closed)
- Winamp interface: Fixed that file paths over about 100 chars did not display all metadata
- CAD interface: Added workaround for issue caused by Rainmeter running as elevated and player running as normal process (Windows Vista+)
This commit is contained in:
Birunthan Mohanathas 2011-06-25 12:44:33 +00:00
parent 9acbe62493
commit c451aba194
11 changed files with 68 additions and 50 deletions

View File

@ -60,6 +60,7 @@ void CInternet::Finalize()
*/
std::wstring CInternet::DownloadUrl(const std::wstring& url, int codepage)
{
// From WebParser.cpp
std::wstring result;
DWORD flags = INTERNET_FLAG_RESYNCHRONIZE;
HINTERNET hUrlDump = InternetOpenUrl(c_NetHandle, url.c_str(), NULL, NULL, flags, 0);

View File

@ -209,10 +209,6 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{
child->type = MEASURE_ALBUM;
}
else if (_wcsicmp(L"LYRICS", str) == 0)
{
child->type = MEASURE_LYRICS;
}
else if (_wcsicmp(L"COVER", str) == 0)
{
child->type = MEASURE_COVER;
@ -239,11 +235,19 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{
child->type = MEASURE_STATE;
}
else if (_wcsicmp(L"STATUS", str) == 0)
{
child->type = MEASURE_STATUS;
}
else if (_wcsicmp(L"VOLUME", str) == 0)
{
child->type = MEASURE_VOLUME;
maxValue = 100;
}
else if (_wcsicmp(L"LYRICS", str) == 0)
{
child->type = MEASURE_LYRICS;
}
else if (_wcsicmp(L"FILE", str) == 0)
{
child->type = MEASURE_FILE;
@ -343,11 +347,14 @@ UINT Update(UINT id)
case MEASURE_RATING:
return player->GetRating();
case MEASURE_VOLUME:
return player->GetVolume();
case MEASURE_STATE:
return (UINT)player->GetState();
case MEASURE_VOLUME:
return player->GetVolume();
case MEASURE_STATUS:
return (UINT)player->IsInitialized();
}
return 0;
@ -389,6 +396,9 @@ LPCTSTR GetString(UINT id, UINT flags)
case MEASURE_COVER:
return player->GetCoverPath();
case MEASURE_FILE:
return player->GetFilePath();
case MEASURE_DURATION:
SecondsToTime(player->GetDuration(), parent->disableLeadingZero, buffer);
return buffer;
@ -405,21 +415,22 @@ LPCTSTR GetString(UINT id, UINT flags)
_itow(player->GetRating(), buffer, 10);
return buffer;
case MEASURE_STATE:
_itow(player->GetState(), buffer, 10);
return buffer;
case MEASURE_VOLUME:
_itow(player->GetVolume(), buffer, 10);
return buffer;
case MEASURE_FILE:
return player->GetFilePath();
case MEASURE_STATE:
_itow(player->GetState(), buffer, 10);
return buffer;
case MEASURE_STATUS:
_itow((UINT)player->IsInitialized(), buffer, 10);
return buffer;
}
}
else
{
return L"Error: Invalid player.";
return L"Error: Invalid player name.";
}
return L"";

View File

@ -39,13 +39,14 @@ enum MEASURETYPE
MEASURE_ALBUM,
MEASURE_LYRICS,
MEASURE_COVER,
MEASURE_FILE,
MEASURE_DURATION,
MEASURE_POSITION,
MEASURE_PROGRESS,
MEASURE_RATING,
MEASURE_STATE,
MEASURE_VOLUME,
MEASURE_FILE
MEASURE_STATE,
MEASURE_STATUS
};
class CPlayer

View File

@ -23,7 +23,6 @@
CPlayer* CPlayerAIMP::c_Player = NULL;
// TODO
/*
** CPlayerAIMP
**

View File

@ -84,7 +84,7 @@ void CPlayerCAD::Initialize()
wc.lpszClassName = L"NowPlayingCADClass";
RegisterClass(&wc);
// Create dummy window
// Create reciever window
m_Window = CreateWindow(L"NowPlayingCADClass",
L"CD Art Display 1.x Class",
WS_DISABLED,
@ -97,6 +97,31 @@ void CPlayerCAD::Initialize()
hInstance,
this);
// Add WM_USER/WM_COPYDATA to allowed messages from lower level processes
HMODULE hUser32 = LoadLibrary(L"user32.dll");
if (hUser32)
{
// Try ChangeWindowMessageFilterEx first (Win7+)
FPCHANGEWINDOWMESSAGEFILTEREX ChangeWindowMessageFilterEx = (FPCHANGEWINDOWMESSAGEFILTEREX)GetProcAddress(hUser32, "ChangeWindowMessageFilterEx");
if (ChangeWindowMessageFilterEx)
{
ChangeWindowMessageFilterEx(m_Window, WM_USER, MSGFLT_ALLOW, NULL);
ChangeWindowMessageFilterEx(m_Window, WM_COPYDATA, MSGFLT_ALLOW, NULL);
}
else
{
// Try ChangeWindowMessageFilter (Vista)
FPCHANGEWINDOWMESSAGEFILTER ChangeWindowMessageFilter = (FPCHANGEWINDOWMESSAGEFILTER)GetProcAddress(hUser32, "ChangeWindowMessageFilter");
if (ChangeWindowMessageFilter)
{
ChangeWindowMessageFilter(WM_USER, MSGFLT_ALLOW);
ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ALLOW);
}
}
FreeLibrary(hUser32);
}
WCHAR buffer[MAX_PATH];
LPCTSTR file = g_SettingsFile.c_str();
@ -177,7 +202,7 @@ LRESULT CALLBACK CPlayerCAD::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
switch (lParam)
{
case IPC_TRACK_CHANGED_NOTIFICATION:
SendMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_CURRENT_TRACK);
PostMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_CURRENT_TRACK);
break;
case IPC_PLAYER_STATE_CHANGED_NOTIFICATION:
@ -280,7 +305,7 @@ LRESULT CALLBACK CPlayerCAD::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
if (player->m_State != PLAYER_STOPPED)
{
SendMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_CURRENT_TRACK);
PostMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_CURRENT_TRACK);
}
}
}

View File

@ -21,6 +21,9 @@
#include "Player.h"
typedef BOOL (WINAPI * FPCHANGEWINDOWMESSAGEFILTER)(UINT message, DWORD dwFlag);
typedef BOOL (WINAPI * FPCHANGEWINDOWMESSAGEFILTEREX)(HWND hWnd, UINT message, DWORD dwFlag, PCHANGEFILTERSTRUCT pChangeFilterStruct);
class CPlayerCAD : public CPlayer
{
public:

View File

@ -284,7 +284,7 @@ void CPlayerFoobar::Pause()
*/
void CPlayerFoobar::Play()
{
SendMessage(m_FooWindow, WM_USER, 0, FOO_PLAY);
SendMessage(m_FooWindow, WM_USER, 0, (m_State == PLAYER_PAUSED) ? FOO_PLAYPAUSE : FOO_PLAY);
}
/*

View File

@ -230,7 +230,7 @@ void CPlayerWMP::Initialize()
CComPtr<IObjectWithSite> spHostObject;
CComPtr<IAxWinHostWindow> spHost;
CComObject<CRemoteHost>* pRemoteHost;
m_AxWindow = new CAxWindow();
HRESULT hr = m_AxWindow ? S_OK : E_OUTOFMEMORY;

View File

@ -138,20 +138,20 @@ void CPlayerWinamp::UpdateData()
m_Volume = (SendMessage(m_Window, WM_WA_IPC, -666, IPC_SETVOLUME) * 100) / 255; // 0 - 255 to 0 - 100
}
BOOL ret;
WCHAR wBuffer[MAX_PATH];
char cBuffer[MAX_PATH];
BOOL ret;
if (m_UseUnicodeAPI)
{
ret = ReadProcessMemory(m_WinampHandle, m_WinampAddress, &wBuffer, MAX_PATH, NULL);
ret = ReadProcessMemory(m_WinampHandle, m_WinampAddress, &wBuffer, sizeof(wBuffer), NULL);
}
else
{
// MediaMonkey doesn't support wide IPC messages
int pos = SendMessage(m_Window, WM_WA_IPC, 0, IPC_GETLISTPOS);
LPCVOID address = (LPCVOID)SendMessage(m_Window, WM_WA_IPC, pos, IPC_GETPLAYLISTFILE);
ret = ReadProcessMemory(m_WinampHandle, address, &cBuffer, MAX_PATH, NULL);
ret = ReadProcessMemory(m_WinampHandle, address, &cBuffer, sizeof(cBuffer), NULL);
mbstowcs(wBuffer, cBuffer, MAX_PATH);
}
@ -182,13 +182,13 @@ void CPlayerWinamp::UpdateData()
if (m_UseUnicodeAPI)
{
LPCVOID address = (LPCVOID)SendMessage(m_Window, WM_WA_IPC, 0, IPC_GET_PLAYING_TITLE);
ret = ReadProcessMemory(m_WinampHandle, address, &wBuffer, MAX_PATH, NULL);
ret = ReadProcessMemory(m_WinampHandle, address, &wBuffer, sizeof(wBuffer), NULL);
}
else
{
int pos = SendMessage(m_Window, WM_WA_IPC, 0, IPC_GETLISTPOS);
LPCVOID address = (LPCVOID)SendMessage(m_Window, WM_WA_IPC, pos, IPC_GETPLAYLISTTITLE);
ReadProcessMemory(m_WinampHandle, m_WinampAddress, &cBuffer, MAX_PATH, NULL);
ReadProcessMemory(m_WinampHandle, m_WinampAddress, &cBuffer, sizeof(cBuffer), NULL);
ret = mbstowcs(wBuffer, cBuffer, MAX_PATH);
}

View File

@ -12,7 +12,7 @@
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,1,0
FILEVERSION 1,1,2,0
PRODUCTVERSION PRODUCTVER
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
@ -29,7 +29,7 @@ BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "NowPlaying Plugin for Rainmeter"
VALUE "FileVersion", "1.1.1.0"
VALUE "FileVersion", "1.1.2.0"
VALUE "InternalName", "NowPlaying"
VALUE "LegalCopyright", "Copyright (C) 2011 - Birunthan Mohanathas"
VALUE "OriginalFilename", "NowPlaying.dll"

View File

@ -1,21 +1,3 @@
/*
Copyright (C) 2011 Birunthan Mohanathas (www.poiru.net)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __CADSDK_H__
#define __CADSDK_H__
@ -155,10 +137,6 @@ enum IPCMESSAGE
// uMsg: WM_USER, wParam: 0, lParam: 801
IPC_GET_CURRENT_LYRICS,
IPC_ADDFILE_PLAY_PLAYLIST,
IPC_ADDFILE_QUEUE_PLAYLIST
};
#endif