mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
NowPlayingPlugin: Minor tweaks.
This commit is contained in:
parent
3268c774d2
commit
72f5d55090
@ -88,8 +88,8 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
int len = wcslen(str) - 2;
|
||||
if (len > 0)
|
||||
{
|
||||
MeasureMap::iterator it;
|
||||
for (it = g_Values.begin(); it != g_Values.end(); ++it)
|
||||
MeasureMap::iterator it = g_Values.begin();
|
||||
for ( ; it != g_Values.end(); ++it)
|
||||
{
|
||||
if (wcsncmp(&str[1], it->second->section.c_str(), len) == 0 &&
|
||||
wcscmp(iniFile, it->second->iniFile.c_str()) == 0)
|
||||
|
@ -28,9 +28,16 @@ extern CPlayer* g_iTunes;
|
||||
**
|
||||
*/
|
||||
CPlayerITunes::CEventHandler::CEventHandler(CPlayerITunes* player) :
|
||||
m_iTunes(player),
|
||||
m_RefCount()
|
||||
m_Player(player),
|
||||
m_RefCount(),
|
||||
m_ConnectionPoint(),
|
||||
m_ConnectionCookie()
|
||||
{
|
||||
IConnectionPointContainer* icpc;
|
||||
m_Player->m_iTunes->QueryInterface(IID_IConnectionPointContainer, (void**)&icpc);
|
||||
icpc->FindConnectionPoint(DIID__IiTunesEvents, &m_ConnectionPoint);
|
||||
m_ConnectionPoint->Advise(this, &m_ConnectionCookie);
|
||||
icpc->Release();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -41,6 +48,11 @@ CPlayerITunes::CEventHandler::CEventHandler(CPlayerITunes* player) :
|
||||
*/
|
||||
CPlayerITunes::CEventHandler::~CEventHandler()
|
||||
{
|
||||
if (m_ConnectionPoint)
|
||||
{
|
||||
m_ConnectionPoint->Unadvise(m_ConnectionCookie);
|
||||
m_ConnectionPoint->Release();
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CPlayerITunes::CEventHandler::QueryInterface(REFIID iid, void** ppvObject)
|
||||
@ -57,19 +69,12 @@ HRESULT STDMETHODCALLTYPE CPlayerITunes::CEventHandler::QueryInterface(REFIID ii
|
||||
|
||||
ULONG STDMETHODCALLTYPE CPlayerITunes::CEventHandler::AddRef()
|
||||
{
|
||||
++m_RefCount;
|
||||
return m_RefCount;
|
||||
return ++m_RefCount;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE CPlayerITunes::CEventHandler::Release()
|
||||
{
|
||||
--m_RefCount;
|
||||
if (m_RefCount == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return m_RefCount;
|
||||
return --m_RefCount;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CPlayerITunes::CEventHandler::Invoke(DISPID dispidMember, REFIID, LCID, WORD, DISPPARAMS* dispParams, VARIANT*, EXCEPINFO*, UINT*)
|
||||
@ -77,25 +82,25 @@ HRESULT STDMETHODCALLTYPE CPlayerITunes::CEventHandler::Invoke(DISPID dispidMemb
|
||||
switch (dispidMember)
|
||||
{
|
||||
case ITEventPlayerPlay:
|
||||
m_iTunes->OnStateChange(true);
|
||||
m_iTunes->OnTrackChange();
|
||||
m_Player->OnStateChange(true);
|
||||
m_Player->OnTrackChange();
|
||||
break;
|
||||
|
||||
case ITEventPlayerStop:
|
||||
m_iTunes->OnStateChange(false);
|
||||
m_Player->OnStateChange(false);
|
||||
break;
|
||||
|
||||
case ITEventPlayerPlayingTrackChanged:
|
||||
m_iTunes->OnTrackChange();
|
||||
m_Player->OnTrackChange();
|
||||
break;
|
||||
|
||||
case ITEventSoundVolumeChanged:
|
||||
m_iTunes->OnVolumeChange(dispParams->rgvarg[0].intVal);
|
||||
m_Player->OnVolumeChange(dispParams->rgvarg[0].intVal);
|
||||
break;
|
||||
|
||||
case ITEventAboutToPromptUserToQuit:
|
||||
m_iTunes->m_UserQuitPrompt = true;
|
||||
m_iTunes->Uninitialize();
|
||||
m_Player->m_UserQuitPrompt = true;
|
||||
m_Player->Uninitialize();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -114,9 +119,7 @@ CPlayerITunes::CPlayerITunes() : CPlayer(),
|
||||
m_HasCoverMeasure(false),
|
||||
m_Window(),
|
||||
m_iTunes(),
|
||||
m_iTunesEvent(),
|
||||
m_ConnectionPoint(),
|
||||
m_ConnectionCookie()
|
||||
m_iTunesEvent()
|
||||
{
|
||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
}
|
||||
@ -196,12 +199,7 @@ void CPlayerITunes::Initialize()
|
||||
m_Initialized = true;
|
||||
|
||||
// Set up event handler
|
||||
IConnectionPointContainer* icpc;
|
||||
m_iTunes->QueryInterface(IID_IConnectionPointContainer, (void **)&icpc);
|
||||
icpc->FindConnectionPoint(DIID__IiTunesEvents, &m_ConnectionPoint);
|
||||
icpc->Release();
|
||||
m_iTunesEvent = new CEventHandler(this);
|
||||
m_ConnectionPoint->Advise(m_iTunesEvent, &m_ConnectionCookie);
|
||||
|
||||
// Try getting track info and player state
|
||||
ITPlayerState state;
|
||||
@ -251,17 +249,11 @@ void CPlayerITunes::Uninitialize()
|
||||
if (m_Initialized)
|
||||
{
|
||||
m_Initialized = false;
|
||||
|
||||
m_UserQuitPrompt = true;
|
||||
if (m_iTunes)
|
||||
{
|
||||
m_iTunes->Release();
|
||||
m_iTunesEvent->Release();
|
||||
}
|
||||
|
||||
if (m_ConnectionPoint)
|
||||
{
|
||||
m_ConnectionPoint->Unadvise(m_ConnectionCookie);
|
||||
m_ConnectionPoint->Release();
|
||||
delete m_iTunesEvent;
|
||||
}
|
||||
|
||||
ClearInfo();
|
||||
|
@ -74,7 +74,9 @@ private:
|
||||
|
||||
private:
|
||||
ULONG m_RefCount;
|
||||
CPlayerITunes* m_iTunes;
|
||||
CPlayerITunes* m_Player;
|
||||
IConnectionPoint* m_ConnectionPoint;
|
||||
DWORD m_ConnectionCookie;
|
||||
};
|
||||
|
||||
void Initialize();
|
||||
@ -91,8 +93,6 @@ private:
|
||||
|
||||
IiTunes* m_iTunes;
|
||||
CEventHandler* m_iTunesEvent;
|
||||
IConnectionPoint* m_ConnectionPoint;
|
||||
DWORD m_ConnectionCookie;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@ extern CPlayer* g_WMP;
|
||||
**
|
||||
*/
|
||||
CPlayerWMP::CRemoteHost::CRemoteHost() :
|
||||
m_WMP()
|
||||
m_Player()
|
||||
{
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ HRESULT CPlayerWMP::CRemoteHost::GetCustomUIMode(BSTR* pbstrFile)
|
||||
*/
|
||||
void CPlayerWMP::CRemoteHost::CurrentItemChange(IDispatch* pdispMedia)
|
||||
{
|
||||
m_WMP->m_TrackChanged = true;
|
||||
m_Player->m_TrackChanged = true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -111,19 +111,19 @@ void CPlayerWMP::CRemoteHost::PlayStateChange(long NewState)
|
||||
{
|
||||
case wmppsStopped:
|
||||
case wmppsMediaEnded:
|
||||
m_WMP->ClearInfo();
|
||||
m_Player->ClearInfo();
|
||||
break;
|
||||
|
||||
case wmppsPaused:
|
||||
m_WMP->m_State = PLAYER_PAUSED;
|
||||
m_Player->m_State = PLAYER_PAUSED;
|
||||
break;
|
||||
|
||||
case wmppsPlaying:
|
||||
if (m_WMP->m_State == PLAYER_STOPPED)
|
||||
if (m_Player->m_State == PLAYER_STOPPED)
|
||||
{
|
||||
m_WMP->m_TrackChanged = true;
|
||||
m_Player->m_TrackChanged = true;
|
||||
}
|
||||
m_WMP->m_State = PLAYER_PLAYING;
|
||||
m_Player->m_State = PLAYER_PLAYING;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -139,8 +139,8 @@ void CPlayerWMP::CRemoteHost::PlayStateChange(long NewState)
|
||||
*/
|
||||
void CPlayerWMP::CRemoteHost::SwitchedToControl()
|
||||
{
|
||||
m_WMP->ClearInfo();
|
||||
m_WMP->Uninitialize();
|
||||
m_Player->ClearInfo();
|
||||
m_Player->Uninitialize();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -273,7 +273,7 @@ void CPlayerWMP::Initialize()
|
||||
if (pRemoteHost)
|
||||
{
|
||||
pRemoteHost->AddRef();
|
||||
pRemoteHost->m_WMP = this;
|
||||
pRemoteHost->m_Player = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ private:
|
||||
CRemoteHost();
|
||||
~CRemoteHost();
|
||||
|
||||
CPlayerWMP* m_WMP;
|
||||
CPlayerWMP* m_Player;
|
||||
|
||||
BEGIN_COM_MAP(CRemoteHost)
|
||||
COM_INTERFACE_ENTRY(IServiceProvider)
|
||||
|
Loading…
Reference in New Issue
Block a user