Shaka Player Embedded
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
shaka::Player Class Referencefinal

#include <player.h>

Classes

class  Client
 
class  Impl
 

Public Types

enum  LogLevel : uint8_t {
  LogLevel::None = 0, LogLevel::Error = 1, LogLevel::Warning = 2, LogLevel::Info = 3,
  LogLevel::Debug = 4, LogLevel::V1 = 5, LogLevel::V2 = 6
}
 

Public Member Functions

 Player (JsManager *engine)
 
 Player (Player &&)
 
 ~Player ()
 
Playeroperator= (Player &&)
 
 Player (const Player &)=delete
 
Playeroperator= (const Player &)=delete
 
AsyncResults< void > Initialize (Client *client, media::MediaPlayer *player=nullptr)
 
AsyncResults< void > Destroy ()
 
AsyncResults< bool > IsAudioOnly () const
 
AsyncResults< bool > IsBuffering () const
 
AsyncResults< bool > IsInProgress () const
 
AsyncResults< bool > IsLive () const
 
AsyncResults< bool > IsTextTrackVisible () const
 
AsyncResults< bool > UsingEmbeddedTextTrack () const
 
AsyncResults< optional< std::string > > AssetUri () const
 
AsyncResults< optional< DrmInfo > > DrmInfo () const
 
AsyncResults< std::vector< LanguageRole > > GetAudioLanguagesAndRoles () const
 
AsyncResults< BufferedInfoGetBufferedInfo () const
 
AsyncResults< double > GetExpiration () const
 
AsyncResults< StatsGetStats () const
 
AsyncResults< std::vector< Track > > GetTextTracks () const
 
AsyncResults< std::vector< Track > > GetVariantTracks () const
 
AsyncResults< std::vector< LanguageRole > > GetTextLanguagesAndRoles () const
 
AsyncResults< std::string > KeySystem () const
 
AsyncResults< BufferedRangeSeekRange () const
 
AsyncResults< void > Load (const std::string &manifest_uri, double start_time=NAN, const std::string &mime_type="")
 
AsyncResults< void > Unload ()
 
AsyncResults< void > ResetConfiguration ()
 
AsyncResults< void > RetryStreaming ()
 
AsyncResults< void > SelectAudioLanguage (const std::string &language, optional< std::string > role=nullopt)
 
AsyncResults< void > SelectEmbeddedTextTrack ()
 
AsyncResults< void > SelectTextLanguage (const std::string &language, optional< std::string > role=nullopt)
 
AsyncResults< void > SelectTextTrack (const Track &track)
 
AsyncResults< void > SelectVariantTrack (const Track &track, bool clear_buffer=false)
 
AsyncResults< void > SetTextTrackVisibility (bool visibility)
 
AsyncResults< TrackAddTextTrack (const std::string &uri, const std::string &language, const std::string &kind, const std::string &mime, const std::string &codec="", const std::string &label="")
 
AsyncResults< void > Attach (media::MediaPlayer *player)
 
AsyncResults< void > Detach ()
 
void AddNetworkFilters (NetworkFilters *filters)
 
void RemoveNetworkFilters (NetworkFilters *filters)
 
AsyncResults< bool > Configure (const std::string &name_path, DefaultValueType)
 
AsyncResults< bool > Configure (const std::string &name_path, bool value)
 
AsyncResults< bool > Configure (const std::string &name_path, double value)
 
AsyncResults< bool > Configure (const std::string &name_path, const std::string &value)
 
template<typename T , typename = typename std::enable_if< std::is_arithmetic<T>::value>::type>
AsyncResults< bool > Configure (const std::string &name_path, T value)
 
AsyncResults< bool > Configure (const std::string &name_path, const char *value)
 
AsyncResults< bool > GetConfigurationBool (const std::string &name_path)
 
AsyncResults< double > GetConfigurationDouble (const std::string &name_path)
 
AsyncResults< std::string > GetConfigurationString (const std::string &name_path)
 
AsyncResults< bool > Configure (const std::string &name_path, const std::vector< uint8_t > &data)
 
AsyncResults< bool > Configure (const std::string &name_path, const uint8_t *data, size_t data_size)
 

Static Public Member Functions

static AsyncResults< void > SetLogLevel (JsManager *engine, LogLevel level)
 
static AsyncResults< LogLevelGetLogLevel (JsManager *engine)
 
static AsyncResults< std::string > GetPlayerVersion (JsManager *engine)
 

Friends

class Storage
 

Detailed Description

Represents a JavaScript shaka.Player instance. This handles loading manifests and changing tracks.

Definition at line 53 of file player.h.

Member Enumeration Documentation

§ LogLevel

enum shaka::Player::LogLevel : uint8_t
strong
Enumerator
None 
Error 
Warning 
Info 
Debug 
V1 
V2 

Definition at line 89 of file player.h.

Constructor & Destructor Documentation

§ Player() [1/3]

shaka::Player::Player ( JsManager engine)

Creates a new Player instance.

Parameters
engineThe JavaScript engine to use.

Definition at line 320 of file player.cc.

§ Player() [2/3]

shaka::Player::Player ( Player &&  )
default

§ ~Player()

shaka::Player::~Player ( )

Definition at line 324 of file player.cc.

§ Player() [3/3]

shaka::Player::Player ( const Player )
delete

Member Function Documentation

§ AddNetworkFilters()

void shaka::Player::AddNetworkFilters ( NetworkFilters filters)

Definition at line 529 of file player.cc.

§ AddTextTrack()

AsyncResults< Track > shaka::Player::AddTextTrack ( const std::string &  uri,
const std::string &  language,
const std::string &  kind,
const std::string &  mime,
const std::string &  codec = "",
const std::string &  label = "" 
)

Adds the given text track to the current Period. Load() must resolve before calling. The current Period or the presentation must have a duration. This returns a Promise that will resolve with the track that was created, when that track can be switched to.

Definition at line 511 of file player.cc.

§ AssetUri()

AsyncResults< optional< std::string > > shaka::Player::AssetUri ( ) const
Returns
A future to the manifest URI given to load(), or null.

Definition at line 381 of file player.cc.

§ Attach()

AsyncResults< void > shaka::Player::Attach ( media::MediaPlayer player)

Tells the Player to use the given MediaPlayer instance for media handling. Once the returned results resolve, the old MediaPlayer won't be used anymore and this one will be used. If we are currently playing content, this will unload the content first.

Definition at line 521 of file player.cc.

§ Configure() [1/8]

AsyncResults< bool > shaka::Player::Configure ( const std::string &  name_path,
DefaultValueType   
)

Sets a configuration value on the Player instance. This is simply forwarded to the JavaScript instance. No error is returned if the requested configuration isn't present or is an invalid type, see the logs for errors. The path is a '.' separated list of names to reach the configuration. For example:

'abr.enabled' => {abr: {enabled: value}}

Returns
A future to whether the configuration path was valid.

Definition at line 441 of file player.cc.

§ Configure() [2/8]

AsyncResults< bool > shaka::Player::Configure ( const std::string &  name_path,
bool  value 
)

Sets a configuration value on the Player instance. This is simply forwarded to the JavaScript instance. No error is returned if the requested configuration isn't present or is an invalid type, see the logs for errors. The path is a '.' separated list of names to reach the configuration. For example:

'abr.enabled' => {abr: {enabled: value}}

Returns
A future to whether the configuration path was valid.

Definition at line 446 of file player.cc.

§ Configure() [3/8]

AsyncResults< bool > shaka::Player::Configure ( const std::string &  name_path,
double  value 
)

Sets a configuration value on the Player instance. This is simply forwarded to the JavaScript instance. No error is returned if the requested configuration isn't present or is an invalid type, see the logs for errors. The path is a '.' separated list of names to reach the configuration. For example:

'abr.enabled' => {abr: {enabled: value}}

Returns
A future to whether the configuration path was valid.

Definition at line 450 of file player.cc.

§ Configure() [4/8]

AsyncResults< bool > shaka::Player::Configure ( const std::string &  name_path,
const std::string &  value 
)

Sets a configuration value on the Player instance. This is simply forwarded to the JavaScript instance. No error is returned if the requested configuration isn't present or is an invalid type, see the logs for errors. The path is a '.' separated list of names to reach the configuration. For example:

'abr.enabled' => {abr: {enabled: value}}

Returns
A future to whether the configuration path was valid.

Definition at line 455 of file player.cc.

§ Configure() [5/8]

template<typename T , typename = typename std::enable_if< std::is_arithmetic<T>::value>::type>
AsyncResults<bool> shaka::Player::Configure ( const std::string &  name_path,
value 
)
inline

Sets a configuration value on the Player instance. This is simply forwarded to the JavaScript instance. No error is returned if the requested configuration isn't present or is an invalid type, see the logs for errors. The path is a '.' separated list of names to reach the configuration. For example:

'abr.enabled' => {abr: {enabled: value}}

Returns
A future to whether the configuration path was valid.

Definition at line 259 of file player.h.

§ Configure() [6/8]

AsyncResults<bool> shaka::Player::Configure ( const std::string &  name_path,
const char *  value 
)
inline

Sets a configuration value on the Player instance. This is simply forwarded to the JavaScript instance. No error is returned if the requested configuration isn't present or is an invalid type, see the logs for errors. The path is a '.' separated list of names to reach the configuration. For example:

'abr.enabled' => {abr: {enabled: value}}

Returns
A future to whether the configuration path was valid.

Definition at line 264 of file player.h.

§ Configure() [7/8]

AsyncResults<bool> shaka::Player::Configure ( const std::string &  name_path,
const std::vector< uint8_t > &  data 
)
inline

Configures the player with the given data buffer.

Definition at line 387 of file player.h.

§ Configure() [8/8]

AsyncResults< bool > shaka::Player::Configure ( const std::string &  name_path,
const uint8_t *  data,
size_t  data_size 
)

Configures the player with the given data buffer.

Definition at line 537 of file player.cc.

§ Destroy()

AsyncResults< void > shaka::Player::Destroy ( )

Destroys the contained Player instance. This is called automatically in the destructor, but calling it explicitly allows for handling of possible errors.

Definition at line 351 of file player.cc.

§ Detach()

AsyncResults< void > shaka::Player::Detach ( )

Tells the Player to stop using the current MediaPlayer instance. Once the returned results resolve, the old MediaPlayer won't be used anymore. If we are currently playing content, this will unload the content first.

Definition at line 525 of file player.cc.

§ DrmInfo()

AsyncResults< optional< DrmInfo > > shaka::Player::DrmInfo ( ) const
Returns
A future to the DrmInfo used to initialize EME. This returns null when not using EME.

Definition at line 385 of file player.cc.

§ GetAudioLanguagesAndRoles()

AsyncResults< std::vector< LanguageRole > > shaka::Player::GetAudioLanguagesAndRoles ( ) const
Returns
A future to list of audio language-role combinations available for the current Period.

Definition at line 389 of file player.cc.

§ GetBufferedInfo()

AsyncResults< BufferedInfo > shaka::Player::GetBufferedInfo ( ) const
Returns
A future to the current buffered ranges.

Definition at line 395 of file player.cc.

§ GetConfigurationBool()

AsyncResults< bool > shaka::Player::GetConfigurationBool ( const std::string &  name_path)

Gets a configuration value from the Player instance. This is simply forwarded to the JavaScript instance. No error is returned if the requested configuration isn't present or is an invalid type, see the logs for errors. The path is a '.' separated list of names to reach the configuration. For example:

'abr.enabled' => {abr: {enabled: value}}

TODO: These will be replaced with a more general GetConfiguration() method in the future.

Returns
A future to the value.

Definition at line 460 of file player.cc.

§ GetConfigurationDouble()

AsyncResults< double > shaka::Player::GetConfigurationDouble ( const std::string &  name_path)

Gets a configuration value from the Player instance. This is simply forwarded to the JavaScript instance. No error is returned if the requested configuration isn't present or is an invalid type, see the logs for errors. The path is a '.' separated list of names to reach the configuration. For example:

'abr.enabled' => {abr: {enabled: value}}

TODO: These will be replaced with a more general GetConfiguration() method in the future.

Returns
A future to the value.

Definition at line 464 of file player.cc.

§ GetConfigurationString()

AsyncResults< std::string > shaka::Player::GetConfigurationString ( const std::string &  name_path)

Gets a configuration value from the Player instance. This is simply forwarded to the JavaScript instance. No error is returned if the requested configuration isn't present or is an invalid type, see the logs for errors. The path is a '.' separated list of names to reach the configuration. For example:

'abr.enabled' => {abr: {enabled: value}}

TODO: These will be replaced with a more general GetConfiguration() method in the future.

Returns
A future to the value.

Definition at line 469 of file player.cc.

§ GetExpiration()

AsyncResults< double > shaka::Player::GetExpiration ( ) const
Returns
A future to the next known expiration time of any EME sessions. This returns Infinity if there are no sessions or they never expire.

Definition at line 399 of file player.cc.

§ GetLogLevel()

AsyncResults< Player::LogLevel > shaka::Player::GetLogLevel ( JsManager engine)
static

Gets the log level of the Shaka Player JavaScript.

Parameters
engineThe JavaScript engine to use.
Returns
A future to the log level.

Definition at line 334 of file player.cc.

§ GetPlayerVersion()

AsyncResults< std::string > shaka::Player::GetPlayerVersion ( JsManager engine)
static

Gets the version string of the Shaka Player JavaScript.

Parameters
engineThe JavaScript engine to use.
Returns
A future to the version string.

Definition at line 340 of file player.cc.

§ GetStats()

AsyncResults< Stats > shaka::Player::GetStats ( ) const

Return playback and adaptation stats.

Definition at line 403 of file player.cc.

§ GetTextLanguagesAndRoles()

AsyncResults< std::vector< LanguageRole > > shaka::Player::GetTextLanguagesAndRoles ( ) const
Returns
A future to list of text language-role combinations available for the current Period.

Definition at line 415 of file player.cc.

§ GetTextTracks()

AsyncResults< std::vector< Track > > shaka::Player::GetTextTracks ( ) const

Return a list of text tracks available for the current Period. If there are multiple Periods, then you must seek to the Period before being able to switch.

Definition at line 407 of file player.cc.

§ GetVariantTracks()

AsyncResults< std::vector< Track > > shaka::Player::GetVariantTracks ( ) const

Return a list of variant tracks available for the current Period. If there are multiple Periods, then you must seek to the Period before being able to switch.

Definition at line 411 of file player.cc.

§ Initialize()

AsyncResults< void > shaka::Player::Initialize ( Client client,
media::MediaPlayer player = nullptr 
)

Initializes the Player instance. This must be called once before any other method.

This can be given a MediaPlayer to attach to immediately. If not given, you need to call Attach before loading content.

Parameters
clientThe client that handles asynchronous events.
playerThe MediaPlayer that controls playback.

Definition at line 346 of file player.cc.

§ IsAudioOnly()

AsyncResults< bool > shaka::Player::IsAudioOnly ( ) const
Returns
A future to whether the stream is currently audio-only.

Definition at line 356 of file player.cc.

§ IsBuffering()

AsyncResults< bool > shaka::Player::IsBuffering ( ) const
Returns
A future to whether the Player is in a buffering state.

Definition at line 360 of file player.cc.

§ IsInProgress()

AsyncResults< bool > shaka::Player::IsInProgress ( ) const
Returns
A future to whether the stream is an in-progress recording.

Definition at line 364 of file player.cc.

§ IsLive()

AsyncResults< bool > shaka::Player::IsLive ( ) const
Returns
A future to whether the stream is live.

Definition at line 368 of file player.cc.

§ IsTextTrackVisible()

AsyncResults< bool > shaka::Player::IsTextTrackVisible ( ) const
Returns
A future to whether the text track is visible.

Definition at line 372 of file player.cc.

§ KeySystem()

AsyncResults< std::string > shaka::Player::KeySystem ( ) const
Returns
A future to the key system name being used by EME, or the empty string if not using EME.

Definition at line 421 of file player.cc.

§ Load()

AsyncResults< void > shaka::Player::Load ( const std::string &  manifest_uri,
double  start_time = NAN,
const std::string &  mime_type = "" 
)

Loads the given manifest. Returns a future that will resolve when the load is complete.

Parameters
manifest_uriThe URI of the manifest to load.
start_timeThe time to start playing at, in seconds.
mime_typeThe MIME type of the content being loaded. If the MIME type can't be detected based on the extension, we'll make a HEAD request to the URL to figure it out.

Definition at line 430 of file player.cc.

§ operator=() [1/2]

Player & shaka::Player::operator= ( Player &&  )
default

§ operator=() [2/2]

Player& shaka::Player::operator= ( const Player )
delete

§ RemoveNetworkFilters()

void shaka::Player::RemoveNetworkFilters ( NetworkFilters filters)

Stops the given object from receiving calls for network requests.

Definition at line 533 of file player.cc.

§ ResetConfiguration()

AsyncResults< void > shaka::Player::ResetConfiguration ( )

Reset configuration to default.

Definition at line 475 of file player.cc.

§ RetryStreaming()

AsyncResults< void > shaka::Player::RetryStreaming ( )

Retry streaming after a failure. Does nothing if not in a failure state.

Definition at line 479 of file player.cc.

§ SeekRange()

AsyncResults< BufferedRange > shaka::Player::SeekRange ( ) const
Returns
A future to the currently seekable range.

Definition at line 425 of file player.cc.

§ SelectAudioLanguage()

AsyncResults< void > shaka::Player::SelectAudioLanguage ( const std::string &  language,
optional< std::string >  role = nullopt 
)

Sets currentAudioLanguage and currentVariantRole to the selected language and role, and chooses a new variant if need be.

Definition at line 483 of file player.cc.

§ SelectEmbeddedTextTrack()

AsyncResults< void > shaka::Player::SelectEmbeddedTextTrack ( )

Use the embedded text for the current stream, if present. CEA 608/708 captions data is embedded inside the video stream.

Definition at line 488 of file player.cc.

§ SelectTextLanguage()

AsyncResults< void > shaka::Player::SelectTextLanguage ( const std::string &  language,
optional< std::string >  role = nullopt 
)

Sets currentTextLanguage and currentTextRole to the selected language and role, and chooses a new text stream if need be.

Definition at line 492 of file player.cc.

§ SelectTextTrack()

AsyncResults< void > shaka::Player::SelectTextTrack ( const Track track)

Select a specific text track. Note that AdaptationEvents are not fired for manual track selections.

Definition at line 497 of file player.cc.

§ SelectVariantTrack()

AsyncResults< void > shaka::Player::SelectVariantTrack ( const Track track,
bool  clear_buffer = false 
)

Select a specific track. Note that AdaptationEvents are not fired for manual track selections.

Definition at line 501 of file player.cc.

§ SetLogLevel()

AsyncResults< void > shaka::Player::SetLogLevel ( JsManager engine,
LogLevel  level 
)
static

Sets the log level of the JavaScript Shaka Player. This only works if the Shaka Player JS file is a debug build.

Parameters
engineThe JavaScript engine to use.
levelThe log level to set to.

Definition at line 328 of file player.cc.

§ SetTextTrackVisibility()

AsyncResults< void > shaka::Player::SetTextTrackVisibility ( bool  visibility)

Sets whether the text track should be visible or not, if any exists.

Parameters
visibilityTrue if the text track should be visible.

Definition at line 507 of file player.cc.

§ Unload()

AsyncResults< void > shaka::Player::Unload ( )

Unload the current manifest and make the Player available for re-use.

Definition at line 437 of file player.cc.

§ UsingEmbeddedTextTrack()

AsyncResults< bool > shaka::Player::UsingEmbeddedTextTrack ( ) const
Returns
A future to whether we are using an embedded text tracks.

Definition at line 376 of file player.cc.

Friends And Related Function Documentation

§ Storage

friend class Storage
friend

Definition at line 396 of file player.h.


The documentation for this class was generated from the following files: