NowPlaying.dll: iTunes shuffle state change now detected immediately.

This commit is contained in:
Birunthan Mohanathas 2011-11-19 11:44:04 +00:00
parent 42ce3d9666
commit d3a2a8a137
3 changed files with 40 additions and 14 deletions

View File

@ -1969,17 +1969,14 @@ BOOL CRainmeter::ExecuteBang(const std::wstring& bang, const std::wstring& arg,
ExecuteCommand(command.c_str() + notwhite, meterWindow); ExecuteCommand(command.c_str() + notwhite, meterWindow);
} }
} }
else if (args[i] == L'"' && args[i + 1] == L'"' && args[i + 2] == L'"') else if (args[i] == L'"' && isize > (i + 2) && args[i + 1] == L'"' && args[i + 2] == L'"')
{ {
i += 3; i += 3;
if (isize > i) std::wstring::size_type pos = arg.find(L"\"\"\"", i);
if (pos != std::wstring::npos)
{ {
std::wstring::size_type pos = arg.find(L"\"\"\"", i); i = pos + 2; // Skip "", loop will skip last "
if (pos != std::wstring::npos)
{
i = pos + 2; // Skip "", loop will skip last "
}
} }
} }
} }

View File

@ -82,6 +82,10 @@ HRESULT STDMETHODCALLTYPE CPlayerITunes::CEventHandler::Invoke(DISPID dispidMemb
{ {
switch (dispidMember) switch (dispidMember)
{ {
case ITEventDatabaseChanged:
m_Player->OnDatabaseChange();
break;
case ITEventPlayerPlay: case ITEventPlayerPlay:
m_Player->OnStateChange(true); m_Player->OnStateChange(true);
m_Player->OnTrackChange(); m_Player->OnTrackChange();
@ -339,6 +343,37 @@ void CPlayerITunes::UpdateData()
} }
} }
/*
** OnDatabaseChange
**
** Called by iTunes event handler when the database is changed.
**
*/
void CPlayerITunes::OnDatabaseChange()
{
// Check the shuffle state. TODO: Find better way
IITTrack* track;
HRESULT hr = m_iTunes->get_CurrentTrack(&track);
if (SUCCEEDED(hr) && track)
{
IITPlaylist* playlist;
hr = track->get_Playlist(&playlist);
if (SUCCEEDED(hr))
{
VARIANT_BOOL shuffle;
hr = playlist->get_Shuffle(&shuffle);
if (SUCCEEDED(hr))
{
m_Shuffle = (bool)shuffle;
}
playlist->Release();
}
track->Release();
}
}
/* /*
** OnTrackChange ** OnTrackChange
** **
@ -376,13 +411,6 @@ void CPlayerITunes::OnTrackChange()
hr = track->get_Playlist(&playlist); hr = track->get_Playlist(&playlist);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
VARIANT_BOOL shuffle;
hr = playlist->get_Shuffle(&shuffle);
if (SUCCEEDED(hr))
{
m_Shuffle = (bool)shuffle;
}
ITPlaylistRepeatMode repeat; ITPlaylistRepeatMode repeat;
hr = playlist->get_SongRepeat(&repeat); hr = playlist->get_SongRepeat(&repeat);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))

View File

@ -87,6 +87,7 @@ private:
void Initialize(); void Initialize();
void Uninitialize(); void Uninitialize();
void OnDatabaseChange();
void OnTrackChange(); void OnTrackChange();
void OnStateChange(bool playing); void OnStateChange(bool playing);
void OnVolumeChange(int volume); void OnVolumeChange(int volume);