-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
/
Player.h
349 lines (302 loc) · 10.5 KB
/
Player.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
/*
* Copyright (C) 2005-2013 Team XBMC
* http://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, see
* <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "cores/playercorefactory/PlayerCoreFactory.h"
#include "ListItem.h"
#include "PlayList.h"
#include "InfoTagVideo.h"
#include "Exception.h"
#include "AddonString.h"
#include "InfoTagMusic.h"
#include "AddonCallback.h"
#include "Alternative.h"
#include "swighelper.h"
namespace XBMCAddon
{
namespace xbmc
{
XBMCCOMMONS_STANDARD_EXCEPTION(PlayerException);
typedef Alternative<String, const PlayList* > PlayParameter;
// This class is a merge of what was previously in xbmcmodule/player.h
// and xbmcmodule/PythonPlayer.h without the python references. The
// queuing and handling of asynchronous callbacks is done internal to
// this class.
/**
* Player class.
*
* Player() -- Creates a new Player class.
*/
class Player : public AddonCallback, public IPlayerCallback
{
private:
int iPlayList;
EPLAYERCORES playerCore;
void playStream(const String& item = emptyString, const XBMCAddon::xbmcgui::ListItem* listitem = NULL, bool windowed = false);
void playPlaylist(const PlayList* playlist = NULL,
bool windowed = false, int startpos=-1);
void playCurrent(bool windowed = false);
public:
#ifndef SWIG
static PlayParameter defaultPlayParameter;
#endif
// Construct a Player proxying the given generated binding. The
// construction of a Player needs to identify whether or not any
// callbacks will be executed asynchronously or not.
Player(int playerCore = EPC_NONE);
virtual ~Player(void);
/**
* play([item, listitem, windowed, startpos]) -- Play this item.\n
* \n
* item : [opt] string - filename, url or playlist.\n
* listitem : [opt] listitem - used with setInfo() to set different infolabels.\n
* windowed : [opt] bool - true=play video windowed, false=play users preference.(default)\n
* startpos : [opt] int - starting position when playing a playlist. Default = -1\n
* \n
* *Note, If item is not given then the Player will try to play the current item\n
* in the current playlist.\n
* \n
* You can use the above as keywords for arguments and skip certain optional arguments.\n
* Once you use a keyword, all following arguments require the keyword.\n
* \n
* example:\n
* - listitem = xbmcgui.ListItem('Ironman')\n
* - listitem.setInfo('video', {'Title': 'Ironman', 'Genre': 'Science Fiction'})\n
* - xbmc.Player().play(url, listitem, windowed)\n
* - xbmc.Player().play(playlist, listitem, windowed, startpos)\n
*/
void play(const PlayParameter& item = Player::defaultPlayParameter,
const XBMCAddon::xbmcgui::ListItem* listitem = NULL, bool windowed = false, int startpos = -1);
/**
* stop() -- Stop playing.
*/
void stop();
/**
* pause() -- Pause or resume playing if already paused.
*/
void pause();
/**
* playnext() -- Play next item in playlist.
*/
void playnext();
/**
* playprevious() -- Play previous item in playlist.
*/
void playprevious();
/**
* playselected() -- Play a certain item from the current playlist.
*/
void playselected(int selected);
/**
* onPlayBackStarted() -- onPlayBackStarted method.
*
* Will be called when Kodi starts playing a file
*/
// Player_OnPlayBackStarted
virtual void onPlayBackStarted();
/**
* onPlayBackEnded() -- onPlayBackEnded method.
*
* Will be called when Kodi stops playing a file
*/
// Player_OnPlayBackEnded
virtual void onPlayBackEnded();
/**
* onPlayBackStopped() -- onPlayBackStopped method.
*
* Will be called when user stops Kodi playing a file
*/
// Player_OnPlayBackStopped
virtual void onPlayBackStopped();
/**
* onPlayBackPaused() -- onPlayBackPaused method.
*
* Will be called when user pauses a playing file
*/
// Player_OnPlayBackPaused
virtual void onPlayBackPaused();
/**
* onPlayBackResumed() -- onPlayBackResumed method.
*
* Will be called when user resumes a paused file
*/
// Player_OnPlayBackResumed
virtual void onPlayBackResumed();
/**
* onQueueNextItem() -- onQueueNextItem method.
*
* Will be called when user queues the next item
*/
virtual void onQueueNextItem();
/**
* onPlayBackSpeedChanged(speed) -- onPlayBackSpeedChanged method.
*
* speed : integer - current speed of player.
*
* *Note, negative speed means player is rewinding, 1 is normal playback speed.
*
* Will be called when players speed changes. (eg. user FF/RW)
*/
virtual void onPlayBackSpeedChanged(int speed);
/**
* onPlayBackSeek(time, seekOffset) -- onPlayBackSeek method.
*
* time : integer - time to seek to.\n
* seekOffset : integer - ?.
*
* Will be called when user seeks to a time
*/
virtual void onPlayBackSeek(int time, int seekOffset);
/**
* onPlayBackSeekChapter(chapter) -- onPlayBackSeekChapter method.
*
* chapter : integer - chapter to seek to.
*
* Will be called when user performs a chapter seek
*/
virtual void onPlayBackSeekChapter(int chapter);
/**
* isPlaying() -- returns True is Kodi is playing a file.
*/
// Player_IsPlaying
bool isPlaying();
/**
* isPlayingAudio() -- returns True is Kodi is playing an audio file.
*/
// Player_IsPlayingAudio
bool isPlayingAudio();
/**
* isPlayingVideo() -- returns True if Kodi is playing a video.
*/
// Player_IsPlayingVideo
bool isPlayingVideo();
/**
* getPlayingFile() -- returns the current playing file as a string.\n
* Note: For LiveTV, returns a pvr:// url which is not translatable to an OS specific file or external url\n
* \n
* Throws: Exception, if player is not playing a file.\n
*/
// Player_GetPlayingFile
String getPlayingFile();
/**
* getTime() -- Returns the current time of the current playing media as fractional seconds.
*
* Throws: Exception, if player is not playing a file.
*/
// Player_GetTime
double getTime();
/**
* seekTime() -- Seeks the specified amount of time as fractional seconds.
* The time specified is relative to the beginning of the
* currently playing media file.
*
* Throws: Exception, if player is not playing a file.
*/
// Player_SeekTime
void seekTime(double seekTime);
/**
* setSubtitles() -- set subtitle file and enable subtitlesn
*/
// Player_SetSubtitles
void setSubtitles(const char* subtitleFile);
// Player_ShowSubtitles
/**
* showSubtitles(visible) -- enable/disable subtitles
*
* visible : boolean - True for visible subtitles.
*
* example:
* - xbmc.Player().showSubtitles(True)
*/
void showSubtitles(bool bVisible);
/**
* getSubtitles() -- get subtitle stream name
*/
// Player_GetSubtitles
String getSubtitles();
/**
* DisableSubtitles() -- disable subtitles
*/
// Player_DisableSubtitles
void disableSubtitles();
// Player_getAvailableSubtitleStreams
/**
* getAvailableSubtitleStreams() -- get Subtitle stream names
*/
std::vector<String> getAvailableSubtitleStreams();
// Player_setSubtitleStream
/**
* setSubtitleStream(stream) -- set Subtitle Stream
*
* stream : int
*
* example:
* - setSubtitleStream(1)
*/
void setSubtitleStream(int iStream);
/**
* getVideoInfoTag() -- returns the VideoInfoTag of the current playing Movie.
*
* Throws: Exception, if player is not playing a file or current file is not a movie file.
*/
InfoTagVideo* getVideoInfoTag();
/**
* getMusicInfoTag() -- returns the MusicInfoTag of the current playing 'Song'.
*
* Throws: Exception, if player is not playing a file or current file is not a music file.
*/
// Player_GetMusicInfoTag
InfoTagMusic* getMusicInfoTag();
/**
* getTotalTime() -- Returns the total time of the current playing media in
* seconds. This is only accurate to the full second.
*
* Throws: Exception, if player is not playing a file.
*/
double getTotalTime();
// Player_getAvailableAudioStreams
/**
* getAvailableAudioStreams() -- get Audio stream names
*/
std::vector<String> getAvailableAudioStreams();
/**
* setAudioStream(stream) -- set Audio Stream.
*
* stream : int
*
* example:
*
* - setAudioStream(1)
*/
void setAudioStream(int iStream);
#ifndef SWIG
SWIGHIDDENVIRTUAL void OnPlayBackStarted();
SWIGHIDDENVIRTUAL void OnPlayBackEnded();
SWIGHIDDENVIRTUAL void OnPlayBackStopped();
SWIGHIDDENVIRTUAL void OnPlayBackPaused();
SWIGHIDDENVIRTUAL void OnPlayBackResumed();
SWIGHIDDENVIRTUAL void OnQueueNextItem();
SWIGHIDDENVIRTUAL void OnPlayBackSpeedChanged(int iSpeed);
SWIGHIDDENVIRTUAL void OnPlayBackSeek(int iTime, int seekOffset);
SWIGHIDDENVIRTUAL void OnPlayBackSeekChapter(int iChapter);
#endif
protected:
};
}
}