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;
|
int len = wcslen(str) - 2;
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
MeasureMap::iterator it;
|
MeasureMap::iterator it = g_Values.begin();
|
||||||
for (it = g_Values.begin(); it != g_Values.end(); ++it)
|
for ( ; it != g_Values.end(); ++it)
|
||||||
{
|
{
|
||||||
if (wcsncmp(&str[1], it->second->section.c_str(), len) == 0 &&
|
if (wcsncmp(&str[1], it->second->section.c_str(), len) == 0 &&
|
||||||
wcscmp(iniFile, it->second->iniFile.c_str()) == 0)
|
wcscmp(iniFile, it->second->iniFile.c_str()) == 0)
|
||||||
|
@ -28,9 +28,16 @@ extern CPlayer* g_iTunes;
|
|||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
CPlayerITunes::CEventHandler::CEventHandler(CPlayerITunes* player) :
|
CPlayerITunes::CEventHandler::CEventHandler(CPlayerITunes* player) :
|
||||||
m_iTunes(player),
|
m_Player(player),
|
||||||
m_RefCount()
|
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()
|
CPlayerITunes::CEventHandler::~CEventHandler()
|
||||||
{
|
{
|
||||||
|
if (m_ConnectionPoint)
|
||||||
|
{
|
||||||
|
m_ConnectionPoint->Unadvise(m_ConnectionCookie);
|
||||||
|
m_ConnectionPoint->Release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CPlayerITunes::CEventHandler::QueryInterface(REFIID iid, void** ppvObject)
|
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()
|
ULONG STDMETHODCALLTYPE CPlayerITunes::CEventHandler::AddRef()
|
||||||
{
|
{
|
||||||
++m_RefCount;
|
return ++m_RefCount;
|
||||||
return m_RefCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG STDMETHODCALLTYPE CPlayerITunes::CEventHandler::Release()
|
ULONG STDMETHODCALLTYPE CPlayerITunes::CEventHandler::Release()
|
||||||
{
|
{
|
||||||
--m_RefCount;
|
return --m_RefCount;
|
||||||
if (m_RefCount == 0)
|
|
||||||
{
|
|
||||||
delete this;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return m_RefCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CPlayerITunes::CEventHandler::Invoke(DISPID dispidMember, REFIID, LCID, WORD, DISPPARAMS* dispParams, VARIANT*, EXCEPINFO*, UINT*)
|
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)
|
switch (dispidMember)
|
||||||
{
|
{
|
||||||
case ITEventPlayerPlay:
|
case ITEventPlayerPlay:
|
||||||
m_iTunes->OnStateChange(true);
|
m_Player->OnStateChange(true);
|
||||||
m_iTunes->OnTrackChange();
|
m_Player->OnTrackChange();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITEventPlayerStop:
|
case ITEventPlayerStop:
|
||||||
m_iTunes->OnStateChange(false);
|
m_Player->OnStateChange(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITEventPlayerPlayingTrackChanged:
|
case ITEventPlayerPlayingTrackChanged:
|
||||||
m_iTunes->OnTrackChange();
|
m_Player->OnTrackChange();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITEventSoundVolumeChanged:
|
case ITEventSoundVolumeChanged:
|
||||||
m_iTunes->OnVolumeChange(dispParams->rgvarg[0].intVal);
|
m_Player->OnVolumeChange(dispParams->rgvarg[0].intVal);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITEventAboutToPromptUserToQuit:
|
case ITEventAboutToPromptUserToQuit:
|
||||||
m_iTunes->m_UserQuitPrompt = true;
|
m_Player->m_UserQuitPrompt = true;
|
||||||
m_iTunes->Uninitialize();
|
m_Player->Uninitialize();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,9 +119,7 @@ CPlayerITunes::CPlayerITunes() : CPlayer(),
|
|||||||
m_HasCoverMeasure(false),
|
m_HasCoverMeasure(false),
|
||||||
m_Window(),
|
m_Window(),
|
||||||
m_iTunes(),
|
m_iTunes(),
|
||||||
m_iTunesEvent(),
|
m_iTunesEvent()
|
||||||
m_ConnectionPoint(),
|
|
||||||
m_ConnectionCookie()
|
|
||||||
{
|
{
|
||||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||||
}
|
}
|
||||||
@ -196,12 +199,7 @@ void CPlayerITunes::Initialize()
|
|||||||
m_Initialized = true;
|
m_Initialized = true;
|
||||||
|
|
||||||
// Set up event handler
|
// 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_iTunesEvent = new CEventHandler(this);
|
||||||
m_ConnectionPoint->Advise(m_iTunesEvent, &m_ConnectionCookie);
|
|
||||||
|
|
||||||
// Try getting track info and player state
|
// Try getting track info and player state
|
||||||
ITPlayerState state;
|
ITPlayerState state;
|
||||||
@ -251,17 +249,11 @@ void CPlayerITunes::Uninitialize()
|
|||||||
if (m_Initialized)
|
if (m_Initialized)
|
||||||
{
|
{
|
||||||
m_Initialized = false;
|
m_Initialized = false;
|
||||||
|
m_UserQuitPrompt = true;
|
||||||
if (m_iTunes)
|
if (m_iTunes)
|
||||||
{
|
{
|
||||||
m_iTunes->Release();
|
m_iTunes->Release();
|
||||||
m_iTunesEvent->Release();
|
delete m_iTunesEvent;
|
||||||
}
|
|
||||||
|
|
||||||
if (m_ConnectionPoint)
|
|
||||||
{
|
|
||||||
m_ConnectionPoint->Unadvise(m_ConnectionCookie);
|
|
||||||
m_ConnectionPoint->Release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearInfo();
|
ClearInfo();
|
||||||
|
@ -74,7 +74,9 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ULONG m_RefCount;
|
ULONG m_RefCount;
|
||||||
CPlayerITunes* m_iTunes;
|
CPlayerITunes* m_Player;
|
||||||
|
IConnectionPoint* m_ConnectionPoint;
|
||||||
|
DWORD m_ConnectionCookie;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Initialize();
|
void Initialize();
|
||||||
@ -91,8 +93,6 @@ private:
|
|||||||
|
|
||||||
IiTunes* m_iTunes;
|
IiTunes* m_iTunes;
|
||||||
CEventHandler* m_iTunesEvent;
|
CEventHandler* m_iTunesEvent;
|
||||||
IConnectionPoint* m_ConnectionPoint;
|
|
||||||
DWORD m_ConnectionCookie;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,7 +28,7 @@ extern CPlayer* g_WMP;
|
|||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
CPlayerWMP::CRemoteHost::CRemoteHost() :
|
CPlayerWMP::CRemoteHost::CRemoteHost() :
|
||||||
m_WMP()
|
m_Player()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ HRESULT CPlayerWMP::CRemoteHost::GetCustomUIMode(BSTR* pbstrFile)
|
|||||||
*/
|
*/
|
||||||
void CPlayerWMP::CRemoteHost::CurrentItemChange(IDispatch* pdispMedia)
|
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 wmppsStopped:
|
||||||
case wmppsMediaEnded:
|
case wmppsMediaEnded:
|
||||||
m_WMP->ClearInfo();
|
m_Player->ClearInfo();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wmppsPaused:
|
case wmppsPaused:
|
||||||
m_WMP->m_State = PLAYER_PAUSED;
|
m_Player->m_State = PLAYER_PAUSED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wmppsPlaying:
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -139,8 +139,8 @@ void CPlayerWMP::CRemoteHost::PlayStateChange(long NewState)
|
|||||||
*/
|
*/
|
||||||
void CPlayerWMP::CRemoteHost::SwitchedToControl()
|
void CPlayerWMP::CRemoteHost::SwitchedToControl()
|
||||||
{
|
{
|
||||||
m_WMP->ClearInfo();
|
m_Player->ClearInfo();
|
||||||
m_WMP->Uninitialize();
|
m_Player->Uninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -273,7 +273,7 @@ void CPlayerWMP::Initialize()
|
|||||||
if (pRemoteHost)
|
if (pRemoteHost)
|
||||||
{
|
{
|
||||||
pRemoteHost->AddRef();
|
pRemoteHost->AddRef();
|
||||||
pRemoteHost->m_WMP = this;
|
pRemoteHost->m_Player = this;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,7 @@ private:
|
|||||||
CRemoteHost();
|
CRemoteHost();
|
||||||
~CRemoteHost();
|
~CRemoteHost();
|
||||||
|
|
||||||
CPlayerWMP* m_WMP;
|
CPlayerWMP* m_Player;
|
||||||
|
|
||||||
BEGIN_COM_MAP(CRemoteHost)
|
BEGIN_COM_MAP(CRemoteHost)
|
||||||
COM_INTERFACE_ENTRY(IServiceProvider)
|
COM_INTERFACE_ENTRY(IServiceProvider)
|
||||||
|
Loading…
Reference in New Issue
Block a user