add missing startpos option to pydocs
[vuplus_xbmc] / xbmc / interfaces / legacy / Player.h
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #pragma once
22
23 #include "cores/playercorefactory/PlayerCoreFactory.h"
24
25 #include "ListItem.h"
26 #include "PlayList.h"
27 #include "InfoTagVideo.h"
28 #include "Exception.h"
29 #include "music/tags/MusicInfoTag.h"
30 #include "AddonString.h"
31 #include "InfoTagMusic.h"
32 #include "AddonCallback.h"
33 #include "Alternative.h"
34
35 #include "swighelper.h"
36
37 namespace XBMCAddon
38 {
39   namespace xbmc
40   {
41     XBMCCOMMONS_STANDARD_EXCEPTION(PlayerException);
42
43     typedef Alternative<String, const PlayList* > PlayParameter;
44
45     // This class is a merge of what was previously in xbmcmodule/player.h
46     //  and xbmcmodule/PythonPlayer.h without the python references. The
47     //  queuing and handling of asynchronous callbacks is done internal to
48     //  this class.
49
50     /**
51      * Player class.
52      * 
53      * Player() -- Creates a new Player class.
54      */
55     class Player : public AddonCallback, public IPlayerCallback
56     {
57     private:
58       int iPlayList;
59       EPLAYERCORES playerCore;
60
61       void playStream(const String& item = emptyString, const XBMCAddon::xbmcgui::ListItem* listitem = NULL, bool windowed = false);
62       void playPlaylist(const PlayList* playlist = NULL,
63                         bool windowed = false, int startpos=-1);
64       void playCurrent(bool windowed = false);
65
66     public:
67 #ifndef SWIG
68           static PlayParameter defaultPlayParameter;
69 #endif
70
71       // Construct a Player proxying the given generated binding. The 
72       //  construction of a Player needs to identify whether or not any 
73       //  callbacks will be executed asynchronously or not.
74       Player(int playerCore = EPC_NONE);
75       virtual ~Player(void);
76
77       /**
78        * play([item, listitem, windowed, startpos]) -- Play this item.\n
79        * \n
80        * item           : [opt] string - filename, url or playlist.\n
81        * listitem       : [opt] listitem - used with setInfo() to set different infolabels.\n
82        * windowed       : [opt] bool - true=play video windowed, false=play users preference.(default)\n
83        * startpos       : [opt] int - starting position when playing a playlist. Default = -1\n
84        * \n
85        * *Note, If item is not given then the Player will try to play the current item\n
86        *        in the current playlist.\n
87        * \n
88        *        You can use the above as keywords for arguments and skip certain optional arguments.\n
89        *        Once you use a keyword, all following arguments require the keyword.\n
90        * \n
91        * example:\n
92        *   - listitem = xbmcgui.ListItem('Ironman')\n
93        *   - listitem.setInfo('video', {'Title': 'Ironman', 'Genre': 'Science Fiction'})\n
94        *   - xbmc.Player().play(url, listitem, windowed)\n
95        *   - xbmc.Player().play(playlist, listitem, windowed, startpos)\n
96        */
97       void play(const PlayParameter& item = Player::defaultPlayParameter, 
98                 const XBMCAddon::xbmcgui::ListItem* listitem = NULL, bool windowed = false, int startpos = -1);
99
100       /**
101        * stop() -- Stop playing.
102        */
103       void stop();
104
105       /**
106        * pause() -- Pause playing.
107        */
108       void pause();
109
110       /**
111        * playnext() -- Play next item in playlist.
112        */
113       void playnext();
114
115       /**
116        * playprevious() -- Play previous item in playlist.
117        */
118       void playprevious();
119
120       /**
121        * playselected() -- Play a certain item from the current playlist.
122        */
123       void playselected(int selected);
124
125       /**
126        * onPlayBackStarted() -- onPlayBackStarted method.
127        * 
128        * Will be called when xbmc starts playing a file
129        */
130       // Player_OnPlayBackStarted
131       virtual void onPlayBackStarted();
132
133
134       /**
135        * onPlayBackEnded() -- onPlayBackEnded method.
136        * 
137        * Will be called when xbmc stops playing a file
138        */
139       // Player_OnPlayBackEnded
140       virtual void onPlayBackEnded();
141
142       /**
143        * onPlayBackStopped() -- onPlayBackStopped method.
144        * 
145        * Will be called when user stops xbmc playing a file
146        */
147       // Player_OnPlayBackStopped
148       virtual void onPlayBackStopped();
149
150       /**
151        * onPlayBackPaused() -- onPlayBackPaused method.
152        * 
153        * Will be called when user pauses a playing file
154        */
155       // Player_OnPlayBackPaused
156       virtual void onPlayBackPaused();
157
158       /**
159        * onPlayBackResumed() -- onPlayBackResumed method.
160        * 
161        * Will be called when user resumes a paused file
162        */
163       // Player_OnPlayBackResumed
164       virtual void onPlayBackResumed();
165
166       /**
167        * onQueueNextItem() -- onQueueNextItem method.
168        * 
169        * Will be called when user queues the next item
170        */
171       virtual void onQueueNextItem();
172
173       /**
174        * onPlayBackSpeedChanged(speed) -- onPlayBackSpeedChanged method.
175        * 
176        * speed          : integer - current speed of player.
177        * 
178        * *Note, negative speed means player is rewinding, 1 is normal playback speed.
179        * 
180        * Will be called when players speed changes. (eg. user FF/RW)
181        */
182       virtual void onPlayBackSpeedChanged(int speed);
183
184       /**
185        * onPlayBackSeek(time, seekOffset) -- onPlayBackSeek method.
186        * 
187        * time           : integer - time to seek to.\n
188        * seekOffset     : integer - ?.
189        * 
190        * Will be called when user seeks to a time
191        */
192       virtual void onPlayBackSeek(int time, int seekOffset);
193
194       /**
195        * onPlayBackSeekChapter(chapter) -- onPlayBackSeekChapter method.
196        * 
197        * chapter        : integer - chapter to seek to.
198        * 
199        * Will be called when user performs a chapter seek
200        */
201       virtual void onPlayBackSeekChapter(int chapter);
202
203       /**
204        * isPlaying() -- returns True is xbmc is playing a file.
205        */
206       // Player_IsPlaying
207       bool isPlaying();
208
209       /**
210        * isPlayingAudio() -- returns True is xbmc is playing an audio file.
211        */
212       // Player_IsPlayingAudio
213       bool isPlayingAudio();
214
215       /**
216        * isPlayingVideo() -- returns True if xbmc is playing a video.
217        */
218       // Player_IsPlayingVideo
219       bool isPlayingVideo();
220
221       /**
222        * getPlayingFile() -- returns the current playing file as a string.
223        * 
224        * Throws: Exception, if player is not playing a file.
225        */
226       // Player_GetPlayingFile
227       String getPlayingFile() throw (PlayerException);
228
229       /**
230        * getTime() -- Returns the current time of the current playing media as fractional seconds.
231        * 
232        * Throws: Exception, if player is not playing a file.
233        */
234       // Player_GetTime
235       double getTime() throw(PlayerException);
236
237       /**
238        * seekTime() -- Seeks the specified amount of time as fractional seconds.
239        *               The time specified is relative to the beginning of the
240        *               currently playing media file.
241        * 
242        * Throws: Exception, if player is not playing a file.
243        */
244       // Player_SeekTime
245       void seekTime(double seekTime) throw(PlayerException);
246
247       /**
248        * setSubtitles() -- set subtitle file and enable subtitlesn
249        */
250       // Player_SetSubtitles
251       void setSubtitles(const char* subtitleFile);
252
253       // Player_ShowSubtitles
254       /**
255        * showSubtitles(visible) -- enable/disable subtitles
256        * 
257        * visible        : boolean - True for visible subtitles.
258        *
259        * example:
260        * - xbmc.Player().showSubtitles(True)
261        */
262       void showSubtitles(bool bVisible);
263
264       /**
265        * getSubtitles() -- get subtitle stream name
266        */
267       // Player_GetSubtitles
268       String getSubtitles();
269
270       /**
271        * DisableSubtitles() -- disable subtitles
272        */
273       // Player_DisableSubtitles
274       void disableSubtitles();
275
276       // Player_getAvailableSubtitleStreams
277       /**
278        * getAvailableSubtitleStreams() -- get Subtitle stream names
279        */
280       std::vector<String>* getAvailableSubtitleStreams();
281
282       // Player_setSubtitleStream
283       /**
284        * setSubtitleStream(stream) -- set Subtitle Stream 
285        * 
286        * stream           : int
287        * 
288        * example:
289        *   - setSubtitleStream(1)
290        */
291       void setSubtitleStream(int iStream);
292
293       /**
294        * getVideoInfoTag() -- returns the VideoInfoTag of the current playing Movie.
295        * 
296        * Throws: Exception, if player is not playing a file or current file is not a movie file.
297        */
298       InfoTagVideo* getVideoInfoTag() throw (PlayerException);
299
300       /**
301        * getMusicInfoTag() -- returns the MusicInfoTag of the current playing 'Song'.
302        * 
303        * Throws: Exception, if player is not playing a file or current file is not a music file.
304        */
305       // Player_GetMusicInfoTag
306       InfoTagMusic* getMusicInfoTag() throw (PlayerException);
307
308       /**
309        *getTotalTime() -- Returns the total time of the current playing media in
310        *                  seconds.  This is only accurate to the full second.
311        *
312        *Throws: Exception, if player is not playing a file.
313        */
314       double getTotalTime() throw (PlayerException);
315
316       // Player_getAvailableAudioStreams
317       /**
318        * getAvailableAudioStreams() -- get Audio stream names
319        */
320       std::vector<String>* getAvailableAudioStreams();
321
322       /**
323        * setAudioStream(stream) -- set Audio Stream.
324        * 
325        * stream           : int
326        * 
327        * example:
328        * 
329        *    - setAudioStream(1)
330        */
331       void setAudioStream(int iStream);
332
333 #ifndef SWIG
334       SWIGHIDDENVIRTUAL void OnPlayBackStarted();
335       SWIGHIDDENVIRTUAL void OnPlayBackEnded();
336       SWIGHIDDENVIRTUAL void OnPlayBackStopped();
337       SWIGHIDDENVIRTUAL void OnPlayBackPaused();
338       SWIGHIDDENVIRTUAL void OnPlayBackResumed();
339       SWIGHIDDENVIRTUAL void OnQueueNextItem();
340       SWIGHIDDENVIRTUAL void    OnPlayBackSpeedChanged(int iSpeed);
341       SWIGHIDDENVIRTUAL void    OnPlayBackSeek(int iTime, int seekOffset);
342       SWIGHIDDENVIRTUAL void    OnPlayBackSeekChapter(int iChapter);
343 #endif
344
345     protected:
346     };
347   }
348 }
349