mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
- NowPlaying.dll/iTunesPlugin.dll: Fixed incompatibility with iTunes controllers
- NowPlaying.dll: Removed support for caching cover art
This commit is contained in:
parent
2a166b520f
commit
c8e4608b41
@ -70,7 +70,7 @@ bool CCover::GetLocal(std::wstring filename, const std::wstring& folder, std::ws
|
||||
** Attempts to extract cover art from audio files.
|
||||
**
|
||||
*/
|
||||
bool CCover::GetEmbedded(const TagLib::FileRef& fr, std::wstring& target)
|
||||
bool CCover::GetEmbedded(const TagLib::FileRef& fr, const std::wstring& target)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
|
@ -44,7 +44,7 @@ class CCover
|
||||
public:
|
||||
static bool GetCached(std::wstring& path);
|
||||
static bool GetLocal(std::wstring filename, const std::wstring& folder, std::wstring& target);
|
||||
static bool GetEmbedded(const TagLib::FileRef& fr, std::wstring& target);
|
||||
static bool GetEmbedded(const TagLib::FileRef& fr, const std::wstring& target);
|
||||
static std::wstring GetFileFolder(const std::wstring& file);
|
||||
|
||||
private:
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "PlayerWMP.h"
|
||||
|
||||
static std::map<UINT, ChildMeasure*> g_Measures;
|
||||
std::wstring g_CachePath;
|
||||
std::wstring g_SettingsFile;
|
||||
HINSTANCE g_Instance = NULL;
|
||||
|
||||
@ -42,15 +41,8 @@ HINSTANCE g_Instance = NULL;
|
||||
*/
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
if (g_Measures.empty())
|
||||
if (!g_Instance)
|
||||
{
|
||||
// Get path to temporary folder (for cover art cache)
|
||||
WCHAR buffer[MAX_PATH];
|
||||
GetTempPath(MAX_PATH, buffer);
|
||||
wcscat(buffer, L"Rainmeter-Cache\\");
|
||||
CreateDirectory(buffer, NULL);
|
||||
g_CachePath = buffer;
|
||||
|
||||
// Get path to Plugins.ini (usually %APPDATA%\Rainmeter\Plugins.ini)
|
||||
std::wstring str = PluginBridge(L"getconfig", iniFile);
|
||||
if (!str.empty())
|
||||
@ -59,10 +51,6 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
g_SettingsFile = PluginBridge(L"getvariable", str.c_str());
|
||||
g_SettingsFile += L"Plugins.ini";
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_ERROR, NULL, L"NowPlaying.dll: PluginBridge error");
|
||||
}
|
||||
|
||||
g_Instance = instance;
|
||||
CInternet::Initialize();
|
||||
@ -168,7 +156,6 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
|
||||
parent->id = id;
|
||||
parent->childCount = 1;
|
||||
parent->player->AddInstance();
|
||||
parent->playerPath = ReadConfigString(section, L"PlayerPath", L"");
|
||||
parent->trackChangeAction = ReadConfigString(section, L"TrackChangeAction", L"");
|
||||
@ -300,6 +287,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
|
||||
if (g_Measures.empty())
|
||||
{
|
||||
g_Instance = NULL;
|
||||
CInternet::Finalize();
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,13 @@
|
||||
|
||||
struct ParentMeasure
|
||||
{
|
||||
ParentMeasure() :
|
||||
player(NULL),
|
||||
childCount(1),
|
||||
trackCount(0),
|
||||
disableLeadingZero(false)
|
||||
{}
|
||||
|
||||
UINT id;
|
||||
UINT childCount;
|
||||
UINT trackCount;
|
||||
@ -33,16 +40,17 @@ struct ParentMeasure
|
||||
std::wstring trackChangeAction;
|
||||
std::wstring playerPath;
|
||||
bool disableLeadingZero;
|
||||
|
||||
ParentMeasure() : player(NULL) {}
|
||||
};
|
||||
|
||||
struct ChildMeasure
|
||||
{
|
||||
ChildMeasure() :
|
||||
type(MEASURE_NONE),
|
||||
parent(NULL)
|
||||
{}
|
||||
|
||||
MEASURETYPE type;
|
||||
ParentMeasure* parent;
|
||||
|
||||
ChildMeasure() : parent(NULL) {}
|
||||
};
|
||||
|
||||
void SecondsToTime(UINT seconds, bool leadingZero, WCHAR* buffer);
|
||||
|
@ -19,8 +19,6 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Player.h"
|
||||
|
||||
extern std::wstring g_CachePath;
|
||||
|
||||
/*
|
||||
** CPlayer
|
||||
**
|
||||
@ -42,6 +40,11 @@ CPlayer::CPlayer() :
|
||||
m_Volume(),
|
||||
m_InternetThread()
|
||||
{
|
||||
// Get temporary file for cover art
|
||||
WCHAR buffer[MAX_PATH];
|
||||
GetTempPath(MAX_PATH, buffer);
|
||||
GetTempFileName(buffer, L"cvr", 0, buffer);
|
||||
m_TempCoverPath = buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -111,35 +114,6 @@ void CPlayer::UpdateMeasure()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** GetCacheFile
|
||||
**
|
||||
** Creates escaped path to cache file (without extension)
|
||||
**
|
||||
*/
|
||||
std::wstring CPlayer::GetCacheFile()
|
||||
{
|
||||
std::wstring path = g_CachePath;
|
||||
|
||||
if (m_Artist.empty() || m_Title.empty())
|
||||
{
|
||||
path += L"temp";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring name = m_Artist + L" - ";
|
||||
name += m_Title;
|
||||
|
||||
// Replace reserved chars with _
|
||||
std::wstring::size_type pos = 0;
|
||||
while ((pos = name.find_first_of(L"\\/:*?\"<>|", pos)) != std::wstring::npos) name[pos] = L'_';
|
||||
|
||||
path += name;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/*
|
||||
** FindCover
|
||||
**
|
||||
@ -148,12 +122,12 @@ std::wstring CPlayer::GetCacheFile()
|
||||
*/
|
||||
void CPlayer::FindCover()
|
||||
{
|
||||
m_CoverPath = GetCacheFile();
|
||||
|
||||
if (!CCover::GetCached(m_CoverPath))
|
||||
{
|
||||
TagLib::FileRef fr(m_FilePath.c_str());
|
||||
if (fr.isNull() || !CCover::GetEmbedded(fr, m_CoverPath))
|
||||
if (!fr.isNull() && CCover::GetEmbedded(fr, m_TempCoverPath))
|
||||
{
|
||||
m_CoverPath = m_TempCoverPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring trackFolder = CCover::GetFileFolder(m_FilePath);
|
||||
|
||||
@ -164,7 +138,6 @@ void CPlayer::FindCover()
|
||||
m_CoverPath.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -34,6 +34,7 @@ enum PLAYSTATE
|
||||
|
||||
enum MEASURETYPE
|
||||
{
|
||||
MEASURE_NONE = 0x00000000,
|
||||
MEASURE_ARTIST = 0x00000001,
|
||||
MEASURE_TITLE = 0x00000002,
|
||||
MEASURE_ALBUM = 0x00000004,
|
||||
@ -66,7 +67,6 @@ public:
|
||||
bool IsInitialized() { return m_Initialized; }
|
||||
UINT GetTrackCount() { return m_TrackCount; }
|
||||
|
||||
std::wstring GetCacheFile();
|
||||
void FindCover();
|
||||
void FindLyrics();
|
||||
|
||||
@ -104,6 +104,7 @@ protected:
|
||||
UINT m_InstanceCount;
|
||||
UINT m_UpdateCount;
|
||||
UINT m_TrackCount;
|
||||
std::wstring m_TempCoverPath;
|
||||
|
||||
INT m_Measures;
|
||||
PLAYSTATE m_State;
|
||||
|
@ -287,7 +287,7 @@ LRESULT CALLBACK CPlayerITunes::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
|
||||
case WM_TIMER:
|
||||
if (wParam == TIMER_CHECKACTIVE)
|
||||
{
|
||||
if (!FindWindow(L"iTunes", L"iTunes"))
|
||||
if (!FindWindow(L"iTunesApp", L"iTunes") && !FindWindow(L"iTunes", L"iTunes"))
|
||||
{
|
||||
player->m_iTunesActive = false;
|
||||
KillTimer(hwnd, TIMER_CHECKACTIVE);
|
||||
@ -313,8 +313,7 @@ bool CPlayerITunes::CheckWindow()
|
||||
{
|
||||
m_LastCheckTime = time;
|
||||
|
||||
HWND wnd = FindWindow(L"ITWindow", L"iTunes");
|
||||
if (wnd && !m_iTunesActive)
|
||||
if ((FindWindow(L"iTunesApp", L"iTunes") || FindWindow(L"iTunes", L"iTunes")) && !m_iTunesActive)
|
||||
{
|
||||
m_iTunesActive = true;
|
||||
Initialize();
|
||||
@ -387,10 +386,9 @@ void CPlayerITunes::OnTrackChange()
|
||||
|
||||
if (m_Measures & MEASURE_COVER)
|
||||
{
|
||||
m_CoverPath = GetCacheFile();
|
||||
if (!CCover::GetCached(m_CoverPath))
|
||||
{
|
||||
// Art not in cache, check for embedded art through iTunes interface
|
||||
m_CoverPath.clear();
|
||||
|
||||
// Check for embedded art through iTunes interface
|
||||
IITArtworkCollection* artworkCollection;
|
||||
hr = track->get_Artwork(&artworkCollection);
|
||||
|
||||
@ -406,28 +404,19 @@ void CPlayerITunes::OnTrackChange()
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
tmpStr = m_CoverPath.c_str();
|
||||
tmpStr = m_TempCoverPath.c_str();
|
||||
hr = artwork->SaveArtworkToFile(tmpStr);
|
||||
if (FAILED(hr))
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
m_CoverPath.clear();
|
||||
m_CoverPath = m_TempCoverPath;
|
||||
}
|
||||
|
||||
artwork->Release();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CoverPath.clear();
|
||||
}
|
||||
|
||||
artworkCollection->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CoverPath.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Measures & MEASURE_LYRICS)
|
||||
|
@ -373,8 +373,6 @@ void CPlayerWMP::Uninitialize()
|
||||
*/
|
||||
void CPlayerWMP::UpdateData()
|
||||
{
|
||||
static bool clear = false;
|
||||
|
||||
if (m_Initialized)
|
||||
{
|
||||
// Get the volume
|
||||
|
@ -33,6 +33,7 @@ CPlayer* CPlayerWinamp::c_Player = NULL;
|
||||
*/
|
||||
CPlayerWinamp::CPlayerWinamp(WINAMPTYPE type) : CPlayer(),
|
||||
m_Window(),
|
||||
m_LastCheckTime(0),
|
||||
m_UseUnicodeAPI(false),
|
||||
m_PlayingStream(false),
|
||||
m_WinampType(type),
|
||||
@ -123,7 +124,7 @@ void CPlayerWinamp::UpdateData()
|
||||
if (m_WinampHandle) CloseHandle(m_WinampHandle);
|
||||
}
|
||||
|
||||
if (!m_FilePath.empty())
|
||||
if (m_State != PLAYER_STOPPED)
|
||||
{
|
||||
ClearData();
|
||||
}
|
||||
@ -198,12 +199,14 @@ void CPlayerWinamp::UpdateData()
|
||||
// Find cover if needed
|
||||
if (m_Measures & MEASURE_COVER)
|
||||
{
|
||||
m_CoverPath = GetCacheFile();
|
||||
if (!CCover::GetCached(m_CoverPath) &&
|
||||
(tag && !CCover::GetEmbedded(fr, m_CoverPath)))
|
||||
if (tag && CCover::GetEmbedded(fr, m_TempCoverPath))
|
||||
{
|
||||
std::wstring trackFolder = CCover::GetFileFolder(m_FilePath);
|
||||
// Got everything, return
|
||||
m_CoverPath = m_TempCoverPath;
|
||||
return;
|
||||
}
|
||||
|
||||
std::wstring trackFolder = CCover::GetFileFolder(m_FilePath);
|
||||
if (!m_Album.empty())
|
||||
{
|
||||
// Winamp stores covers usually as %album%.jpg
|
||||
@ -254,11 +257,8 @@ void CPlayerWinamp::UpdateData()
|
||||
m_CoverPath.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tag)
|
||||
else if (tag)
|
||||
{
|
||||
// Got metadata, return
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -266,13 +266,9 @@ void CPlayerWinamp::UpdateData()
|
||||
{
|
||||
m_Rating = 0;
|
||||
m_Duration = 0;
|
||||
|
||||
if (m_Measures & MEASURE_COVER)
|
||||
{
|
||||
m_CoverPath.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!m_PlayingStream)
|
||||
{
|
||||
return;
|
||||
|
@ -12,7 +12,7 @@
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,1,3,5
|
||||
FILEVERSION 1,1,3,6
|
||||
PRODUCTVERSION PRODUCTVER
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
@ -29,7 +29,7 @@ BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "NowPlaying Plugin for Rainmeter"
|
||||
VALUE "FileVersion", "1.1.3.5"
|
||||
VALUE "FileVersion", "1.1.3.6"
|
||||
VALUE "InternalName", "NowPlaying"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2011 - Birunthan Mohanathas"
|
||||
VALUE "OriginalFilename", "NowPlaying.dll"
|
||||
|
@ -450,7 +450,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
CoInitialized = true;
|
||||
}
|
||||
|
||||
if (CoInitialized && !InstanceCreated && ::FindWindow(L"ITWindow", L"iTunes"))
|
||||
if (CoInitialized && !InstanceCreated && (FindWindow(L"iTunesApp", L"iTunes") || FindWindow(L"iTunes", L"iTunes")))
|
||||
{
|
||||
if (SUCCEEDED(iTunes.CreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER)))
|
||||
{
|
||||
@ -490,7 +490,7 @@ UINT Update(UINT id)
|
||||
if (!CoInitialized || !InstanceCreated)
|
||||
{
|
||||
// Check if the iTunes window has appeared
|
||||
if (::FindWindow(L"ITWindow", L"iTunes"))
|
||||
if (FindWindow(L"iTunesApp", L"iTunes") || FindWindow(L"iTunes", L"iTunes"))
|
||||
{
|
||||
if (!iTunesAboutToPromptUserToQuit && SUCCEEDED(iTunes.CreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER)))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user