📄 playlist.h
字号:
/*****************************************************************
|
| PlayList Management
|
|
| (c) 1996-1998 MpegTV, LLC
| Author: Gilles Boccon-Gibod (gilles@mpegtv.com)
|
****************************************************************/
#ifndef __PLAYLIST_H__
#define __PLAYLIST_H__
/*----------------------------------------------------------------------
| constants
+---------------------------------------------------------------------*/
const int PLAYLIST_SUCCESS = 0;
const int PLAYLIST_FAILURE = -1;
const int PLAYLIST_ERROR_INVALID_PARAMETERS = -2;
const int PLAYLIST_MODE_PLAYING = 0x01;
const int PLAYLIST_MODE_LOOP = 0x02;
const int PLAYLIST_MODE_RANDOM = 0x04;
const int PLAYLIST_STATUS_PLAYED = 0x01;
/*----------------------------------------------------------------------
| types
+---------------------------------------------------------------------*/
class PlayList;
class PlayListItem;
typedef enum
{
PLAYLIST_EVENT_ITEM_CREATED,
PLAYLIST_EVENT_ITEM_DELETED,
PLAYLIST_EVENT_ITEM_CHANGED,
PLAYLIST_EVENT_CURRENT_CHANGED,
PLAYLIST_EVENT_STOP_PLAYING
} PlayListEventType;
typedef enum {
PLAYLIST_ACTION_NONE,
PLAYLIST_ACTION_PLAY
} PlayListAction;
typedef struct
{
PlayListItem *current;
PlayListItem *previous;
PlayListAction action;
} PlayListCurrentChangedEvent;
typedef void(*PlayListCallback)(void *client,
PlayList *,
PlayListEventType event,
void *event_data);
/*----------------------------------------------------------------------
| PlayList class
+---------------------------------------------------------------------*/
class PlayList {
friend class PlayListItem;
protected:
void *m_CallbackClient;
PlayListCallback m_CallbackFunction;
PlayListItem *m_Root;
PlayListItem *m_Current;
unsigned int m_Mode;
PlayListAction m_DefaultAction;
public:
PlayList();
~PlayList();
void RegisterCallback(PlayListCallback callback, void *client);
int AddTrack(const char *name);
int AddTrack(PlayListItem *parent, const char *name);
int AddGroup(const char *name);
int AddGroup(PlayListItem *parent, const char *name);
int Delete(PlayListItem *);
void Clear();
int SetCurrent(PlayListItem *item, PlayListAction action = PLAYLIST_ACTION_NONE);
int Play();
int Stop();
int Next();
int Prev();
void SetMode(unsigned int mask, unsigned int mode);
};
/*----------------------------------------------------------------------
| PlayListItem class
+---------------------------------------------------------------------*/
class PlayListItem
{
friend class PlayList;
protected:
// variables
PlayList *m_PlayList;
unsigned int m_Status;
// methods
void SetName(const char *name);
int DoAction(PlayListAction action);
public:
// variables
PlayListItem *m_Parent;
PlayListItem *m_FirstChild;
PlayListItem *m_RightSibling;
PlayListItem *m_LeftSibling;
unsigned long m_State;
char *m_FullName;
char *m_ShortName;
char *m_GroupName;
unsigned long m_ClientData;
// methods
PlayListItem(PlayListItem *parent, const char *name);
PlayListItem(PlayList *owner, const char *name);
~PlayListItem();
void Init();
void AddChild(PlayListItem *item);
int Play();
int Next();
int Prev();
};
#endif /* __PLAYLIST_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -