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 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
|
/*
* 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 <vector>
#include "ListItem.h"
#include "PlayList.h"
#include "InfoTagVideo.h"
#include "Exception.h"
#include "AddonString.h"
#include "InfoTagMusic.h"
#include "InfoTagRadioRDS.h"
#include "AddonCallback.h"
#include "Alternative.h"
#include "swighelper.h"
#include "cores/IPlayerCallback.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.
//
/// \defgroup python_Player Player
/// \ingroup python_xbmc
/// @{
/// @brief **Kodi's player.**
///
/// \python_class{ xbmc.Player() }
///
/// To become and create the class to play something.
///
///
///
///--------------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
/// ...
/// xbmc.Player().play(url, listitem, windowed)
/// ...
/// ~~~~~~~~~~~~~
//
class Player : public AddonCallback, public IPlayerCallback
{
private:
int iPlayList;
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:
#if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
static PlayParameter defaultPlayParameter;
#endif
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// 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 = 0);
virtual ~Player(void);
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ play([item, listitem, windowed, startpos]) }
///-----------------------------------------------------------------------
/// @brief Play a item.
///
/// @param item [opt] string - filename, url or playlist
/// @param listitem [opt] listitem - used with setInfo() to set
/// different infolabels.
/// @param windowed [opt] bool - true=play video windowed,
/// false=play users preference.(default)
/// @param startpos [opt] int - starting position when playing
/// a playlist. Default = -1
///
/// @note If item is not given then the Player will try to play the
/// current item 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.
///
///
///
///-----------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
/// ...
/// listitem = xbmcgui.ListItem('Ironman')
/// listitem.setInfo('video', {'Title': 'Ironman', 'Genre': 'Science Fiction'})
/// xbmc.Player().play(url, listitem, windowed)
/// xbmc.Player().play(playlist, listitem, windowed, startpos)
/// ...
/// ~~~~~~~~~~~~~
///
play(...);
#else
void play(const PlayParameter& item = Player::defaultPlayParameter,
const XBMCAddon::xbmcgui::ListItem* listitem = NULL, bool windowed = false, int startpos = -1);
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ stop() }
///-----------------------------------------------------------------------
/// Stop playing.
///
stop();
#else
void stop();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ pause() }
///-----------------------------------------------------------------------
/// Pause or resume playing if already paused.
///
pause();
#else
void pause();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ playnext() }
///-----------------------------------------------------------------------
/// Play next item in playlist.
///
playnext();
#else
void playnext();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ playprevious() }
///-----------------------------------------------------------------------
/// Play previous item in playlist.
///
playprevious();
#else
void playprevious();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ playselected(selected) }
///-----------------------------------------------------------------------
/// Play a certain item from the current playlist.
///
/// @param selected Integer - Item to select
///
playselected(...);
#else
void playselected(int selected);
#endif
//
/// @defgroup python_PlayerCB Callback functions from Kodi to Add-On
/// \ingroup python_Player
/// @{
/// @brief **Callback functions.**
///
/// Functions to handle control callbacks from Kodi to Add-On.
///
/// ----------------------------------------------------------------------
///
/// @link python_Player Go back to normal functions from player@endlink
//
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_PlayerCB
/// @brief \python_func{ onPlayBackStarted() }
///-----------------------------------------------------------------------
/// onPlayBackStarted method.
///
/// Will be called when Kodi starts playing a file.
///
onPlayBackStarted();
#else
virtual void onPlayBackStarted();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_PlayerCB
/// @brief \python_func{ onPlayBackEnded() }
///-----------------------------------------------------------------------
/// onPlayBackEnded method.
///
/// Will be called when Kodi stops playing a file.
///
onPlayBackEnded();
#else
virtual void onPlayBackEnded();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_PlayerCB
/// @brief \python_func{ onPlayBackStopped() }
///-----------------------------------------------------------------------
/// onPlayBackStopped method.
///
/// Will be called when user stops Kodi playing a file.
///
onPlayBackStopped();
#else
virtual void onPlayBackStopped();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_PlayerCB
/// @brief \python_func{ onPlayBackPaused() }
///-----------------------------------------------------------------------
/// onPlayBackPaused method.
///
/// Will be called when user pauses a playing file.
///
onPlayBackPaused();
#else
virtual void onPlayBackPaused();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_PlayerCB
/// @brief \python_func{ onPlayBackResumed() }
///-----------------------------------------------------------------------
/// onPlayBackResumed method.
///
/// Will be called when user resumes a paused file.
///
onPlayBackResumed();
#else
virtual void onPlayBackResumed();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_PlayerCB
/// @brief \python_func{ onQueueNextItem() }
///-----------------------------------------------------------------------
/// onQueueNextItem method.
///
/// Will be called when user queues the next item.
///
onQueueNextItem();
#else
virtual void onQueueNextItem();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_PlayerCB
/// @brief \python_func{ onPlayBackSpeedChanged(speed) }
///-----------------------------------------------------------------------
/// onPlayBackSpeedChanged method.
///
/// Will be called when players speed changes (eg. user FF/RW).
///
/// @param speed [integer] Current speed of player
///
/// @note Negative speed means player is rewinding, 1 is normal playback
/// speed.
///
onPlayBackSpeedChanged(int speed);
#else
virtual void onPlayBackSpeedChanged(int speed);
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_PlayerCB
/// @brief \python_func{ onPlayBackSeek(time, seekOffset) }
///-----------------------------------------------------------------------
/// onPlayBackSeek method.
///
/// Will be called when user seeks to a time.
///
/// @param time [integer] Time to seek to
/// @param seekOffset [integer] ?
///
onPlayBackSeek(...);
#else
virtual void onPlayBackSeek(int time, int seekOffset);
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_PlayerCB
/// @brief \python_func{ onPlayBackSeekChapter(chapter) }
///-----------------------------------------------------------------------
/// onPlayBackSeekChapter method.
///
/// Will be called when user performs a chapter seek.
///
/// @param chapter [integer] Chapter to seek to
///
onPlayBackSeekChapter(...);
#else
virtual void onPlayBackSeekChapter(int chapter);
#endif
/// @}
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ isPlaying() }
///-----------------------------------------------------------------------
/// Check Kodi is playing something.
///
/// @return True if Kodi is playing a file.
///
isPlaying();
#else
bool isPlaying();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ isPlayingAudio() }
///-----------------------------------------------------------------------
/// Check for playing audio.
///
/// @return True if Kodi is playing an audio file.
///
isPlayingAudio();
#else
bool isPlayingAudio();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ isPlayingVideo() }
///-----------------------------------------------------------------------
/// Check for playing video.
///
/// @return True if Kodi is playing a video.
///
isPlayingVideo();
#else
bool isPlayingVideo();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ isPlayingRDS() }
///-----------------------------------------------------------------------
/// Check for playing radio data system (RDS).
///
/// @return True if kodi is playing a radio data
/// system (RDS).
///
isPlayingRDS();
#else
bool isPlayingRDS();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ getPlayingFile() }
///-----------------------------------------------------------------------
/// Returns the current playing file as a string.
///
/// @note For LiveTV, returns a __pvr://__ url which is not translatable
/// to an OS specific file or external url.
///
/// @return Playing filename
/// @throws Exception If player is not playing a file.
///
getPlayingFile();
#else
String getPlayingFile();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ getTime() }
///-----------------------------------------------------------------------
/// Get playing time.
///
/// Returns the current time of the current playing media as fractional
/// seconds.
///
/// @return Current time as fractional seconds
/// @throws Exception If player is not playing a file.
///
getTime();
#else
double getTime();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ seekTime(seekTime) }
///-----------------------------------------------------------------------
/// Seek time.
///
/// Seeks the specified amount of time as fractional seconds.
/// The time specified is relative to the beginning of the currently.
/// playing media file.
///
/// @param seekTime Time to seek as fractional seconds
/// @throws Exception If player is not playing a file.
///
seekTime(...);
#else
void seekTime(double seekTime);
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ setSubtitles(subtitleFile) }
///-----------------------------------------------------------------------
/// Set subtitle file and enable subtitles.
///
/// @param subtitleFile File to use as source ofsubtitles
///
setSubtitles(...);
#else
void setSubtitles(const char* subtitleFile);
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ showSubtitles(visible) }
///-----------------------------------------------------------------------
/// Enable / disable subtitles.
///
/// @param visible [boolean] True for visible subtitles.
///
///
///-----------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
/// ...
/// xbmc.Player().showSubtitles(True)
/// ...
/// ~~~~~~~~~~~~~
///
showSubtitles(...);
#else
void showSubtitles(bool bVisible);
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ DisableSubtitles() }
///-----------------------------------------------------------------------
/// @python_v12 Deprecated. Use **showSubtitles** instead.
/// @python_v17 Completely removed function.
///
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ getSubtitles() }
///-----------------------------------------------------------------------
/// Get subtitle stream name.
///
/// @return Stream name
///
getSubtitles();
#else
String getSubtitles();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ getAvailableSubtitleStreams() }
///-----------------------------------------------------------------------
/// Get Subtitle stream names.
///
/// @return List of subtitle streams as name
///
getAvailableSubtitleStreams();
#else
std::vector<String> getAvailableSubtitleStreams();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ setSubtitleStream(stream) }
///-----------------------------------------------------------------------
/// Set Subtitle Stream.
///
/// @param iStream [int] Subtitle stream to select for play
///
///
///-----------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
/// ...
/// xbmc.Player().setSubtitleStream(1)
/// ...
/// ~~~~~~~~~~~~~
///
setSubtitleStream(...);
#else
void setSubtitleStream(int iStream);
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ getVideoInfoTag() }
///-----------------------------------------------------------------------
/// To get video info tag.
///
/// Returns the VideoInfoTag of the current playing Movie.
///
/// @return Video info tag
/// @throws Exception If player is not playing a file or current
/// file is not a movie file.
///
getVideoInfoTag();
#else
InfoTagVideo* getVideoInfoTag();
#endif
// Player_GetMusicInfoTag
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ getMusicInfoTag() }
///-----------------------------------------------------------------------
/// To get music info tag.
///
/// Returns the MusicInfoTag of the current playing 'Song'.
///
/// @return Music info tag
/// @throws Exception If player is not playing a file or current
/// file is not a music file.
///
getMusicInfoTag();
#else
InfoTagMusic* getMusicInfoTag();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ getRadioRDSInfoTag() }
///-----------------------------------------------------------------------
/// To get Radio RDS info tag
///
/// Returns the RadioRDSInfoTag of the current playing 'Radio Song if.
/// present'.
///
/// @return Radio RDS info tag
/// @throws Exception If player is not playing a file or current
/// file is not a rds file.
///
getRadioRDSInfoTag();
#else
InfoTagRadioRDS* getRadioRDSInfoTag() throw (PlayerException);
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ getTotalTime() }
///-----------------------------------------------------------------------
/// To get total playing time.
///
/// Returns the total time of the current playing media in seconds.
/// This is only accurate to the full second.
///
/// @return Total time of the current playing media
/// @throws Exception If player is not playing a file.
///
getTotalTime();
#else
double getTotalTime();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ getAvailableAudioStreams() }
///-----------------------------------------------------------------------
/// Get Audio stream names
///
/// @return List of audio streams as name
///
getAvailableAudioStreams();
#else
std::vector<String> getAvailableAudioStreams();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ setAudioStream(stream) }
///-----------------------------------------------------------------------
/// Set Audio Stream.
///
/// @param iStream [int] Audio stream to select for play
///
///
///-----------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
/// ...
/// xbmc.Player().setAudioStream(1)
/// ...
/// ~~~~~~~~~~~~~
///
setAudioStream(...);
#else
void setAudioStream(int iStream);
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ getAvailableVideoStreams() }
///-----------------------------------------------------------------------
/// Get Video stream names
///
/// @return List of video streams as name
///
getAvailableVideoStreams();
#else
std::vector<String> getAvailableVideoStreams();
#endif
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_Player
/// @brief \python_func{ setVideoStream(stream) }
///-----------------------------------------------------------------------
/// Set Video Stream.
///
/// @param iStream [int] Video stream to select for play
///
///
///-----------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
/// ...
/// xbmc.Player().setVideoStream(1)
/// ...
/// ~~~~~~~~~~~~~
///
setVideoStream(...);
#else
void setVideoStream(int iStream);
#endif
#if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
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:
};
}
}
|