2011-05-24 18:20:35 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2011 Birunthan Mohanathas (www.poiru.net)
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2011-05-24 18:20:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "PlayerCAD.h"
|
2011-05-28 07:50:33 +00:00
|
|
|
#include "CAD/cad_sdk.h"
|
2011-05-24 18:20:35 +00:00
|
|
|
|
2011-06-19 14:58:48 +00:00
|
|
|
CPlayer* CPlayerCAD::c_Player = NULL;
|
2011-06-12 10:05:37 +00:00
|
|
|
extern std::wstring g_SettingsFile;
|
2011-07-15 15:18:02 +00:00
|
|
|
extern HINSTANCE g_Instance;
|
2011-06-12 10:05:37 +00:00
|
|
|
|
|
|
|
// This player emulates the CD Art Display IPC interface, which is supported by
|
|
|
|
// MusicBee, VLC (with libcad plugin), and possibly others.
|
2011-05-24 18:20:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Constructor.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
CPlayerCAD::CPlayerCAD() : CPlayer(),
|
|
|
|
m_Window(),
|
2011-07-10 09:30:51 +00:00
|
|
|
m_PlayerWindow(),
|
|
|
|
m_ExtendedAPI(false)
|
2011-05-24 18:20:35 +00:00
|
|
|
{
|
|
|
|
Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Constructor.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
CPlayerCAD::~CPlayerCAD()
|
|
|
|
{
|
2011-06-19 14:58:48 +00:00
|
|
|
c_Player = NULL;
|
2011-05-24 18:20:35 +00:00
|
|
|
Uninitialize();
|
|
|
|
}
|
|
|
|
|
2011-06-19 14:58:48 +00:00
|
|
|
/*
|
|
|
|
** Creates a shared class object.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
CPlayer* CPlayerCAD::Create()
|
|
|
|
{
|
|
|
|
if (!c_Player)
|
|
|
|
{
|
|
|
|
c_Player = new CPlayerCAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
return c_Player;
|
|
|
|
}
|
|
|
|
|
2011-05-24 18:20:35 +00:00
|
|
|
/*
|
|
|
|
** Create receiver window.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::Initialize()
|
|
|
|
{
|
|
|
|
// Create windows class
|
|
|
|
WNDCLASS wc = {0};
|
2011-07-15 15:18:02 +00:00
|
|
|
wc.hInstance = g_Instance;
|
2011-05-24 18:20:35 +00:00
|
|
|
wc.lpfnWndProc = WndProc;
|
|
|
|
wc.lpszClassName = L"NowPlayingCADClass";
|
|
|
|
RegisterClass(&wc);
|
|
|
|
|
2011-06-25 12:44:33 +00:00
|
|
|
// Create reciever window
|
2011-05-24 18:20:35 +00:00
|
|
|
m_Window = CreateWindow(L"NowPlayingCADClass",
|
|
|
|
L"CD Art Display 1.x Class",
|
|
|
|
WS_DISABLED,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2011-07-15 15:18:02 +00:00
|
|
|
g_Instance,
|
2011-05-24 18:20:35 +00:00
|
|
|
this);
|
|
|
|
|
2011-06-25 12:44:33 +00:00
|
|
|
// Add WM_USER/WM_COPYDATA to allowed messages from lower level processes
|
|
|
|
HMODULE hUser32 = LoadLibrary(L"user32.dll");
|
|
|
|
if (hUser32)
|
|
|
|
{
|
|
|
|
// Try ChangeWindowMessageFilterEx first (Win7+)
|
|
|
|
FPCHANGEWINDOWMESSAGEFILTEREX ChangeWindowMessageFilterEx = (FPCHANGEWINDOWMESSAGEFILTEREX)GetProcAddress(hUser32, "ChangeWindowMessageFilterEx");
|
|
|
|
if (ChangeWindowMessageFilterEx)
|
|
|
|
{
|
|
|
|
ChangeWindowMessageFilterEx(m_Window, WM_USER, MSGFLT_ALLOW, NULL);
|
|
|
|
ChangeWindowMessageFilterEx(m_Window, WM_COPYDATA, MSGFLT_ALLOW, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Try ChangeWindowMessageFilter (Vista)
|
|
|
|
FPCHANGEWINDOWMESSAGEFILTER ChangeWindowMessageFilter = (FPCHANGEWINDOWMESSAGEFILTER)GetProcAddress(hUser32, "ChangeWindowMessageFilter");
|
|
|
|
if (ChangeWindowMessageFilter)
|
|
|
|
{
|
|
|
|
ChangeWindowMessageFilter(WM_USER, MSGFLT_ALLOW);
|
|
|
|
ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ALLOW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FreeLibrary(hUser32);
|
|
|
|
}
|
|
|
|
|
2011-06-12 10:05:37 +00:00
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
LPCTSTR file = g_SettingsFile.c_str();
|
|
|
|
|
|
|
|
// Read saved settings
|
|
|
|
GetPrivateProfileString(L"NowPlaying.dll", L"ClassName", NULL, buffer, MAX_PATH, file);
|
|
|
|
std::wstring className = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(L"NowPlaying.dll", L"WindowName", NULL, buffer, MAX_PATH, file);
|
|
|
|
std::wstring windowName = buffer;
|
|
|
|
|
|
|
|
GetPrivateProfileString(L"NowPlaying.dll", L"PlayerPath", NULL, buffer, MAX_PATH, file);
|
|
|
|
m_PlayerPath = buffer;
|
|
|
|
|
|
|
|
LPCTSTR classSz = className.empty() ? NULL : className.c_str();
|
|
|
|
LPCTSTR windowSz = windowName.empty() ? NULL : windowName.c_str();
|
|
|
|
|
|
|
|
if (classSz || windowSz)
|
|
|
|
{
|
|
|
|
m_PlayerWindow = FindWindow(classSz, windowSz);
|
|
|
|
}
|
|
|
|
else
|
2011-05-24 18:20:35 +00:00
|
|
|
{
|
2011-08-21 13:24:24 +00:00
|
|
|
classSz = L"CD Art Display IPC Class";
|
|
|
|
m_PlayerWindow = FindWindow(classSz, NULL);
|
2011-06-12 10:05:37 +00:00
|
|
|
if (m_PlayerWindow)
|
2011-05-24 18:20:35 +00:00
|
|
|
{
|
2011-07-01 20:34:12 +00:00
|
|
|
WritePrivateProfileString(L"NowPlaying.dll", L"ClassName", classSz, file);
|
|
|
|
|
|
|
|
windowSz = (GetWindowText(m_PlayerWindow, buffer, MAX_PATH) > 0) ? buffer : NULL;
|
|
|
|
WritePrivateProfileString(L"NowPlaying.dll", L"WindowName", windowSz, file);
|
|
|
|
|
|
|
|
DWORD pID;
|
|
|
|
GetWindowThreadProcessId(m_PlayerWindow, &pID);
|
|
|
|
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pID);
|
|
|
|
if (hProcess)
|
|
|
|
{
|
|
|
|
if (GetModuleFileNameEx(hProcess, NULL, buffer, MAX_PATH) > 0)
|
|
|
|
{
|
|
|
|
WritePrivateProfileString(L"NowPlaying.dll", L"PlayerPath", buffer, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(hProcess);
|
|
|
|
}
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
2011-06-12 10:05:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_PlayerWindow)
|
|
|
|
{
|
2011-06-19 14:58:48 +00:00
|
|
|
m_Initialized = true;
|
2011-08-21 13:24:24 +00:00
|
|
|
|
|
|
|
if (classSz && wcscmp(classSz, L"CD Art Display IPC Class") == 0)
|
|
|
|
{
|
|
|
|
m_ExtendedAPI = true;
|
|
|
|
}
|
|
|
|
|
2011-06-12 10:05:37 +00:00
|
|
|
SendMessage(m_PlayerWindow, WM_USER, (WPARAM)m_Window, IPC_SET_CALLBACK_HWND);
|
2012-01-08 17:35:29 +00:00
|
|
|
m_State = (StateType)SendMessage(m_PlayerWindow, WM_USER, 0, IPC_GET_STATE);
|
2011-06-12 10:05:37 +00:00
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
if (m_State != STATE_STOPPED)
|
2011-05-24 18:20:35 +00:00
|
|
|
{
|
2011-06-12 10:05:37 +00:00
|
|
|
SendMessage(m_PlayerWindow, WM_USER, 0, IPC_GET_CURRENT_TRACK);
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Destroy reciever window.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::Uninitialize()
|
|
|
|
{
|
|
|
|
DestroyWindow(m_Window);
|
2011-07-15 15:18:02 +00:00
|
|
|
UnregisterClass(L"NowPlayingCADClass", g_Instance);
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Window procedure for the reciever window.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
LRESULT CALLBACK CPlayerCAD::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2011-06-19 14:58:48 +00:00
|
|
|
static CPlayerCAD* player;
|
2011-05-24 18:20:35 +00:00
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
2011-07-01 20:34:12 +00:00
|
|
|
{
|
|
|
|
// Get pointer to the CPlayerCAD class from the CreateWindow call
|
|
|
|
player = (CPlayerCAD*)((CREATESTRUCT*)lParam)->lpCreateParams;
|
|
|
|
return 0;
|
|
|
|
}
|
2011-05-24 18:20:35 +00:00
|
|
|
|
|
|
|
case WM_DESTROY:
|
2011-07-01 20:34:12 +00:00
|
|
|
{
|
|
|
|
SendMessage(player->m_PlayerWindow, WM_USER, 0, IPC_SHUTDOWN_NOTIFICATION);
|
|
|
|
return 0;
|
|
|
|
}
|
2011-05-24 18:20:35 +00:00
|
|
|
|
|
|
|
case WM_USER:
|
|
|
|
switch (lParam)
|
|
|
|
{
|
|
|
|
case IPC_TRACK_CHANGED_NOTIFICATION:
|
2011-07-01 20:34:12 +00:00
|
|
|
{
|
|
|
|
PostMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_CURRENT_TRACK);
|
|
|
|
break;
|
|
|
|
}
|
2011-05-24 18:20:35 +00:00
|
|
|
|
2011-07-01 20:34:12 +00:00
|
|
|
case IPC_STATE_CHANGED_NOTIFICATION:
|
2011-05-24 18:20:35 +00:00
|
|
|
{
|
2012-01-08 17:35:29 +00:00
|
|
|
player->m_State = (StateType)wParam;
|
|
|
|
if (player->m_State == STATE_STOPPED)
|
2011-07-01 20:34:12 +00:00
|
|
|
{
|
|
|
|
player->ClearData();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case IPC_VOLUME_CHANGED_NOTIFICATION:
|
|
|
|
{
|
|
|
|
player->m_Volume = wParam;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-11 08:22:07 +00:00
|
|
|
case IPC_REPEAT_CHANGED_NOTIFICATION:
|
|
|
|
{
|
|
|
|
player->m_Repeat = (bool)wParam;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case IPC_SHUFFLE_CHANGED_NOTIFICATION:
|
|
|
|
{
|
|
|
|
player->m_Shuffle = (bool)wParam;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-07-01 20:34:12 +00:00
|
|
|
case IPC_RATING_CHANGED_NOTIFICATION:
|
|
|
|
{
|
|
|
|
player->m_Rating = (wParam + 1) / 2; // From 0 - 10 to 0 - 5
|
|
|
|
break;
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case IPC_SHUTDOWN_NOTIFICATION:
|
2011-07-01 20:34:12 +00:00
|
|
|
{
|
|
|
|
player->m_Initialized = false;
|
|
|
|
player->ClearData();
|
|
|
|
break;
|
|
|
|
}
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_COPYDATA:
|
|
|
|
{
|
|
|
|
PCOPYDATASTRUCT cds = (PCOPYDATASTRUCT)lParam;
|
2011-07-01 20:34:12 +00:00
|
|
|
if (cds->dwData == IPC_CURRENT_TRACK_NOTIFICATION)
|
2011-05-24 18:20:35 +00:00
|
|
|
{
|
2011-09-11 12:14:52 +00:00
|
|
|
player->m_Shuffle = (bool)SendMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_SHUFFLE);
|
|
|
|
player->m_Repeat = (bool)SendMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_REPEAT);
|
|
|
|
|
2011-06-17 19:07:06 +00:00
|
|
|
// TODO: Sent on track update?
|
2011-06-19 14:58:48 +00:00
|
|
|
++player->m_TrackCount;
|
2011-06-17 19:07:06 +00:00
|
|
|
|
2011-05-24 18:20:35 +00:00
|
|
|
std::wstring data = (WCHAR*)cds->lpData;
|
|
|
|
std::wstring::size_type len = data.find_first_of(L'\t');
|
2011-06-19 14:58:48 +00:00
|
|
|
player->m_Title.assign(data, 0, len);
|
2011-05-24 18:20:35 +00:00
|
|
|
data.erase(0, ++len);
|
|
|
|
|
|
|
|
len = data.find_first_of(L'\t');
|
2011-06-19 14:58:48 +00:00
|
|
|
player->m_Artist.assign(data, 0, len);
|
2011-05-24 18:20:35 +00:00
|
|
|
data.erase(0, ++len);
|
|
|
|
|
|
|
|
len = data.find_first_of(L'\t');
|
2011-06-19 14:58:48 +00:00
|
|
|
player->m_Album.assign(data, 0, len);
|
2011-05-24 18:20:35 +00:00
|
|
|
data.erase(0, ++len);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
len = data.find_first_of(L'\t');
|
2011-07-14 10:12:02 +00:00
|
|
|
std::wstring tmpStr(data, 0, len);
|
|
|
|
player->m_Duration = _wtoi(tmpStr.c_str());
|
2011-05-24 18:20:35 +00:00
|
|
|
data.erase(0, ++len);
|
|
|
|
|
|
|
|
len = data.find_first_of(L'\t');
|
2011-06-19 14:58:48 +00:00
|
|
|
player->m_FilePath.assign(data, 0, len);
|
2011-05-24 18:20:35 +00:00
|
|
|
data.erase(0, ++len);
|
|
|
|
|
|
|
|
len = data.find_first_of(L'\t');
|
2011-07-14 10:12:02 +00:00
|
|
|
tmpStr.assign(data, 0, len);
|
|
|
|
UINT rating = (_wtoi(tmpStr.c_str()) + 1) / 2; // From 0 - 10 to 0 - 5
|
2011-06-19 14:58:48 +00:00
|
|
|
player->m_Rating = rating;
|
2011-05-24 18:20:35 +00:00
|
|
|
data.erase(0, ++len);
|
|
|
|
|
|
|
|
len = data.find_first_of(L'\t');
|
2011-06-19 14:58:48 +00:00
|
|
|
player->m_CoverPath.assign(data, 0, len);
|
2011-05-24 18:20:35 +00:00
|
|
|
data.erase(0, ++len);
|
2011-06-19 14:58:48 +00:00
|
|
|
|
2011-09-08 12:42:03 +00:00
|
|
|
if (player->m_Measures & MEASURE_LYRICS)
|
2011-06-19 14:58:48 +00:00
|
|
|
{
|
|
|
|
player->FindLyrics();
|
|
|
|
}
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
2011-07-01 20:34:12 +00:00
|
|
|
else if (cds->dwData == IPC_REGISTER_NOTIFICATION && !player->m_Initialized)
|
2011-05-24 18:20:35 +00:00
|
|
|
{
|
|
|
|
std::wstring data = (WCHAR*)cds->lpData;
|
|
|
|
if (data[0] == L'1')
|
|
|
|
{
|
|
|
|
data.erase(0, 2); // Get rid of the 1\t at the beginning
|
|
|
|
|
|
|
|
std::wstring::size_type len = data.find_first_of(L'\t');
|
2011-07-14 10:12:02 +00:00
|
|
|
std::wstring className(data, 0, len);
|
2011-05-24 18:20:35 +00:00
|
|
|
data.erase(0, ++len);
|
|
|
|
|
|
|
|
len = data.find_first_of(L'\t');
|
2011-07-14 10:12:02 +00:00
|
|
|
std::wstring windowName(data, 0, len);
|
2011-05-24 18:20:35 +00:00
|
|
|
data.erase(0, ++len);
|
|
|
|
|
|
|
|
len = data.find_first_of(L'\t');
|
2011-06-19 14:58:48 +00:00
|
|
|
player->m_PlayerPath.assign(data, 0, len);
|
2011-05-24 18:20:35 +00:00
|
|
|
data.erase(0, ++len);
|
|
|
|
|
2011-06-12 10:05:37 +00:00
|
|
|
LPCTSTR classSz = className.empty() ? NULL : className.c_str();
|
|
|
|
LPCTSTR windowSz = windowName.empty() ? NULL : windowName.c_str();
|
|
|
|
LPCTSTR file = g_SettingsFile.c_str();
|
|
|
|
|
|
|
|
WritePrivateProfileString(L"NowPlaying.dll", L"ClassName", classSz, file);
|
|
|
|
WritePrivateProfileString(L"NowPlaying.dll", L"WindowName", windowSz, file);
|
2011-06-19 14:58:48 +00:00
|
|
|
WritePrivateProfileString(L"NowPlaying.dll", L"PlayerPath", player->m_PlayerPath.c_str(), file);
|
2011-06-12 10:05:37 +00:00
|
|
|
|
2011-06-19 14:58:48 +00:00
|
|
|
player->m_PlayerWindow = FindWindow(classSz, windowSz);
|
2011-06-12 10:05:37 +00:00
|
|
|
|
2011-06-19 14:58:48 +00:00
|
|
|
if (player->m_PlayerWindow)
|
2011-06-12 10:05:37 +00:00
|
|
|
{
|
2011-06-19 14:58:48 +00:00
|
|
|
player->m_Initialized = true;
|
2011-08-21 13:24:24 +00:00
|
|
|
player->m_ExtendedAPI = (classSz && wcscmp(classSz, L"CD Art Display IPC Class") == 0);
|
2012-01-08 17:35:29 +00:00
|
|
|
player->m_State = (StateType)SendMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_STATE);
|
2011-06-12 10:05:37 +00:00
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
if (player->m_State != STATE_STOPPED)
|
2011-06-12 10:05:37 +00:00
|
|
|
{
|
2011-06-25 12:44:33 +00:00
|
|
|
PostMessage(player->m_PlayerWindow, WM_USER, 0, IPC_GET_CURRENT_TRACK);
|
2011-06-12 10:05:37 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Called during each update of the main measure.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::UpdateData()
|
|
|
|
{
|
2012-01-08 17:35:29 +00:00
|
|
|
if (m_State != STATE_STOPPED)
|
2011-05-24 18:20:35 +00:00
|
|
|
{
|
|
|
|
m_Position = SendMessage(m_PlayerWindow, WM_USER, 0, IPC_GET_POSITION);
|
|
|
|
m_Volume = SendMessage(m_PlayerWindow, WM_USER, 0, IPC_GET_VOLUME);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-09 09:47:55 +00:00
|
|
|
/*
|
|
|
|
** Handles the Pause bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::Pause()
|
|
|
|
{
|
2011-07-10 09:30:51 +00:00
|
|
|
SendMessage(m_PlayerWindow, WM_USER, 0, m_ExtendedAPI ? IPC_PAUSE : IPC_PLAYPAUSE);
|
2011-06-09 09:47:55 +00:00
|
|
|
}
|
|
|
|
|
2011-05-24 18:20:35 +00:00
|
|
|
/*
|
|
|
|
** Handles the Play bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::Play()
|
|
|
|
{
|
2011-07-10 09:30:51 +00:00
|
|
|
SendMessage(m_PlayerWindow, WM_USER, 0, m_ExtendedAPI ? IPC_PLAY : IPC_PLAYPAUSE);
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Handles the Stop bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::Stop()
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
SendMessage(m_PlayerWindow, WM_USER, 0, IPC_STOP);
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Handles the Next bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::Next()
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
SendMessage(m_PlayerWindow, WM_USER, 0, IPC_NEXT);
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Handles the Previous bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::Previous()
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
SendMessage(m_PlayerWindow, WM_USER, 0, IPC_PREVIOUS);
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
|
|
|
|
2011-06-09 09:47:55 +00:00
|
|
|
/*
|
|
|
|
** Handles the SetPosition bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::SetPosition(int position)
|
|
|
|
{
|
|
|
|
SendMessage(m_PlayerWindow, WM_USER, position, IPC_SET_POSITION);
|
|
|
|
}
|
|
|
|
|
2011-05-24 18:20:35 +00:00
|
|
|
/*
|
|
|
|
** Handles the SetVolume bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::SetRating(int rating)
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
m_Rating = rating;
|
|
|
|
rating *= 2; // From 0 - 5 to 0 - 10
|
2011-07-01 20:34:12 +00:00
|
|
|
SendMessage(m_PlayerWindow, WM_USER, rating, IPC_SET_RATING);
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Handles the SetVolume bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::SetVolume(int volume)
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
SendMessage(m_PlayerWindow, WM_USER, volume, IPC_SET_VOLUME);
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
|
|
|
|
2011-09-11 08:22:07 +00:00
|
|
|
/*
|
|
|
|
** Handles the SetShuffle bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::SetShuffle(bool state)
|
|
|
|
{
|
2011-09-11 12:14:52 +00:00
|
|
|
SendMessage(m_PlayerWindow, WM_USER, (WPARAM)state, IPC_SET_SHUFFLE);
|
|
|
|
m_Shuffle = (bool)SendMessage(m_PlayerWindow, WM_USER, 0, IPC_GET_SHUFFLE);
|
2011-09-11 08:22:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Handles the SetRepeat bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::SetRepeat(bool state)
|
|
|
|
{
|
2011-09-11 12:14:52 +00:00
|
|
|
SendMessage(m_PlayerWindow, WM_USER, (WPARAM)state, IPC_SET_REPEAT);
|
|
|
|
m_Repeat = (bool)SendMessage(m_PlayerWindow, WM_USER, 0, IPC_GET_REPEAT);
|
2011-09-11 08:22:07 +00:00
|
|
|
}
|
|
|
|
|
2011-05-24 18:20:35 +00:00
|
|
|
/*
|
|
|
|
** Handles the ClosePlayer bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerCAD::ClosePlayer()
|
|
|
|
{
|
2011-07-01 20:34:12 +00:00
|
|
|
SendMessage(m_PlayerWindow, WM_USER, 0, IPC_CLOSE);
|
2011-06-19 14:58:48 +00:00
|
|
|
// TODO
|
|
|
|
m_Initialized = false;
|
2011-06-17 19:07:06 +00:00
|
|
|
ClearData();
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Handles the OpenPlayer bang.
|
|
|
|
**
|
|
|
|
*/
|
2011-06-17 19:07:06 +00:00
|
|
|
void CPlayerCAD::OpenPlayer(std::wstring& path)
|
2011-05-24 18:20:35 +00:00
|
|
|
{
|
2011-07-01 20:34:12 +00:00
|
|
|
if (!m_Initialized)
|
2011-06-17 19:07:06 +00:00
|
|
|
{
|
2011-07-01 20:34:12 +00:00
|
|
|
if (!path.empty())
|
|
|
|
{
|
|
|
|
ShellExecute(NULL, L"open", path.c_str(), NULL, NULL, SW_SHOW);
|
|
|
|
}
|
|
|
|
else if (!m_PlayerPath.empty())
|
|
|
|
{
|
|
|
|
ShellExecute(NULL, L"open", m_PlayerPath.c_str(), NULL, NULL, SW_SHOW);
|
|
|
|
}
|
2011-06-17 19:07:06 +00:00
|
|
|
}
|
2011-07-01 20:34:12 +00:00
|
|
|
else
|
2011-06-12 10:05:37 +00:00
|
|
|
{
|
2011-07-01 20:34:12 +00:00
|
|
|
// Bring player to front
|
|
|
|
SendMessage(m_PlayerWindow, WM_USER, 0, IPC_SHOW_WINDOW);
|
2011-06-12 10:05:37 +00:00
|
|
|
}
|
2011-05-24 18:20:35 +00:00
|
|
|
}
|