NowPlaying.dll: Added support for types NUMBER and YEAR

This commit is contained in:
Birunthan Mohanathas 2012-03-12 12:01:12 +00:00
parent 63c42fe3a5
commit a57d75399c
9 changed files with 104 additions and 50 deletions

View File

@ -271,6 +271,14 @@ PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
measure->type = MEASURE_FILE;
}
else if (_wcsicmp(L"NUMBER", str) == 0)
{
measure->type = MEASURE_NUMBER;
}
else if (_wcsicmp(L"YEAR", str) == 0)
{
measure->type = MEASURE_YEAR;
}
else
{
std::wstring error = L"NowPlaying.dll: Invalid PlayerType=";
@ -328,16 +336,22 @@ PLUGIN_EXPORT double Update(void* data)
return player->GetVolume();
case MEASURE_STATE:
return (UINT)player->GetState();
return player->GetState();
case MEASURE_STATUS:
return (UINT)player->IsInitialized();
return player->IsInitialized();
case MEASURE_SHUFFLE:
return (UINT)player->GetShuffle();
return player->GetShuffle();
case MEASURE_REPEAT:
return (UINT)player->GetRepeat();
return player->GetRepeat();
case MEASURE_NUMBER:
return player->GetNumber();
case MEASURE_YEAR:
return player->GetYear();
}
return 0.0;

View File

@ -30,6 +30,8 @@ CPlayer::CPlayer() :
m_TrackCount(),
m_Measures(),
m_State(),
m_Number(1),
m_Year(),
m_Shuffle(false),
m_Repeat(false),
m_Duration(),
@ -204,4 +206,6 @@ void CPlayer::ClearData()
m_Duration = 0;
m_Position = 0;
m_Rating = 0;
m_Number = 0;
m_Year = 0;
}

View File

@ -49,7 +49,9 @@ enum MeasureType
MEASURE_STATE = 0x00000800,
MEASURE_STATUS = 0x00001000,
MEASURE_SHUFFLE = 0x00002000,
MEASURE_REPEAT = 0x00004000
MEASURE_REPEAT = 0x00004000,
MEASURE_NUMBER = 0x00008000,
MEASURE_YEAR = 0x00010000
};
class CPlayer
@ -87,16 +89,18 @@ public:
void SetMeasures(INT measures) { m_Measures = measures; }
StateType GetState() const { return m_State; }
LPCTSTR GetArtist() const{ return m_Artist.c_str(); }
LPCTSTR GetAlbum() const{ return m_Album.c_str(); }
LPCTSTR GetTitle() const{ return m_Title.c_str(); }
LPCTSTR GetLyrics() const{ return m_Lyrics.c_str(); }
LPCTSTR GetCoverPath() const{ return m_CoverPath.c_str(); }
LPCTSTR GetFilePath() const{ return m_FilePath.c_str(); }
UINT GetDuration() const{ return m_Duration; }
UINT GetPosition() const{ return m_Position; }
UINT GetRating() const{ return m_Rating; }
UINT GetVolume() const{ return m_Volume; }
LPCTSTR GetArtist() const { return m_Artist.c_str(); }
LPCTSTR GetAlbum() const { return m_Album.c_str(); }
LPCTSTR GetTitle() const { return m_Title.c_str(); }
LPCTSTR GetLyrics() const { return m_Lyrics.c_str(); }
LPCTSTR GetCoverPath() const { return m_CoverPath.c_str(); }
LPCTSTR GetFilePath() const { return m_FilePath.c_str(); }
UINT GetDuration() const { return m_Duration; }
UINT GetPosition() const { return m_Position; }
UINT GetRating() const { return m_Rating; }
UINT GetVolume() const { return m_Volume; }
UINT GetNumber() const { return m_Number; }
UINT GetYear() const { return m_Year; }
bool GetShuffle() const { return m_Shuffle; }
bool GetRepeat() const { return m_Repeat; }
@ -122,6 +126,8 @@ protected:
UINT m_Position; // Current position in seconds
UINT m_Rating; // Track rating from 0 to 100
UINT m_Volume; // Volume from 0 to 100
UINT m_Number;
UINT m_Year;
bool m_Shuffle;
bool m_Repeat;

View File

@ -164,8 +164,9 @@ void CPlayerAIMP::UpdateData()
stringData += info->nFileNameLen;
stringData += info->nGenreLen;
m_Title.assign(stringData, info->nTitleLen);
m_Duration = info->nDuration / 1000;
m_Number = (UINT)info->nTrackID;
m_Shuffle = (bool)SendMessage(m_Window, WM_AIMP_COMMAND, WM_AIMP_STATUS_GET, AIMP_STS_SHUFFLE);
m_Repeat = (bool)SendMessage(m_Window, WM_AIMP_COMMAND, WM_AIMP_STATUS_GET, AIMP_STS_REPEAT);

View File

@ -275,43 +275,58 @@ LRESULT CALLBACK CPlayerCAD::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
// TODO: Sent on track update?
++player->m_TrackCount;
std::wstring data = (WCHAR*)cds->lpData;
std::wstring::size_type len = data.find_first_of(L'\t');
player->m_Title.assign(data, 0, len);
data.erase(0, ++len);
WCHAR* data = (WCHAR*)cds->lpData;
WCHAR* pos;
UINT index = 1;
while ((pos = wcschr(data, '\t')) != NULL)
{
switch (index)
{
case 1:
player->m_Title.assign(data, pos - data);
break;
len = data.find_first_of(L'\t');
player->m_Artist.assign(data, 0, len);
data.erase(0, ++len);
case 2:
player->m_Artist.assign(data, pos - data);
break;
len = data.find_first_of(L'\t');
player->m_Album.assign(data, 0, len);
data.erase(0, ++len);
case 3:
player->m_Album.assign(data, pos - data);
break;
len = data.find_first_of(L'\t'); // Skip genre
len = data.find_first_of(L'\t', ++len); // Skip year
len = data.find_first_of(L'\t', ++len); // Skip comments
len = data.find_first_of(L'\t', ++len); // Skip track no
data.erase(0, ++len);
case 5:
player->m_Year = (UINT)_wtoi(data);
break;
len = data.find_first_of(L'\t');
std::wstring tmpStr(data, 0, len);
player->m_Duration = _wtoi(tmpStr.c_str());
data.erase(0, ++len);
case 7:
player->m_Number = (UINT)_wtoi(data);
break;
len = data.find_first_of(L'\t');
player->m_FilePath.assign(data, 0, len);
data.erase(0, ++len);
case 8:
player->m_Duration = (UINT)_wtoi(data);
break;
len = data.find_first_of(L'\t');
tmpStr.assign(data, 0, len);
UINT rating = (_wtoi(tmpStr.c_str()) + 1) / 2; // From 0 - 10 to 0 - 5
player->m_Rating = rating;
data.erase(0, ++len);
case 9:
player->m_FilePath.assign(data, pos - data);
break;
len = data.find_first_of(L'\t');
player->m_CoverPath.assign(data, 0, len);
data.erase(0, ++len);
case 10:
player->m_Rating = ((UINT)_wtoi(data) + 1) / 2; // 0 - 10 -> 0 - 5
break;
case 11:
player->m_CoverPath.assign(data, pos - data);
break;
}
data = pos + 1;
++index;
if (index == 12)
{
break;
}
}
if (player->m_Measures & MEASURE_LYRICS)
{
@ -436,7 +451,7 @@ void CPlayerCAD::SetPosition(int position)
}
/*
** Handles the SetVolume bang.
** Handles the SetRating bang.
**
*/
void CPlayerCAD::SetRating(int rating)

View File

@ -378,6 +378,12 @@ void CPlayerITunes::OnTrackChange()
tmpVal /= 20L;
m_Rating = (UINT)tmpVal;
track->get_TrackNumber(&tmpVal);
m_Number = (UINT)tmpVal;
track->get_Year(&tmpVal);
m_Year = (UINT)tmpVal;
IITPlaylist* playlist;
hr = track->get_Playlist(&playlist);
if (SUCCEEDED(hr))

View File

@ -397,6 +397,12 @@ void CPlayerWMP::UpdateData()
m_Rating = rating;
}
spMedia->getItemInfo(CComBSTR(L"WM/TrackNumber"), &val);
m_Number = (UINT)_wtoi(val);
spMedia->getItemInfo(CComBSTR(L"WM/Year"), &val);
m_Year = (UINT)_wtoi(val);
double duration;
spMedia->get_duration(&duration);
m_Duration = (UINT)duration;

View File

@ -176,6 +176,8 @@ void CPlayerWinamp::UpdateData()
m_Artist = tag->artist().toWString();
m_Album = tag->album().toWString();
m_Title = tag->title().toWString();
m_Number = tag->track();
m_Year = tag->year();
if (m_Measures & MEASURE_LYRICS)
{

View File

@ -7,7 +7,7 @@
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,3,7
FILEVERSION 1,1,4,0
PRODUCTVERSION PRODUCTVER
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
@ -23,8 +23,8 @@ BEGIN
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileVersion", "1.1.3.7"
VALUE "LegalCopyright", "© 2011 - Birunthan Mohanathas"
VALUE "FileVersion", "1.1.4.0"
VALUE "LegalCopyright", "© 2012 - Birunthan Mohanathas"
VALUE "OriginalFilename", "NowPlaying.dll"
VALUE "ProductName", "Rainmeter"
#ifdef _WIN64