kodi
Player.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "AddonCallback.h"
12 #include "AddonString.h"
13 #include "Alternative.h"
14 #include "Exception.h"
15 #include "InfoTagGame.h"
16 #include "InfoTagMusic.h"
17 #include "InfoTagRadioRDS.h"
18 #include "InfoTagVideo.h"
19 #include "ListItem.h"
20 #include "PlayList.h"
21 #include "cores/IPlayerCallback.h"
22 #include "swighelper.h"
23 
24 #include <vector>
25 
26 namespace XBMCAddon
27 {
28  namespace xbmc
29  {
30  XBMCCOMMONS_STANDARD_EXCEPTION(PlayerException);
31 
32  typedef Alternative<String, const PlayList* > PlayParameter;
33 
34  // This class is a merge of what was previously in xbmcmodule/player.h
35  // and xbmcmodule/PythonPlayer.h without the python references. The
36  // queuing and handling of asynchronous callbacks is done internal to
37  // this class.
38 
39  //
59  //
60  class Player : public AddonCallback, public IPlayerCallback
61  {
62  private:
63  int iPlayList;
64 
65  void playStream(const String& item = emptyString, const XBMCAddon::xbmcgui::ListItem* listitem = NULL, bool windowed = false);
66  void playPlaylist(const PlayList* playlist = NULL,
67  bool windowed = false, int startpos=-1);
68  void playCurrent(bool windowed = false);
69 
70  public:
71 #if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
72  static PlayParameter defaultPlayParameter;
73 #endif
74 
75 #ifndef DOXYGEN_SHOULD_SKIP_THIS
76  // Construct a Player proxying the given generated binding. The
77  // construction of a Player needs to identify whether or not any
78  // callbacks will be executed asynchronously or not.
79  explicit Player();
80  ~Player(void) override;
81 #endif
82 
83 #ifdef DOXYGEN_SHOULD_USE_THIS
84  play(...);
125 #else
126  void play(const PlayParameter& item = Player::defaultPlayParameter,
127  const XBMCAddon::xbmcgui::ListItem* listitem = NULL, bool windowed = false, int startpos = -1);
128 #endif
129 
130 #ifdef DOXYGEN_SHOULD_USE_THIS
131  stop();
137 #else
138  void stop();
139 #endif
140 
141 #ifdef DOXYGEN_SHOULD_USE_THIS
142  pause();
148 #else
149  void pause();
150 #endif
151 
152 #ifdef DOXYGEN_SHOULD_USE_THIS
153  playnext();
159 #else
160  void playnext();
161 #endif
162 
163 #ifdef DOXYGEN_SHOULD_USE_THIS
164  playprevious();
170 #else
171  void playprevious();
172 #endif
173 
174 #ifdef DOXYGEN_SHOULD_USE_THIS
175  playselected(...);
183 #else
184  void playselected(int selected);
185 #endif
186 
187  //
198  //
199 
200 #ifdef DOXYGEN_SHOULD_USE_THIS
201  onPlayBackStarted();
213 #else
214  virtual void onPlayBackStarted();
215 #endif
216 
217 
218 #ifdef DOXYGEN_SHOULD_USE_THIS
219  onAVStarted();
230 #else
231  virtual void onAVStarted();
232 #endif
233 
234 
235 #ifdef DOXYGEN_SHOULD_USE_THIS
236  onAVChange();
247 #else
248  virtual void onAVChange();
249 #endif
250 
251 #ifdef DOXYGEN_SHOULD_USE_THIS
252  onPlayBackEnded();
260 #else
261  virtual void onPlayBackEnded();
262 #endif
263 
264 #ifdef DOXYGEN_SHOULD_USE_THIS
265  onPlayBackStopped();
273 #else
274  virtual void onPlayBackStopped();
275 #endif
276 
277 #ifdef DOXYGEN_SHOULD_USE_THIS
278  onPlayBackError();
286 #else
287  virtual void onPlayBackError();
288 #endif
289 
290 #ifdef DOXYGEN_SHOULD_USE_THIS
291  onPlayBackPaused();
299 #else
300  virtual void onPlayBackPaused();
301 #endif
302 
303 #ifdef DOXYGEN_SHOULD_USE_THIS
304  onPlayBackResumed();
312 #else
313  virtual void onPlayBackResumed();
314 #endif
315 
316 #ifdef DOXYGEN_SHOULD_USE_THIS
317  onQueueNextItem();
325 #else
326  virtual void onQueueNextItem();
327 #endif
328 
329 #ifdef DOXYGEN_SHOULD_USE_THIS
330  onPlayBackSpeedChanged(int speed);
343 #else
344  virtual void onPlayBackSpeedChanged(int speed);
345 #endif
346 
347 #ifdef DOXYGEN_SHOULD_USE_THIS
348  onPlayBackSeek(...);
359 #else
360  virtual void onPlayBackSeek(int time, int seekOffset);
361 #endif
362 
363 #ifdef DOXYGEN_SHOULD_USE_THIS
364  onPlayBackSeekChapter(...);
374 #else
375  virtual void onPlayBackSeekChapter(int chapter);
376 #endif
377 
379 #ifdef DOXYGEN_SHOULD_USE_THIS
380  isPlaying();
388 #else
389  bool isPlaying();
390 #endif
391 
392 #ifdef DOXYGEN_SHOULD_USE_THIS
393  isPlayingAudio();
401 #else
402  bool isPlayingAudio();
403 #endif
404 
405 #ifdef DOXYGEN_SHOULD_USE_THIS
406  isPlayingVideo();
414 #else
415  bool isPlayingVideo();
416 #endif
417 
418 #ifdef DOXYGEN_SHOULD_USE_THIS
419  isPlayingRDS();
428 #else
429  bool isPlayingRDS();
430 #endif
431 
432 #ifdef DOXYGEN_SHOULD_USE_THIS
433  isPlayingGame();
444 #else
445  bool isPlayingGame();
446 #endif
447 
448 #ifdef DOXYGEN_SHOULD_USE_THIS
449  isExternalPlayer();
462 #else
463  bool isExternalPlayer();
464 #endif
465 
466 #ifdef DOXYGEN_SHOULD_USE_THIS
467  getPlayingFile();
479 #else
480  String getPlayingFile();
481 #endif
482 
483 #ifdef DOXYGEN_SHOULD_USE_THIS
484  getPlayingItem();
496 #else
497  XBMCAddon::xbmcgui::ListItem* getPlayingItem();
498 #endif
499 
500 #ifdef DOXYGEN_SHOULD_USE_THIS
501  getTime();
513 #else
514  double getTime();
515 #endif
516 
517 #ifdef DOXYGEN_SHOULD_USE_THIS
518  seekTime(...);
531 #else
532  void seekTime(double seekTime);
533 #endif
534 
535 #ifdef DOXYGEN_SHOULD_USE_THIS
536  setSubtitles(...);
544 #else
545  void setSubtitles(const char* subtitleFile);
546 #endif
547 
548 #ifdef DOXYGEN_SHOULD_USE_THIS
549  showSubtitles(...);
567 #else
568  void showSubtitles(bool bVisible);
569 #endif
570 
571 #ifdef DOXYGEN_SHOULD_USE_THIS
572  getSubtitles();
580 #else
581  String getSubtitles();
582 #endif
583 
584 #ifdef DOXYGEN_SHOULD_USE_THIS
585  getAvailableSubtitleStreams();
593 #else
594  std::vector<String> getAvailableSubtitleStreams();
595 #endif
596 
597 #ifdef DOXYGEN_SHOULD_USE_THIS
598  setSubtitleStream(...);
616 #else
617  void setSubtitleStream(int iStream);
618 #endif
619 
620  // Player_UpdateInfoTag
621 #ifdef DOXYGEN_SHOULD_USE_THIS
622  updateInfoTag();
644 #else
645  void updateInfoTag(const XBMCAddon::xbmcgui::ListItem* item);
646 #endif
647 
648 #ifdef DOXYGEN_SHOULD_USE_THIS
649  getGameInfoTag();
664 #else
665  InfoTagGame* getGameInfoTag();
666 #endif
667 
668 #ifdef DOXYGEN_SHOULD_USE_THIS
669  getVideoInfoTag();
681 #else
682  InfoTagVideo* getVideoInfoTag();
683 #endif
684 
685  // Player_GetMusicInfoTag
686 #ifdef DOXYGEN_SHOULD_USE_THIS
687  getMusicInfoTag();
699 #else
700  InfoTagMusic* getMusicInfoTag();
701 #endif
702 
703 #ifdef DOXYGEN_SHOULD_USE_THIS
704  getRadioRDSInfoTag();
717 #else
718  InfoTagRadioRDS* getRadioRDSInfoTag();
719 #endif
720 
721 #ifdef DOXYGEN_SHOULD_USE_THIS
722  getTotalTime();
734 #else
735  double getTotalTime();
736 #endif
737 
738 #ifdef DOXYGEN_SHOULD_USE_THIS
739  getAvailableAudioStreams();
747 #else
748  std::vector<String> getAvailableAudioStreams();
749 #endif
750 
751 #ifdef DOXYGEN_SHOULD_USE_THIS
752  setAudioStream(...);
770 #else
771  void setAudioStream(int iStream);
772 #endif
773 
774 #ifdef DOXYGEN_SHOULD_USE_THIS
775  getAvailableVideoStreams();
783 #else
784  std::vector<String> getAvailableVideoStreams();
785 #endif
786 
787 #ifdef DOXYGEN_SHOULD_USE_THIS
788  setVideoStream(...);
806 #else
807  void setVideoStream(int iStream);
808 #endif
809 
810 #if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
811  void OnPlayBackStarted(const CFileItem& file) override;
812  void OnAVStarted(const CFileItem& file) override;
813  void OnAVChange() override;
814  void OnPlayBackEnded() override;
815  void OnPlayBackStopped() override;
816  void OnPlayBackError() override;
817  void OnPlayBackPaused() override;
818  void OnPlayBackResumed() override;
819  void OnQueueNextItem() override;
820  void OnPlayBackSpeedChanged(int iSpeed) override;
821  void OnPlayBackSeek(int64_t iTime, int64_t seekOffset) override;
822  void OnPlayBackSeekChapter(int iChapter) override;
823 #endif
824 
825  protected:
826  };
827  }
828 }
829 
Definition: InfoTagRadioRDS.h:52
Definition: Player.h:60
Definition: InfoTagGame.h:48
Definition: InfoTagVideo.h:858
Defining LOG_LIFECYCLE_EVENTS will log all instantiations, deletions and also reference countings (in...
Definition: Addon.cpp:25
Definition: IPlayerCallback.h:18
Definition: PlayList.h:49
Definition: ListItem.h:53
This class is the superclass for all API classes that are expected to be able to handle cross-languag...
Definition: AddonCallback.h:23
Definition: InfoTagMusic.h:47
Represents a file on a share.
Definition: FileItem.h:102