2011-05-21 18:17:37 +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
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "PlayerWMP.h"
|
|
|
|
|
2011-06-19 14:58:48 +00:00
|
|
|
CPlayer* CPlayerWMP::c_Player = NULL;
|
2011-07-15 15:18:02 +00:00
|
|
|
extern HINSTANCE g_Instance;
|
2011-05-22 14:45:54 +00:00
|
|
|
|
2011-05-21 18:17:37 +00:00
|
|
|
/*
|
|
|
|
** CRemoteHost
|
|
|
|
**
|
|
|
|
** Constructor.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
CPlayerWMP::CRemoteHost::CRemoteHost() :
|
2011-05-31 13:15:53 +00:00
|
|
|
m_Player()
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** ~CRemoteHost
|
|
|
|
**
|
|
|
|
** Destructor.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
CPlayerWMP::CRemoteHost::~CRemoteHost()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT CPlayerWMP::CRemoteHost::QueryService(REFGUID guidService, REFIID riid, void** ppv)
|
|
|
|
{
|
|
|
|
return ppv ? QueryInterface(riid, ppv) : E_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT CPlayerWMP::CRemoteHost::GetServiceType(BSTR* pbstrType)
|
|
|
|
{
|
|
|
|
HRESULT hr = E_POINTER;
|
|
|
|
if (pbstrType)
|
|
|
|
{
|
2011-06-12 10:05:37 +00:00
|
|
|
*pbstrType = SysAllocString(L"RemoteNoDialogs");
|
2011-05-21 18:17:37 +00:00
|
|
|
hr = *pbstrType? S_OK : E_POINTER;
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT CPlayerWMP::CRemoteHost::GetApplicationName(BSTR* pbstrName)
|
|
|
|
{
|
|
|
|
HRESULT hr = E_POINTER;
|
|
|
|
if (pbstrName)
|
|
|
|
{
|
|
|
|
CComBSTR bstrAppName = L"Rainmeter NowPlaying";
|
|
|
|
*pbstrName = bstrAppName.Detach();
|
|
|
|
hr = *pbstrName? S_OK : E_POINTER;
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT CPlayerWMP::CRemoteHost::GetScriptableObject(BSTR* pbstrName, IDispatch** ppDispatch)
|
|
|
|
{
|
|
|
|
if (pbstrName)
|
|
|
|
{
|
|
|
|
*pbstrName = NULL;
|
|
|
|
}
|
|
|
|
if (ppDispatch)
|
|
|
|
{
|
|
|
|
*ppDispatch = NULL;
|
|
|
|
}
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT CPlayerWMP::CRemoteHost::GetCustomUIMode(BSTR* pbstrFile)
|
|
|
|
{
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** CurrentItemChange
|
|
|
|
**
|
|
|
|
** Called when playing track changes.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::CRemoteHost::CurrentItemChange(IDispatch* pdispMedia)
|
|
|
|
{
|
2011-05-31 13:15:53 +00:00
|
|
|
m_Player->m_TrackChanged = true;
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** PlayStateChange
|
|
|
|
**
|
|
|
|
** Called when play state changes.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::CRemoteHost::PlayStateChange(long NewState)
|
|
|
|
{
|
|
|
|
switch (NewState)
|
|
|
|
{
|
|
|
|
case wmppsStopped:
|
|
|
|
case wmppsMediaEnded:
|
2011-06-17 19:07:06 +00:00
|
|
|
m_Player->ClearData();
|
2011-05-21 18:17:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wmppsPaused:
|
2012-01-08 17:35:29 +00:00
|
|
|
m_Player->m_State = STATE_PAUSED;
|
2011-05-21 18:17:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wmppsPlaying:
|
2012-01-08 17:35:29 +00:00
|
|
|
if (m_Player->m_State == STATE_STOPPED)
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
2011-05-31 13:15:53 +00:00
|
|
|
m_Player->m_TrackChanged = true;
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
2012-01-08 17:35:29 +00:00
|
|
|
m_Player->m_State = STATE_PLAYING;
|
2011-05-21 18:17:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** SwitchedToControl
|
|
|
|
**
|
|
|
|
** Called when WMP quits.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::CRemoteHost::SwitchedToControl()
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
m_Player->ClearData();
|
2011-05-31 13:15:53 +00:00
|
|
|
m_Player->Uninitialize();
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** CPlayerWMP
|
|
|
|
**
|
|
|
|
** Constructor.
|
|
|
|
**
|
|
|
|
*/
|
2011-05-22 08:06:43 +00:00
|
|
|
CPlayerWMP::CPlayerWMP() : CPlayer(),
|
2011-06-17 19:07:06 +00:00
|
|
|
m_TrackChanged(false),
|
|
|
|
m_Window(),
|
2011-10-12 13:34:04 +00:00
|
|
|
m_LastCheckTime(0),
|
2011-05-21 18:17:37 +00:00
|
|
|
m_ComModule(),
|
|
|
|
m_AxWindow(),
|
|
|
|
m_IPlayer(),
|
|
|
|
m_IControls(),
|
|
|
|
m_ISettings(),
|
|
|
|
m_IConnectionPoint()
|
|
|
|
{
|
|
|
|
m_ComModule.Init(NULL, NULL, &LIBID_ATLLib);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** ~CPlayerWMP
|
|
|
|
**
|
|
|
|
** Destructor.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
CPlayerWMP::~CPlayerWMP()
|
|
|
|
{
|
2011-06-19 14:58:48 +00:00
|
|
|
c_Player = NULL;
|
2011-05-21 18:17:37 +00:00
|
|
|
Uninitialize();
|
|
|
|
m_ComModule.Term();
|
|
|
|
}
|
|
|
|
|
2011-06-19 14:58:48 +00:00
|
|
|
/*
|
|
|
|
** Create
|
|
|
|
**
|
|
|
|
** Creates a shared class object.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
CPlayer* CPlayerWMP::Create()
|
|
|
|
{
|
|
|
|
if (!c_Player)
|
|
|
|
{
|
|
|
|
c_Player = new CPlayerWMP();
|
|
|
|
}
|
|
|
|
|
|
|
|
return c_Player;
|
|
|
|
}
|
|
|
|
|
2011-05-21 18:17:37 +00:00
|
|
|
/*
|
|
|
|
** Initialize
|
|
|
|
**
|
|
|
|
** Set up the COM interface with WMP.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::Initialize()
|
|
|
|
{
|
|
|
|
// Create windows class
|
|
|
|
WNDCLASS wc = {0};
|
2011-07-15 15:18:02 +00:00
|
|
|
wc.hInstance = g_Instance;
|
2011-05-21 18:17:37 +00:00
|
|
|
wc.lpfnWndProc = DefWindowProc;
|
|
|
|
wc.lpszClassName = L"NowPlayingWMPClass";
|
|
|
|
RegisterClass(&wc);
|
|
|
|
|
2011-06-12 10:05:37 +00:00
|
|
|
// Create the host window
|
2011-05-21 18:17:37 +00:00
|
|
|
m_Window = CreateWindow(L"NowPlayingWMPClass",
|
2011-06-12 10:05:37 +00:00
|
|
|
L"HostWindow",
|
2011-05-21 18:17:37 +00:00
|
|
|
WS_DISABLED,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2011-07-15 15:18:02 +00:00
|
|
|
g_Instance,
|
2011-05-21 18:17:37 +00:00
|
|
|
NULL);
|
|
|
|
|
2011-10-12 13:34:04 +00:00
|
|
|
if (!m_Window) return;
|
2011-05-21 18:17:37 +00:00
|
|
|
|
|
|
|
CComPtr<IObjectWithSite> spHostObject;
|
|
|
|
CComPtr<IAxWinHostWindow> spHost;
|
|
|
|
CComObject<CRemoteHost>* pRemoteHost;
|
2011-06-25 12:44:33 +00:00
|
|
|
|
2011-05-21 18:17:37 +00:00
|
|
|
m_AxWindow = new CAxWindow();
|
|
|
|
HRESULT hr = m_AxWindow ? S_OK : E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
m_AxWindow->Create(m_Window, NULL, NULL, WS_CHILD | WS_DISABLED);
|
|
|
|
if(IsWindow(m_AxWindow->m_hWnd))
|
|
|
|
{
|
2011-06-12 10:05:37 +00:00
|
|
|
hr = m_AxWindow->QueryHost(IID_IObjectWithSite, (void**)&spHostObject);
|
2011-05-21 18:17:37 +00:00
|
|
|
if(!spHostObject.p)
|
|
|
|
{
|
|
|
|
hr = E_POINTER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create remote host which implements IServiceProvider and IWMPRemoteMediaServices
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = CComObject<CRemoteHost>::CreateInstance(&pRemoteHost);
|
|
|
|
if (pRemoteHost)
|
|
|
|
{
|
|
|
|
pRemoteHost->AddRef();
|
2011-05-31 13:15:53 +00:00
|
|
|
pRemoteHost->m_Player = this;
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = E_POINTER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set site to the remote host
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = spHostObject->SetSite((IWMPRemoteMediaServices*)pRemoteHost);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = m_AxWindow->QueryHost(&spHost);
|
|
|
|
if (!spHost)
|
|
|
|
{
|
|
|
|
hr = E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create WMP control
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = spHost->CreateControl(CComBSTR(L"{6BF52A52-394A-11D3-B153-00C04F79FAA6}"), m_AxWindow->m_hWnd, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = m_AxWindow->QueryControl(&m_IPlayer);
|
|
|
|
if (!m_IPlayer.p)
|
|
|
|
{
|
|
|
|
hr = E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Connect the event interface
|
|
|
|
CComPtr<IConnectionPointContainer> spConnectionContainer;
|
|
|
|
hr = m_IPlayer->QueryInterface(&spConnectionContainer);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = spConnectionContainer->FindConnectionPoint( __uuidof(IWMPEvents), &m_IConnectionPoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
DWORD adviseCookie;
|
|
|
|
hr = m_IConnectionPoint->Advise(pRemoteHost->GetUnknown(), &adviseCookie);
|
|
|
|
|
|
|
|
if ((FAILED(hr)) || !adviseCookie)
|
|
|
|
{
|
|
|
|
m_IConnectionPoint = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Release remote host object
|
|
|
|
if (pRemoteHost)
|
|
|
|
{
|
|
|
|
pRemoteHost->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = m_IPlayer->get_controls(&m_IControls);
|
|
|
|
if (FAILED(hr)) return;
|
|
|
|
|
|
|
|
hr = m_IPlayer->get_settings(&m_ISettings);
|
|
|
|
if (FAILED(hr)) return;
|
|
|
|
|
|
|
|
// Get player state
|
|
|
|
WMPPlayState state;
|
|
|
|
m_IPlayer->get_playState(&state);
|
|
|
|
if (state == wmppsPlaying)
|
|
|
|
{
|
2012-01-08 17:35:29 +00:00
|
|
|
m_State = STATE_PLAYING;
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
else if (state == wmppsPaused)
|
|
|
|
{
|
2012-01-08 17:35:29 +00:00
|
|
|
m_State = STATE_PAUSED;
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
if (m_State != STATE_STOPPED)
|
2011-06-12 10:05:37 +00:00
|
|
|
{
|
|
|
|
m_TrackChanged = true;
|
|
|
|
}
|
|
|
|
|
2011-05-21 18:17:37 +00:00
|
|
|
m_Initialized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Uninitialize
|
|
|
|
**
|
|
|
|
** Close the interface with WMP.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::Uninitialize()
|
|
|
|
{
|
|
|
|
if (m_Initialized)
|
|
|
|
{
|
|
|
|
m_Initialized = false;
|
|
|
|
m_IControls.Release();
|
|
|
|
m_ISettings.Release();
|
|
|
|
m_IPlayer.Release();
|
|
|
|
m_AxWindow->DestroyWindow();
|
|
|
|
delete m_AxWindow;
|
|
|
|
DestroyWindow(m_Window);
|
2011-07-15 15:18:02 +00:00
|
|
|
UnregisterClass(L"NowPlayingWMPClass", g_Instance);
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** UpdateData
|
|
|
|
**
|
|
|
|
** Called during each update of the main measure.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::UpdateData()
|
|
|
|
{
|
|
|
|
if (m_Initialized)
|
|
|
|
{
|
|
|
|
// Get the volume
|
|
|
|
long volume;
|
|
|
|
m_ISettings->get_volume(&volume);
|
|
|
|
m_Volume = (UINT)volume;
|
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
if (m_State != STATE_STOPPED)
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
|
|
|
double position;
|
|
|
|
m_IControls->get_currentPosition(&position);
|
|
|
|
m_Position = (UINT)position;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_TrackChanged)
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
++m_TrackCount;
|
2011-05-21 18:17:37 +00:00
|
|
|
m_TrackChanged = false;
|
2011-06-17 19:07:06 +00:00
|
|
|
|
2011-05-21 18:17:37 +00:00
|
|
|
CComPtr<IWMPMedia> spMedia;
|
|
|
|
m_IPlayer->get_currentMedia(&spMedia);
|
|
|
|
|
|
|
|
if (spMedia)
|
|
|
|
{
|
|
|
|
CComBSTR val;
|
|
|
|
spMedia->getItemInfo(CComBSTR("Artist"), &val);
|
|
|
|
m_Artist = val;
|
|
|
|
|
|
|
|
spMedia->getItemInfo(CComBSTR("Title"), &val);
|
|
|
|
m_Title = val;
|
|
|
|
|
|
|
|
spMedia->getItemInfo(CComBSTR("Album"), &val);
|
|
|
|
m_Album = val;
|
|
|
|
|
|
|
|
spMedia->getItemInfo(CComBSTR("UserRating"), &val);
|
|
|
|
int rating = _wtoi(val);
|
|
|
|
|
|
|
|
if (rating > 75)
|
|
|
|
{
|
|
|
|
m_Rating = 5;
|
|
|
|
}
|
|
|
|
else if (rating > 50)
|
|
|
|
{
|
|
|
|
m_Rating = 4;
|
|
|
|
}
|
|
|
|
else if (rating > 25)
|
|
|
|
{
|
|
|
|
m_Rating = 3;
|
|
|
|
}
|
|
|
|
else if (rating > 1)
|
|
|
|
{
|
|
|
|
m_Rating = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Rating = rating;
|
|
|
|
}
|
|
|
|
|
|
|
|
double duration;
|
|
|
|
spMedia->get_duration(&duration);
|
|
|
|
m_Duration = (UINT)duration;
|
|
|
|
|
2011-05-22 08:06:43 +00:00
|
|
|
CComBSTR url;
|
|
|
|
spMedia->get_sourceURL(&url);
|
|
|
|
std::wstring targetPath = url;
|
2011-05-21 18:17:37 +00:00
|
|
|
|
2011-05-22 08:06:43 +00:00
|
|
|
if (targetPath != m_FilePath)
|
|
|
|
{
|
|
|
|
m_FilePath = targetPath;
|
2011-05-21 18:17:37 +00:00
|
|
|
|
2011-06-17 19:07:06 +00:00
|
|
|
// Find cover if needed
|
|
|
|
// TODO: Fix temp solution
|
2011-09-08 12:42:03 +00:00
|
|
|
if (m_Measures & MEASURE_COVER || m_InstanceCount == 0)
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
2011-05-22 08:06:43 +00:00
|
|
|
spMedia->getItemInfo(CComBSTR("WM/WMCollectionID"), &val);
|
|
|
|
targetPath.resize(targetPath.find_last_of(L'\\') + 1);
|
|
|
|
targetPath += L"AlbumArt_";
|
|
|
|
targetPath += val;
|
|
|
|
targetPath += L"_Large.jpg";
|
2011-05-21 18:17:37 +00:00
|
|
|
|
2011-05-22 08:06:43 +00:00
|
|
|
if (_waccess(targetPath.c_str(), 0) == 0)
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
2011-05-22 08:06:43 +00:00
|
|
|
m_CoverPath = targetPath;
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
2011-05-22 08:06:43 +00:00
|
|
|
else
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
2011-06-19 14:58:48 +00:00
|
|
|
FindCover();
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
}
|
2011-06-19 14:58:48 +00:00
|
|
|
|
2011-09-08 12:42:03 +00:00
|
|
|
if (m_Measures & MEASURE_LYRICS)
|
2011-06-19 14:58:48 +00:00
|
|
|
{
|
|
|
|
FindLyrics();
|
|
|
|
}
|
2011-05-22 08:06:43 +00:00
|
|
|
}
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD time = GetTickCount();
|
|
|
|
|
|
|
|
// Try to find WMP window every 5 seconds
|
2011-10-12 13:34:04 +00:00
|
|
|
if (m_LastCheckTime = 0 || time - m_LastCheckTime > 5000)
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
2011-10-12 13:34:04 +00:00
|
|
|
m_LastCheckTime = time;
|
2011-05-21 18:17:37 +00:00
|
|
|
|
|
|
|
if (FindWindow(L"WMPlayerApp", NULL))
|
|
|
|
{
|
|
|
|
Initialize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-09 09:47:55 +00:00
|
|
|
/*
|
|
|
|
** Pause
|
|
|
|
**
|
|
|
|
** Handles the Pause bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::Pause()
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
m_IControls->pause();
|
2011-06-09 09:47:55 +00:00
|
|
|
}
|
|
|
|
|
2011-05-21 18:17:37 +00:00
|
|
|
/*
|
|
|
|
** Play
|
|
|
|
**
|
|
|
|
** Handles the Play bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::Play()
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
m_IControls->play();
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Stop
|
|
|
|
**
|
|
|
|
** Handles the Stop bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::Stop()
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
m_IControls->stop();
|
|
|
|
// TODO: FIXME
|
2012-01-08 17:35:29 +00:00
|
|
|
m_State = STATE_STOPPED;
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Next
|
|
|
|
**
|
|
|
|
** Handles the Next bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::Next()
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
m_IControls->next();
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Previous
|
|
|
|
**
|
|
|
|
** Handles the Previous bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::Previous()
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
m_IControls->previous();
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
|
2011-06-09 09:47:55 +00:00
|
|
|
/*
|
|
|
|
** SetPosition
|
|
|
|
**
|
|
|
|
** Handles the SetPosition bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::SetPosition(int position)
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
m_IControls->put_currentPosition((double)position);
|
2011-06-09 09:47:55 +00:00
|
|
|
}
|
|
|
|
|
2011-05-21 18:17:37 +00:00
|
|
|
/*
|
|
|
|
** SetRating
|
|
|
|
**
|
|
|
|
** Handles the SetRating bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::SetRating(int rating)
|
|
|
|
{
|
2012-01-08 17:35:29 +00:00
|
|
|
if (m_State != STATE_STOPPED)
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
|
|
|
CComPtr<IWMPMedia> spMedia;
|
|
|
|
m_IPlayer->get_currentMedia(&spMedia);
|
|
|
|
|
|
|
|
if (spMedia)
|
|
|
|
{
|
|
|
|
CComBSTR val;
|
2011-09-11 08:22:07 +00:00
|
|
|
switch (rating)
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
2011-09-11 08:22:07 +00:00
|
|
|
case 0:
|
2011-05-21 18:17:37 +00:00
|
|
|
val = L"0";
|
2011-09-11 08:22:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2011-05-21 18:17:37 +00:00
|
|
|
val = L"1";
|
2011-09-11 08:22:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2011-05-21 18:17:37 +00:00
|
|
|
val = L"25";
|
2011-09-11 08:22:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2011-05-21 18:17:37 +00:00
|
|
|
val = L"50";
|
2011-09-11 08:22:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2011-05-21 18:17:37 +00:00
|
|
|
val = L"75";
|
2011-09-11 08:22:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
2011-05-21 18:17:37 +00:00
|
|
|
val = L"99";
|
2011-09-11 08:22:07 +00:00
|
|
|
break;
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
spMedia->setItemInfo(CComBSTR("UserRating"), val);
|
|
|
|
m_Rating = rating;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** SetVolume
|
|
|
|
**
|
|
|
|
** Handles the SetVolume bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::SetVolume(int volume)
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
m_ISettings->put_volume(volume);
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** ClosePlayer
|
|
|
|
**
|
|
|
|
** Handles the ClosePlayer bang.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
void CPlayerWMP::ClosePlayer()
|
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
HWND wnd = FindWindow(L"WMPlayerApp", NULL);
|
2011-05-21 18:17:37 +00:00
|
|
|
|
2011-06-17 19:07:06 +00:00
|
|
|
if (wnd)
|
|
|
|
{
|
|
|
|
SendMessage(wnd, WM_CLOSE, 0, 0);
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** OpenPlayer
|
|
|
|
**
|
|
|
|
** Handles the OpenPlayer bang.
|
|
|
|
**
|
|
|
|
*/
|
2011-06-17 19:07:06 +00:00
|
|
|
void CPlayerWMP::OpenPlayer(std::wstring& path)
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
2011-06-17 19:07:06 +00:00
|
|
|
ShellExecute(NULL, L"open", path.empty() ? L"wmplayer.exe" : path.c_str(), NULL, NULL, SW_SHOW);
|
2011-05-21 18:17:37 +00:00
|
|
|
}
|