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
6b06548260
commit
d598c56b76
@ -39,8 +39,7 @@ bool CCover::GetCached(std::wstring& path)
|
|||||||
*/
|
*/
|
||||||
bool CCover::GetLocal(std::wstring filename, const std::wstring& folder, std::wstring& target)
|
bool CCover::GetLocal(std::wstring filename, const std::wstring& folder, std::wstring& target)
|
||||||
{
|
{
|
||||||
std::wstring testPath = folder;
|
std::wstring testPath = folder + filename;
|
||||||
testPath += filename;
|
|
||||||
testPath += L".";
|
testPath += L".";
|
||||||
std::wstring::size_type origLen = testPath.length();
|
std::wstring::size_type origLen = testPath.length();
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ void CInternet::DecodeReferences(std::wstring& str)
|
|||||||
/*
|
/*
|
||||||
** ConvertToWide
|
** ConvertToWide
|
||||||
**
|
**
|
||||||
** Convert from multibyte ti wide string.
|
** Convert multibyte string to wide string.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
std::wstring CInternet::ConvertToWide(LPCSTR str, int codepage)
|
std::wstring CInternet::ConvertToWide(LPCSTR str, int codepage)
|
||||||
@ -266,15 +266,12 @@ std::wstring CInternet::ConvertToWide(LPCSTR str, int codepage)
|
|||||||
|
|
||||||
if (str && *str)
|
if (str && *str)
|
||||||
{
|
{
|
||||||
int strLen = (int)strlen(str) + 1;
|
int strLen = (int)strlen(str);
|
||||||
int bufLen = MultiByteToWideChar(codepage, 0, str, strLen, NULL, 0);
|
int bufLen = MultiByteToWideChar(codepage, 0, str, strLen, NULL, 0);
|
||||||
if (bufLen > 0)
|
if (bufLen > 0)
|
||||||
{
|
{
|
||||||
WCHAR* wideSz = new WCHAR[bufLen];
|
szWide.resize(bufLen);
|
||||||
wideSz[0] = 0;
|
MultiByteToWideChar(codepage, 0, str, strLen, &szWide[0], bufLen);
|
||||||
MultiByteToWideChar(codepage, 0, str, strLen, wideSz, bufLen);
|
|
||||||
szWide = wideSz;
|
|
||||||
delete [] wideSz;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,8 +49,7 @@ bool CLyrics::GetFromWikia(const std::wstring& artist, const std::wstring& title
|
|||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
std::wstring url = L"http://lyrics.wikia.com/api.php?func=getSong&fmt=json&artist=";
|
std::wstring url = L"http://lyrics.wikia.com/api.php?func=getSong&fmt=json&artist=" + artist;
|
||||||
url += artist;
|
|
||||||
url += L"&song=";
|
url += L"&song=";
|
||||||
url += title;
|
url += title;
|
||||||
|
|
||||||
@ -126,8 +125,7 @@ bool CLyrics::GetFromLYRDB(const std::wstring& artist, const std::wstring& title
|
|||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
std::wstring query = artist;
|
std::wstring query = artist + L"|";
|
||||||
query += L"|";
|
|
||||||
query += title;
|
query += title;
|
||||||
|
|
||||||
// LYRDB doesn't like apostrophes
|
// LYRDB doesn't like apostrophes
|
||||||
@ -137,8 +135,7 @@ bool CLyrics::GetFromLYRDB(const std::wstring& artist, const std::wstring& title
|
|||||||
query.erase(pos, 3);
|
query.erase(pos, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring url = L"http://webservices.lyrdb.com/lookup.php?q=";
|
std::wstring url = L"http://webservices.lyrdb.com/lookup.php?q=" + query;
|
||||||
url += query;
|
|
||||||
url += L"&for=match&agent=RainmeterNowPlaying";
|
url += L"&for=match&agent=RainmeterNowPlaying";
|
||||||
|
|
||||||
data = CInternet::DownloadUrl(url, CP_ACP);
|
data = CInternet::DownloadUrl(url, CP_ACP);
|
||||||
@ -172,8 +169,7 @@ bool CLyrics::GetFromLetras(const std::wstring& artist, const std::wstring& titl
|
|||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
std::wstring url = L"http://letras.terra.com.br/winamp.php?musica=";
|
std::wstring url = L"http://letras.terra.com.br/winamp.php?musica=" + title;
|
||||||
url += title;
|
|
||||||
url += L"&artista=";
|
url += L"&artista=";
|
||||||
url += artist;
|
url += artist;
|
||||||
data = CInternet::DownloadUrl(url, CP_ACP);
|
data = CInternet::DownloadUrl(url, CP_ACP);
|
||||||
|
@ -242,6 +242,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
|||||||
}
|
}
|
||||||
else if (_wcsicmp(L"LYRICS", str) == 0)
|
else if (_wcsicmp(L"LYRICS", str) == 0)
|
||||||
{
|
{
|
||||||
|
LSLog(LOG_WARNING, L"Rainmeter", L"NowPlayingPlugin: Using undocumented PlayerType=LYRICS!");
|
||||||
child->type = MEASURE_LYRICS;
|
child->type = MEASURE_LYRICS;
|
||||||
}
|
}
|
||||||
else if (_wcsicmp(L"FILE", str) == 0)
|
else if (_wcsicmp(L"FILE", str) == 0)
|
||||||
|
@ -29,11 +29,10 @@ extern std::wstring g_CachePath;
|
|||||||
*/
|
*/
|
||||||
CPlayer::CPlayer() :
|
CPlayer::CPlayer() :
|
||||||
m_Initialized(false),
|
m_Initialized(false),
|
||||||
m_HasCoverMeasure(false),
|
|
||||||
m_HasLyricsMeasure(false),
|
|
||||||
m_InstanceCount(),
|
m_InstanceCount(),
|
||||||
m_UpdateCount(),
|
m_UpdateCount(),
|
||||||
m_TrackCount(),
|
m_TrackCount(),
|
||||||
|
m_Measures(),
|
||||||
m_State(),
|
m_State(),
|
||||||
m_Duration(),
|
m_Duration(),
|
||||||
m_Position(),
|
m_Position(),
|
||||||
@ -90,18 +89,9 @@ void CPlayer::RemoveInstance()
|
|||||||
** Called during initialization of any measure.
|
** Called during initialization of any measure.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
void CPlayer::AddMeasure(MEASURETYPE measure)
|
void CPlayer::AddMeasure(INT type)
|
||||||
{
|
{
|
||||||
switch (measure)
|
m_Measures |= type;
|
||||||
{
|
|
||||||
case MEASURE_LYRICS:
|
|
||||||
m_HasLyricsMeasure = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MEASURE_COVER:
|
|
||||||
m_HasCoverMeasure = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -135,8 +125,7 @@ std::wstring CPlayer::GetCacheFile()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::wstring name = m_Artist;
|
std::wstring name = m_Artist + L" - ";
|
||||||
name += L" - ";
|
|
||||||
name += m_Title;
|
name += m_Title;
|
||||||
|
|
||||||
// Replace reserved chars with _
|
// Replace reserved chars with _
|
||||||
|
@ -34,19 +34,19 @@ enum PLAYSTATE
|
|||||||
|
|
||||||
enum MEASURETYPE
|
enum MEASURETYPE
|
||||||
{
|
{
|
||||||
MEASURE_ARTIST,
|
MEASURE_ARTIST = 0x00000001,
|
||||||
MEASURE_TITLE,
|
MEASURE_TITLE = 0x00000002,
|
||||||
MEASURE_ALBUM,
|
MEASURE_ALBUM = 0x00000004,
|
||||||
MEASURE_LYRICS,
|
MEASURE_LYRICS = 0x00000008,
|
||||||
MEASURE_COVER,
|
MEASURE_COVER = 0x00000010,
|
||||||
MEASURE_FILE,
|
MEASURE_FILE = 0x00000020,
|
||||||
MEASURE_DURATION,
|
MEASURE_DURATION = 0x00000040,
|
||||||
MEASURE_POSITION,
|
MEASURE_POSITION = 0x00000080,
|
||||||
MEASURE_PROGRESS,
|
MEASURE_PROGRESS = 0x00000100,
|
||||||
MEASURE_RATING,
|
MEASURE_RATING = 0x00000200,
|
||||||
MEASURE_VOLUME,
|
MEASURE_VOLUME = 0x00000400,
|
||||||
MEASURE_STATE,
|
MEASURE_STATE = 0x00000800,
|
||||||
MEASURE_STATUS
|
MEASURE_STATUS = 0x00001000
|
||||||
};
|
};
|
||||||
|
|
||||||
class CPlayer
|
class CPlayer
|
||||||
@ -58,7 +58,7 @@ public:
|
|||||||
void AddInstance();
|
void AddInstance();
|
||||||
void RemoveInstance();
|
void RemoveInstance();
|
||||||
void UpdateMeasure();
|
void UpdateMeasure();
|
||||||
virtual void AddMeasure(MEASURETYPE measure);
|
virtual void AddMeasure(INT type);
|
||||||
virtual void UpdateData() = 0;
|
virtual void UpdateData() = 0;
|
||||||
|
|
||||||
bool IsInitialized() { return m_Initialized; }
|
bool IsInitialized() { return m_Initialized; }
|
||||||
@ -95,12 +95,11 @@ protected:
|
|||||||
void ClearData();
|
void ClearData();
|
||||||
|
|
||||||
bool m_Initialized;
|
bool m_Initialized;
|
||||||
bool m_HasCoverMeasure;
|
|
||||||
bool m_HasLyricsMeasure;
|
|
||||||
UINT m_InstanceCount;
|
UINT m_InstanceCount;
|
||||||
UINT m_UpdateCount;
|
UINT m_UpdateCount;
|
||||||
UINT m_TrackCount;
|
UINT m_TrackCount;
|
||||||
|
|
||||||
|
INT m_Measures;
|
||||||
PLAYSTATE m_State;
|
PLAYSTATE m_State;
|
||||||
std::wstring m_Artist;
|
std::wstring m_Artist;
|
||||||
std::wstring m_Title;
|
std::wstring m_Title;
|
||||||
|
@ -118,8 +118,8 @@ bool CPlayerAIMP::CheckWindow()
|
|||||||
*/
|
*/
|
||||||
void CPlayerAIMP::UpdateData()
|
void CPlayerAIMP::UpdateData()
|
||||||
{
|
{
|
||||||
static long oldFileSize = 0;
|
static INT64 oldFileSize = 0;
|
||||||
static UINT oldTitleLen = 0;
|
static long oldTitleLen = 0;
|
||||||
|
|
||||||
if (!m_Initialized)
|
if (!m_Initialized)
|
||||||
{
|
{
|
||||||
@ -198,12 +198,12 @@ void CPlayerAIMP::UpdateData()
|
|||||||
++m_TrackCount;
|
++m_TrackCount;
|
||||||
|
|
||||||
// Find cover if needed
|
// Find cover if needed
|
||||||
if (m_HasCoverMeasure)
|
if (m_Measures & MEASURE_COVER)
|
||||||
{
|
{
|
||||||
FindCover();
|
FindCover();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_HasLyricsMeasure)
|
if (m_Measures & MEASURE_LYRICS)
|
||||||
{
|
{
|
||||||
FindLyrics();
|
FindLyrics();
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ LRESULT CALLBACK CPlayerCAD::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
|
|||||||
player->m_CoverPath.assign(data, 0, len);
|
player->m_CoverPath.assign(data, 0, len);
|
||||||
data.erase(0, ++len);
|
data.erase(0, ++len);
|
||||||
|
|
||||||
if (player->m_HasLyricsMeasure)
|
if (player->m_Measures & MEASURE_LYRICS)
|
||||||
{
|
{
|
||||||
player->FindLyrics();
|
player->FindLyrics();
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,7 @@ void CPlayerFoobar::Initialize()
|
|||||||
int version = (int)SendMessage(m_FooWindow, WM_USER, 0, FOO_GETVERSION);
|
int version = (int)SendMessage(m_FooWindow, WM_USER, 0, FOO_GETVERSION);
|
||||||
if (version < 100)
|
if (version < 100)
|
||||||
{
|
{
|
||||||
std::wstring error = L"Your copy of the foo_rainmeter.dll plugin for foobar2000 is outdated.\n";
|
std::wstring error = L"Your copy of the foo_rainmeter.dll plugin for foobar2000 is outdated.\nDownload the latest version from foo-rainmeter.googlecode.com and try again.";
|
||||||
error += L"Please download the latest version from foo-rainmeter.googlecode.com and try again.";
|
|
||||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_ICONERROR | MB_TOPMOST);
|
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_ICONERROR | MB_TOPMOST);
|
||||||
m_FooWindow = NULL;
|
m_FooWindow = NULL;
|
||||||
}
|
}
|
||||||
@ -264,12 +263,12 @@ LRESULT CALLBACK CPlayerFoobar::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
|
|||||||
player->m_FilePath = token;
|
player->m_FilePath = token;
|
||||||
player->m_Position = 0;
|
player->m_Position = 0;
|
||||||
|
|
||||||
if (player->m_HasCoverMeasure || player->m_InstanceCount == 0)
|
if (player->m_Measures & MEASURE_COVER || player->m_InstanceCount == 0)
|
||||||
{
|
{
|
||||||
player->FindCover();
|
player->FindCover();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player->m_HasLyricsMeasure)
|
if (player->m_Measures & MEASURE_LYRICS)
|
||||||
{
|
{
|
||||||
player->FindLyrics();
|
player->FindLyrics();
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,7 @@ void CPlayerITunes::OnTrackChange()
|
|||||||
++m_TrackCount;
|
++m_TrackCount;
|
||||||
m_FilePath = tmpStr;
|
m_FilePath = tmpStr;
|
||||||
|
|
||||||
if (m_HasCoverMeasure)
|
if (m_Measures & MEASURE_COVER)
|
||||||
{
|
{
|
||||||
m_CoverPath = GetCacheFile();
|
m_CoverPath = GetCacheFile();
|
||||||
if (!CCover::GetCached(m_CoverPath))
|
if (!CCover::GetCached(m_CoverPath))
|
||||||
@ -432,7 +432,7 @@ void CPlayerITunes::OnTrackChange()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_HasLyricsMeasure)
|
if (m_Measures & MEASURE_LYRICS)
|
||||||
{
|
{
|
||||||
FindLyrics();
|
FindLyrics();
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ void CPlayerSpotify::UpdateData()
|
|||||||
m_Artist = artist;
|
m_Artist = artist;
|
||||||
++m_TrackCount;
|
++m_TrackCount;
|
||||||
|
|
||||||
if (m_HasLyricsMeasure)
|
if (m_Measures & MEASURE_LYRICS)
|
||||||
{
|
{
|
||||||
FindLyrics();
|
FindLyrics();
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ LRESULT CALLBACK CPlayerWLM::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
|
|||||||
len = data.find_first_of(L'\\');
|
len = data.find_first_of(L'\\');
|
||||||
player->m_Album.assign(data, 0, len);
|
player->m_Album.assign(data, 0, len);
|
||||||
|
|
||||||
if (player->m_HasLyricsMeasure)
|
if (player->m_Measures & MEASURE_LYRICS)
|
||||||
{
|
{
|
||||||
player->FindLyrics();
|
player->FindLyrics();
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ void CPlayerWMP::UpdateData()
|
|||||||
|
|
||||||
// Find cover if needed
|
// Find cover if needed
|
||||||
// TODO: Fix temp solution
|
// TODO: Fix temp solution
|
||||||
if (m_HasCoverMeasure || m_InstanceCount == 0)
|
if (m_Measures & MEASURE_COVER || m_InstanceCount == 0)
|
||||||
{
|
{
|
||||||
spMedia->getItemInfo(CComBSTR("WM/WMCollectionID"), &val);
|
spMedia->getItemInfo(CComBSTR("WM/WMCollectionID"), &val);
|
||||||
targetPath.resize(targetPath.find_last_of(L'\\') + 1);
|
targetPath.resize(targetPath.find_last_of(L'\\') + 1);
|
||||||
@ -469,7 +469,7 @@ void CPlayerWMP::UpdateData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_HasLyricsMeasure)
|
if (m_Measures & MEASURE_LYRICS)
|
||||||
{
|
{
|
||||||
FindLyrics();
|
FindLyrics();
|
||||||
}
|
}
|
||||||
|
@ -184,18 +184,18 @@ void CPlayerWinamp::UpdateData()
|
|||||||
m_Album = tag->album().toWString();
|
m_Album = tag->album().toWString();
|
||||||
m_Title = tag->title().toWString();
|
m_Title = tag->title().toWString();
|
||||||
|
|
||||||
if (m_HasLyricsMeasure)
|
if (m_Measures & MEASURE_LYRICS)
|
||||||
{
|
{
|
||||||
FindLyrics();
|
FindLyrics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_HasLyricsMeasure)
|
else if (m_Measures & MEASURE_LYRICS)
|
||||||
{
|
{
|
||||||
m_Lyrics.clear();
|
m_Lyrics.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find cover if needed
|
// Find cover if needed
|
||||||
if (m_HasCoverMeasure)
|
if (m_Measures & MEASURE_COVER)
|
||||||
{
|
{
|
||||||
m_CoverPath = GetCacheFile();
|
m_CoverPath = GetCacheFile();
|
||||||
if (!CCover::GetCached(m_CoverPath) &&
|
if (!CCover::GetCached(m_CoverPath) &&
|
||||||
@ -266,7 +266,7 @@ void CPlayerWinamp::UpdateData()
|
|||||||
m_Rating = 0;
|
m_Rating = 0;
|
||||||
m_Duration = 0;
|
m_Duration = 0;
|
||||||
|
|
||||||
if (m_HasCoverMeasure)
|
if (m_Measures & MEASURE_COVER)
|
||||||
{
|
{
|
||||||
m_CoverPath.clear();
|
m_CoverPath.clear();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user