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