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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PLAYER_H__
|
|
|
|
#define __PLAYER_H__
|
|
|
|
|
2011-06-19 14:58:48 +00:00
|
|
|
#include "fileref.h"
|
2011-05-21 18:17:37 +00:00
|
|
|
#include "tag.h"
|
2011-06-17 19:07:06 +00:00
|
|
|
#include "Cover.h"
|
2011-06-19 14:58:48 +00:00
|
|
|
#include "Internet.h"
|
|
|
|
#include "Lyrics.h"
|
2011-05-21 18:17:37 +00:00
|
|
|
|
2011-06-17 19:07:06 +00:00
|
|
|
enum PLAYSTATE
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
|
|
|
PLAYER_STOPPED,
|
|
|
|
PLAYER_PLAYING,
|
|
|
|
PLAYER_PAUSED
|
|
|
|
};
|
|
|
|
|
|
|
|
enum MEASURETYPE
|
|
|
|
{
|
|
|
|
MEASURE_ARTIST,
|
|
|
|
MEASURE_TITLE,
|
|
|
|
MEASURE_ALBUM,
|
2011-06-17 19:07:06 +00:00
|
|
|
MEASURE_LYRICS,
|
2011-05-21 18:17:37 +00:00
|
|
|
MEASURE_COVER,
|
2011-06-25 12:44:33 +00:00
|
|
|
MEASURE_FILE,
|
2011-05-21 18:17:37 +00:00
|
|
|
MEASURE_DURATION,
|
|
|
|
MEASURE_POSITION,
|
|
|
|
MEASURE_PROGRESS,
|
|
|
|
MEASURE_RATING,
|
2011-05-22 08:06:43 +00:00
|
|
|
MEASURE_VOLUME,
|
2011-06-25 12:44:33 +00:00
|
|
|
MEASURE_STATE,
|
|
|
|
MEASURE_STATUS
|
2011-05-21 18:17:37 +00:00
|
|
|
};
|
|
|
|
|
2011-06-19 14:58:48 +00:00
|
|
|
class CPlayer
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CPlayer();
|
2011-06-17 19:07:06 +00:00
|
|
|
virtual ~CPlayer() = 0;
|
|
|
|
|
|
|
|
void AddInstance();
|
|
|
|
void RemoveInstance();
|
|
|
|
void UpdateMeasure();
|
|
|
|
virtual void AddMeasure(MEASURETYPE measure);
|
|
|
|
virtual void UpdateData() = 0;
|
|
|
|
|
|
|
|
bool IsInitialized() { return m_Initialized; }
|
|
|
|
UINT GetTrackCount() { return m_TrackCount; }
|
2011-06-19 14:58:48 +00:00
|
|
|
|
|
|
|
std::wstring GetCacheFile();
|
|
|
|
void FindCover();
|
|
|
|
void FindLyrics();
|
2011-06-17 19:07:06 +00:00
|
|
|
|
2011-06-09 09:47:55 +00:00
|
|
|
virtual void Pause() {}
|
2011-05-21 18:17:37 +00:00
|
|
|
virtual void Play() {}
|
|
|
|
virtual void Stop() {}
|
|
|
|
virtual void Next() {}
|
|
|
|
virtual void Previous() {}
|
2011-06-09 09:47:55 +00:00
|
|
|
virtual void SetPosition(int position) {}
|
2011-05-21 18:17:37 +00:00
|
|
|
virtual void SetRating(int rating) {}
|
|
|
|
virtual void SetVolume(int volume) {}
|
2011-06-17 19:07:06 +00:00
|
|
|
virtual void OpenPlayer(std::wstring& path) {}
|
2011-05-21 18:17:37 +00:00
|
|
|
virtual void ClosePlayer() {}
|
|
|
|
|
2011-06-17 19:07:06 +00:00
|
|
|
PLAYSTATE GetState() { return m_State; }
|
2011-05-21 18:17:37 +00:00
|
|
|
LPCTSTR GetArtist() { return m_Artist.c_str(); }
|
|
|
|
LPCTSTR GetAlbum() { return m_Album.c_str(); }
|
|
|
|
LPCTSTR GetTitle() { return m_Title.c_str(); }
|
2011-06-17 19:07:06 +00:00
|
|
|
LPCTSTR GetLyrics() { return m_Lyrics.c_str(); }
|
2011-05-21 18:17:37 +00:00
|
|
|
LPCTSTR GetCoverPath() { return m_CoverPath.c_str(); }
|
2011-06-17 19:07:06 +00:00
|
|
|
LPCTSTR GetFilePath() { return m_FilePath.c_str(); }
|
2011-05-21 18:17:37 +00:00
|
|
|
UINT GetDuration() { return m_Duration; }
|
|
|
|
UINT GetPosition() { return m_Position; }
|
|
|
|
UINT GetRating() { return m_Rating; }
|
|
|
|
UINT GetVolume() { return m_Volume; }
|
|
|
|
|
|
|
|
protected:
|
2011-06-17 19:07:06 +00:00
|
|
|
void ClearData();
|
2011-05-21 18:17:37 +00:00
|
|
|
|
2011-06-17 19:07:06 +00:00
|
|
|
bool m_Initialized;
|
|
|
|
bool m_HasCoverMeasure;
|
|
|
|
bool m_HasLyricsMeasure;
|
|
|
|
UINT m_InstanceCount;
|
|
|
|
UINT m_UpdateCount;
|
|
|
|
UINT m_TrackCount;
|
|
|
|
|
|
|
|
PLAYSTATE m_State;
|
2011-05-21 18:17:37 +00:00
|
|
|
std::wstring m_Artist;
|
|
|
|
std::wstring m_Title;
|
2011-06-17 19:07:06 +00:00
|
|
|
std::wstring m_Album;
|
|
|
|
std::wstring m_Lyrics;
|
2011-05-21 18:17:37 +00:00
|
|
|
std::wstring m_CoverPath; // Path to cover art image
|
2011-06-17 19:07:06 +00:00
|
|
|
std::wstring m_FilePath; // Path to playing file
|
2011-05-21 18:17:37 +00:00
|
|
|
UINT m_Duration; // Track duration in seconds
|
|
|
|
UINT m_Position; // Current position in seconds
|
|
|
|
UINT m_Rating; // Track rating from 0 to 100
|
|
|
|
UINT m_Volume; // Volume from 0 to 100
|
2011-06-19 14:58:48 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static unsigned __stdcall LyricsThreadProc(void* pParam);
|
|
|
|
|
|
|
|
HANDLE m_InternetThread;
|
|
|
|
CRITICAL_SECTION m_CriticalSection;
|
2011-05-21 18:17:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|