/
PlayListPlayer.h
200 lines (170 loc) · 6.98 KB
/
PlayListPlayer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#pragma once
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* 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, 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 XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "guilib/IMsgTargetCallback.h"
#include <boost/shared_ptr.hpp>
#define PLAYLIST_NONE -1
#define PLAYLIST_MUSIC 0
#define PLAYLIST_VIDEO 1
#define PLAYLIST_PICTURE 2
class CFileItem; typedef boost::shared_ptr<CFileItem> CFileItemPtr;
class CFileItemList;
namespace PLAYLIST
{
/*!
\ingroup windows
\brief Manages playlist playing.
*/
enum REPEAT_STATE { REPEAT_NONE = 0, REPEAT_ONE, REPEAT_ALL };
class CPlayList;
class CPlayListPlayer : public IMsgTargetCallback
{
public:
CPlayListPlayer(void);
virtual ~CPlayListPlayer(void);
virtual bool OnMessage(CGUIMessage &message);
/*! \brief Play the next (or another) entry in the current playlist
\param offset The offset from the current entry (defaults to 1, i.e. the next entry).
\param autoPlay Whether we should start playing if not already (defaults to false).
*/
bool PlayNext(int offset = 1, bool autoPlay = false);
/*! \brief Play the previous entry in the current playlist
\sa PlayNext
*/
bool PlayPrevious();
bool PlaySongId(int songId);
bool Play();
/*! \brief Start playing a particular entry in the current playlist
\param index the index of the item to play. This value is modified to ensure it lies within the current playlist.
\param replace whether this item should replace the currently playing item. See CApplication::PlayFile (defaults to false).
\param playPreviousOnFail whether to go back to the previous item if playback fails (default to false)
*/
bool Play(int index, bool replace = false, bool playPreviousOnFail = false);
/*! \brief Returns the index of the current item in active playlist.
\return Current item in the active playlist.
\sa SetCurrentSong
*/
int GetCurrentSong() const;
/*! \brief Change the current item in the active playlist.
\param index item index in playlist. Set only if the index is within the range of the current playlist.
\sa GetCurrentSong
*/
void SetCurrentSong(int index);
int GetNextSong();
/*! \brief Get the index in the playlist that is offset away from the current index in the current playlist.
Obeys any repeat settings (eg repeat one will return the current index regardless of offset)
\return the index of the entry, or -1 if there is no current playlist. There is no guarantee that the returned index is valid.
*/
int GetNextSong(int offset) const;
/*! \brief Set the active playlist
\param playList Values can be PLAYLIST_NONE, PLAYLIST_MUSIC or PLAYLIST_VIDEO
\sa GetCurrentPlaylist
*/
void SetCurrentPlaylist(int playlist);
/*! \brief Get the currently active playlist
\return PLAYLIST_NONE, PLAYLIST_MUSIC or PLAYLIST_VIDEO
\sa SetCurrentPlaylist, GetPlaylist
*/
int GetCurrentPlaylist() const;
/*! \brief Get a particular playlist object
\param playList Values can be PLAYLIST_MUSIC or PLAYLIST_VIDEO
\return A reference to the CPlayList object.
\sa GetCurrentPlaylist
*/
CPlayList& GetPlaylist(int playlist);
const CPlayList& GetPlaylist(int iPlaylist) const;
/*! \brief Removes any item from all playlists located on a removable share
\return Number of items removed from PLAYLIST_MUSIC and PLAYLIST_VIDEO
*/
int RemoveDVDItems();
/*! \brief Resets the current song and unplayable counts.
Does not alter the active playlist.
*/
void Reset();
void ClearPlaylist(int iPlaylist);
void Clear();
/*! \brief Set shuffle state of a playlist.
If the shuffle state changes, the playlist is shuffled or unshuffled.
Has no effect if Party Mode is enabled.
\param playlist the playlist to (un)shuffle, PLAYLIST_MUSIC or PLAYLIST_VIDEO.
\param shuffle set true to shuffle, false to unshuffle.
\param notify notify the user with a Toast notification (defaults to false)
\sa IsShuffled
*/
void SetShuffle(int playlist, bool shuffle, bool notify = false);
/*! \brief Return whether a playlist is shuffled.
If partymode is enabled, this always returns false.
\param playlist the playlist to query for shuffle state, PLAYLIST_MUSIC or PLAYLIST_VIDEO.
\return true if the given playlist is shuffled and party mode isn't enabled, false otherwise.
\sa SetShuffle
*/
bool IsShuffled(int iPlaylist) const;
/*! \brief Return whether or not something has been played yet from the current playlist.
\return true if something has been played, false otherwise.
*/
bool HasPlayedFirstFile() const;
/*! \brief Set repeat state of a playlist.
If called while in Party Mode, repeat is disabled.
\param playlist the playlist to set repeat state for, PLAYLIST_MUSIC or PLAYLIST_VIDEO.
\param state set to REPEAT_NONE, REPEAT_ONE or REPEAT_ALL
\param notify notify the user with a Toast notification
\sa GetRepeat
*/
void SetRepeat(int iPlaylist, REPEAT_STATE state, bool notify = false);
REPEAT_STATE GetRepeat(int iPlaylist) const;
// add items via the playlist player
void Add(int iPlaylist, CPlayList& playlist);
void Add(int iPlaylist, const CFileItemPtr &pItem);
void Add(int iPlaylist, CFileItemList& items);
void Insert(int iPlaylist, CPlayList& playlist, int iIndex);
void Insert(int iPlaylist, const CFileItemPtr &pItem, int iIndex);
void Insert(int iPlaylist, CFileItemList& items, int iIndex);
void Remove(int iPlaylist, int iPosition);
void Swap(int iPlaylist, int indexItem1, int indexItem2);
protected:
/*! \brief Returns true if the given is set to repeat all
\param playlist Playlist to be query
\return true if the given playlist is set to repeat all, false otherwise.
*/
bool Repeated(int playlist) const;
/*! \brief Returns true if the given is set to repeat one
\param playlist Playlist to be query
\return true if the given playlist is set to repeat one, false otherwise.
*/
bool RepeatedOne(int playlist) const;
void ReShuffle(int iPlaylist, int iPosition);
bool m_bPlayedFirstFile;
bool m_bPlaybackStarted;
int m_iFailedSongs;
unsigned int m_failedSongsStart;
int m_iCurrentSong;
int m_iCurrentPlayList;
CPlayList* m_PlaylistMusic;
CPlayList* m_PlaylistVideo;
CPlayList* m_PlaylistEmpty;
REPEAT_STATE m_repeatState[2];
};
}
/*!
\ingroup windows
\brief Global instance of playlist player
*/
extern PLAYLIST::CPlayListPlayer g_playlistPlayer;