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
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2011-05-21 18:17:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
enum StateType
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
2012-01-08 17:35:29 +00:00
|
|
|
STATE_STOPPED,
|
|
|
|
STATE_PLAYING,
|
|
|
|
STATE_PAUSED
|
2011-05-21 18:17:37 +00:00
|
|
|
};
|
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
enum MeasureType
|
2011-05-21 18:17:37 +00:00
|
|
|
{
|
2011-11-05 17:52:53 +00:00
|
|
|
MEASURE_NONE = 0x00000000,
|
2011-09-08 12:42:03 +00:00
|
|
|
MEASURE_ARTIST = 0x00000001,
|
|
|
|
MEASURE_TITLE = 0x00000002,
|
|
|
|
MEASURE_ALBUM = 0x00000004,
|
|
|
|
MEASURE_LYRICS = 0x00000008,
|
|
|
|
MEASURE_COVER = 0x00000010,
|
|
|
|
MEASURE_FILE = 0x00000020,
|
|
|
|
MEASURE_DURATION = 0x00000040,
|
|
|
|
MEASURE_POSITION = 0x00000080,
|
|
|
|
MEASURE_PROGRESS = 0x00000100,
|
|
|
|
MEASURE_RATING = 0x00000200,
|
|
|
|
MEASURE_VOLUME = 0x00000400,
|
|
|
|
MEASURE_STATE = 0x00000800,
|
2011-09-11 08:22:07 +00:00
|
|
|
MEASURE_STATUS = 0x00001000,
|
|
|
|
MEASURE_SHUFFLE = 0x00002000,
|
2012-03-12 12:01:12 +00:00
|
|
|
MEASURE_REPEAT = 0x00004000,
|
|
|
|
MEASURE_NUMBER = 0x00008000,
|
|
|
|
MEASURE_YEAR = 0x00010000
|
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();
|
2011-09-17 09:38:12 +00:00
|
|
|
void AddMeasure(INT type);
|
2011-06-17 19:07:06 +00:00
|
|
|
virtual void UpdateData() = 0;
|
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
bool IsInitialized() const { return m_Initialized; }
|
|
|
|
UINT GetTrackCount() const { return m_TrackCount; }
|
2011-11-05 17:52:53 +00:00
|
|
|
|
2011-06-19 14:58:48 +00:00
|
|
|
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-09-11 08:22:07 +00:00
|
|
|
virtual void SetPosition(int position) {} // position: position in seconds
|
|
|
|
virtual void SetRating(int rating) {} // rating: 0 - 5
|
|
|
|
virtual void SetVolume(int volume) {} // volume: 0 - 100
|
|
|
|
virtual void SetShuffle(bool state) {} // state: off = 0, on = 1
|
|
|
|
virtual void SetRepeat(bool state) {} // state: off = 0, on = 1
|
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() {}
|
|
|
|
|
2012-02-12 15:03:38 +00:00
|
|
|
INT GetMeasures() const { return m_Measures; }
|
|
|
|
void SetMeasures(INT measures) { m_Measures = measures; }
|
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
StateType GetState() const { return m_State; }
|
2012-03-12 12:01:12 +00:00
|
|
|
LPCTSTR GetArtist() const { return m_Artist.c_str(); }
|
|
|
|
LPCTSTR GetAlbum() const { return m_Album.c_str(); }
|
|
|
|
LPCTSTR GetTitle() const { return m_Title.c_str(); }
|
|
|
|
LPCTSTR GetLyrics() const { return m_Lyrics.c_str(); }
|
|
|
|
LPCTSTR GetCoverPath() const { return m_CoverPath.c_str(); }
|
|
|
|
LPCTSTR GetFilePath() const { return m_FilePath.c_str(); }
|
|
|
|
UINT GetDuration() const { return m_Duration; }
|
|
|
|
UINT GetPosition() const { return m_Position; }
|
|
|
|
UINT GetRating() const { return m_Rating; }
|
|
|
|
UINT GetVolume() const { return m_Volume; }
|
|
|
|
UINT GetNumber() const { return m_Number; }
|
|
|
|
UINT GetYear() const { return m_Year; }
|
2012-01-08 17:35:29 +00:00
|
|
|
bool GetShuffle() const { return m_Shuffle; }
|
|
|
|
bool GetRepeat() const { return m_Repeat; }
|
2011-05-21 18:17:37 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
UINT m_InstanceCount;
|
|
|
|
UINT m_UpdateCount;
|
|
|
|
UINT m_TrackCount;
|
2011-11-05 17:52:53 +00:00
|
|
|
std::wstring m_TempCoverPath;
|
2011-06-17 19:07:06 +00:00
|
|
|
|
2011-09-08 12:42:03 +00:00
|
|
|
INT m_Measures;
|
2012-02-12 15:03:38 +00:00
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
StateType 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
|
2012-03-12 12:01:12 +00:00
|
|
|
UINT m_Number;
|
|
|
|
UINT m_Year;
|
2011-09-11 08:22:07 +00:00
|
|
|
bool m_Shuffle;
|
|
|
|
bool m_Repeat;
|
2011-06-19 14:58:48 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static unsigned __stdcall LyricsThreadProc(void* pParam);
|
|
|
|
|
|
|
|
HANDLE m_InternetThread;
|
2011-05-21 18:17:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|