An abstract video player that provides a basic interface that all subclasses must implement.
The abstract video player provides all the basic functionality expected of a standard video player. This video player must be subclassed and implemented in a concrete way. Basic player functionality and signals are provided by the abstract video player. The abstract video player contains a CYIVideoPlayerStateManager which is responsible for maintaining valid player states for the abstract video player. When implementing a concrete player state transitions must be made through the CYIVideoPlayerStateManager. See the class level documentation of CYIVideoPlayerStateManager for further detail on state transitions in the video player.
CYIDefaultVideoPlayerFactory is provided to construct the default concrete player for the current platform.
CYIAbstractVideoPlayer and each provided concrete implementation is equipped with RTTI. This enables dynamic casting to a concrete player in order to safely use APIs specific to the desired player. It is recommended to use the CYIAbstractVideoPlayer type whenever possible. For example:
#include <player/YiAbstractVideoPlayer.h>

Classes | |
| struct | AudioTrackInfo |
| struct | ClosedCaptionsTrackInfo |
| class | DRMConfiguration |
| The base class for all DRM configurations. More... | |
| struct | Error |
| struct | PlayerState |
| struct | Statistics |
| struct | TrackInfo |
Public Types | |
| enum | MEDIA_STATE { MEDIA_UNLOADED, MEDIA_PREPARING, MEDIA_READY } |
| enum | PLAYBACK_STATE { PLAYBACK_PLAYING, PLAYBACK_PAUSED, PLAYBACK_BUFFERING } |
| enum | STREAMING_FORMAT { HLS = 0, SMOOTH, DASH, MP4 } |
| enum | DRM_SCHEME { DRM_NONE = 0, DRM_FAIRPLAY, DRM_PLAYREADY, DRM_WIDEVINE_MODULAR } |
| enum | ERROR_CODE { PLAYBACK_ERROR, UNSUPPORTED_FORMAT, STATE_TRANSITION_ERROR, DRM_ERROR, UNKNOWN } |
| using | VideoMetadata = std::map< CYIString, CYIString > |
Public Attributes | |
| CYISignal | BufferingStarted |
| CYISignal | BufferingEnded |
| CYISignal< Error > | ErrorOccurred |
| CYISignal | Preparing |
| CYISignal | Ready |
| CYISignal | Playing |
| CYISignal | Paused |
| CYISignal | PlaybackComplete |
| CYISignal | Finalized |
| CYISignal< uint64_t > | CurrentTimeUpdated |
| CYISignal< uint64_t > | DurationChanged |
| CYISignal< const CYIAbstractVideoPlayer::PlayerState & > | PlayerStateChanged |
| CYISignal< std::vector< AudioTrackInfo > > | AvailableAudioTracksChanged |
| CYISignal< std::vector< ClosedCaptionsTrackInfo > > | AvailableClosedCaptionsTracksChanged |
Protected Member Functions | |
| CYIAbstractVideoPlayer () | |
| const std::shared_ptr< CYIMaterial > & | GetVideoMaterial () const |
| void | SetVideoSurfaceSize (const glm::ivec2 &size) |
| void | ChangeInitialPlaybackState (CYIAbstractVideoPlayer::PLAYBACK_STATE eInitialState) |
| CYIAbstractVideoPlayer::PLAYBACK_STATE | GetRequestedInitialPlaybackState () const |
| void | CheckAndNotifyMediaTracksChanged () |
| void | UpdateCurrentTime () |
Protected Attributes | |
| CYISignal< Error > | NotifyErrorOccurred |
| CYISignal | NotifyPlaybackComplete |
| CYISignal< uint64_t > | NotifyDurationChanged |
| std::unique_ptr< CYIVideoPlayerStateManager > | m_pStateManager |
| std::unique_ptr< CYIClosedCaptionsDispatcher > | m_pClosedCaptionsDispatcher |
| std::shared_ptr< DRMConfiguration > | m_pDRMConfiguration |
| uint64_t | m_uMaxBitrate |
Friends | |
| class | CYIVideoPlayerStateManager |
| class | TimeUpdater |
| using CYIAbstractVideoPlayer::VideoMetadata = std::map<CYIString, CYIString> |
Alias type for metadata associated with video.
Enumeration of available DRM schemes.
| Enumerator | |
|---|---|
| DRM_NONE | |
| DRM_FAIRPLAY | |
| DRM_PLAYREADY | |
| DRM_WIDEVINE_MODULAR | |
Enumeration of the possible errors which the player can emit.
| Enumerator | |
|---|---|
| PLAYBACK_ERROR |
Indicates that an error occurred during playback of the video media. This may occur at anytime which the media state is not CYIAbstractVideoPlayer::MEDIA_UNLOADED. |
| UNSUPPORTED_FORMAT |
Indicates that the combination of eFormatHint and pDRMConfiguration provided to Prepare() is not supported by the current player/platform. |
| STATE_TRANSITION_ERROR |
Indicates that the player has transitioned into an invalid state.
|
| DRM_ERROR | |
| UNKNOWN |
< Indicates that an error occured when attempting to process DRM protected content. Indicates that an unknown error has occurred in the player. |
Enumeration of the states relating to the preparation of media for the video player.
| Enumerator | |
|---|---|
| MEDIA_UNLOADED |
Represents that no video media is currently loaded into the player for playback. This is the default media state for the player.
|
| MEDIA_PREPARING |
Represents that the video media has been provided to the player and is in the process of being loaded for playback. |
| MEDIA_READY |
Represents that the video media is loaded into the player and ready for playback. When the player is in this state the player will also have a valid CYIAbstractVideoPlayer::PLAYBACK_STATE.
|
Enumeration of the states relating to the current media playback state for the video player. These states are only relevant when the player's media state is CYIAbstractVideoPlayer::MEDIA_READY.
Enumeration of available video media streaming formats.
| Enumerator | |
|---|---|
| HLS | |
| SMOOTH | |
| DASH | |
| MP4 | |
|
virtual |
|
protected |
| bool CYIAbstractVideoPlayer::AreAudioTracksAvailable | ( | ) | const |
Returns true if the audio tracks for the current media have been loaded. Returns false if the tracks are currently unavailable.
| bool CYIAbstractVideoPlayer::AreClosedCaptionsTracksAvailable | ( | ) | const |
Returns true if the closed captions tracks for the current media have been loaded. Returns false if the tracks are currently unavailable.
Once tracks become available they can be selected at which point they will begin rendering.
|
protected |
Changes the playback state which the player will be in when media is loaded and in the CYIAbstractVideoPlayer::MEDIA_READY state.
|
protected |
Queries audio and closed captioning track availability and emits CYIAbstractVideoPlayer::AvailableAudioTracksChanged and CYIAbstractVideoPlayer::AvailableClosedCaptionsTracksChanged respectively if applicable. Is called each 1000 ms if the player has been prepared and has not been stopped, but can be called manually to check and notify at any time.
| AudioTrackInfo CYIAbstractVideoPlayer::GetActiveAudioTrack | ( | ) | const |
Returns information about the audio track which is currently selected.
If the media has no audio tracks or if audio tracks are unavailable this method will return an AudioTrackInfo that has AudioTrackInfo::bIsValid set to false.
| ClosedCaptionsTrackInfo CYIAbstractVideoPlayer::GetActiveClosedCaptionsTrack | ( | ) | const |
Returns information about the closed captions track which is currently selected.
If the media has no closed captions tracks or if closed captions tracks are unavailable this method will return a ClosedCaptionsTrackInfo that has a ClosedCaptionsTrackInfo::uID of ClosedCaptionsTrackInfo::OFF_TRACK_ID.
| std::vector<AudioTrackInfo> CYIAbstractVideoPlayer::GetAudioTracks | ( | ) | const |
Returns information about the audio tracks for the currently loaded media.
These may become available at any point during preparation and playback. This API reflects what is currently available from the media. Connect to CYIAbstractVideoPlayer::AudioTracksAvailabilityChanged to get the tracks as soon as they are available.
If the video does not have any audio tracks, then a vector of size 0 is returned.
| CYIClosedCaptionsDispatcher* CYIAbstractVideoPlayer::GetClosedCaptionsDispatcher | ( | ) | const |
| std::vector<ClosedCaptionsTrackInfo> CYIAbstractVideoPlayer::GetClosedCaptionsTracks | ( | ) | const |
Returns information about the closed captions tracks for the currently loaded media.
These may become available at any point during preparation and playback. This API reflects what is currently available from the media. Connect to CYIAbstractVideoPlayer::AvailableClosedCaptionsTracksChanged to get the tracks as soon as they are available.
A track with special value ClosedCaptionsTrackInfo::OFF_TRACK_ID is always present and is used to disable closed captions rendering.
| uint64_t CYIAbstractVideoPlayer::GetCurrentTimeMs | ( | ) | const |
Returns the current playback time of the video in milliseconds. Returns 0 prior to the emission of the CYIAbstractVideoPlayer::DurationChanged signal for the current video media.
| const DRMConfiguration* CYIAbstractVideoPlayer::GetDRMConfiguration | ( | ) | const |
Returns the current DRM configuration that was provided when the player was prepared.
| DRMConfiguration* CYIAbstractVideoPlayer::GetDRMConfiguration | ( | ) |
Returns the current DRM configuration that was provided when the player was prepared.
| uint64_t CYIAbstractVideoPlayer::GetDurationMs | ( | ) | const |
Returns the duration of the video in milliseconds. Returns 0 if the player is in the CYIAbstractVideoPlayer::MEDIA_UNLOADED state.
| CYIString CYIAbstractVideoPlayer::GetName | ( | ) | const |
Returns the name of the player.
| CYIAbstractVideoPlayer::PlayerState CYIAbstractVideoPlayer::GetPlayerState | ( | ) | const |
Returns the current state of the player.
|
protected |
Returns the initial playback state requested when media was loaded with Prepare().
| Statistics CYIAbstractVideoPlayer::GetStatistics | ( | ) | const |
Returns the latest statistics from the player.
| CYIVideoSurface* CYIAbstractVideoPlayer::GetSurface | ( | ) | const |
Returns the player surface into which the video is being rendered. This is owned by the player and must not be deleted or retained independently.
| CYIString CYIAbstractVideoPlayer::GetVersion | ( | ) | const |
Returns the version of the player.
|
protected |
Returns the material associated with the player's CYIVideoSurface. If the CYIVideoSurface::GetCapabilities() reports that it does not render to texture this will be null.
| void CYIAbstractVideoPlayer::Init | ( | ) |
Initializes the player and its video surface.
| bool CYIAbstractVideoPlayer::IsMuted | ( | ) | const |
| void CYIAbstractVideoPlayer::Mute | ( | bool | bMute | ) |
Mute the player, so that no audio is played. By default the player is not muted.
| void CYIAbstractVideoPlayer::Pause | ( | ) |
Pauses video playback.
| void CYIAbstractVideoPlayer::Play | ( | ) |
Starts the playback of the prepared video asset, or resumes playback if the player is paused.
| void CYIAbstractVideoPlayer::Prepare | ( | const CYIUrl & | videoURI, |
| STREAMING_FORMAT | eFormatHint, | ||
| CYIAbstractVideoPlayer::PLAYBACK_STATE | eInitialState = CYIAbstractVideoPlayer::PLAYBACK_PAUSED, |
||
| std::unique_ptr< DRMConfiguration > | pDRMConfiguration = nullptr |
||
| ) |
Prepares the player with the provided video file at videoURI.
The eFormatHint and the scheme of the pDRMConfiguration will be validated against the player. If the player does not support the specified format/DRM scheme, a CYIAbstractVideoPlayer::UNSUPPORTED_FORMAT error will be emitted. If the format hint does not match the actual content of the URI, then the player may encounter a playback error or proceed without any error.
If the prepare operation was successful the player will transition into the CYIAbstractVideoPlayer::MEDIA_READY state. eInitialState represents the state the player will be in after Prepare() completes.
| void CYIAbstractVideoPlayer::Prepare | ( | const std::shared_ptr< CYIAssetVideo > & | videoAsset, |
| STREAMING_FORMAT | eFormatHint, | ||
| CYIAbstractVideoPlayer::PLAYBACK_STATE | eInitialState = CYIAbstractVideoPlayer::PLAYBACK_PAUSED, |
||
| std::unique_ptr< DRMConfiguration > | pDRMConfiguration = nullptr |
||
| ) |
Prepares the player with the provided video file at videoAsset. If videoAsset is null, an error will be reported.
| void CYIAbstractVideoPlayer::Seek | ( | uint64_t | uSeekPositionMs | ) |
Seek to uSeekPositionMs in the video, in milliseconds.
| bool CYIAbstractVideoPlayer::SelectAudioTrack | ( | uint32_t | uID | ) |
Switches the video player's audio to the track indicated by the given uID.
If the video is playing, playback will not be stopped during the switch.
Returns true if the track exists and was successfully selected.
Returns false if no track with uID is available.
| bool CYIAbstractVideoPlayer::SelectClosedCaptionsTrack | ( | uint32_t | uID | ) |
Switches the video player's closed captions track to the track indicated by the given uID.
If the video is playing, playback will not be stopped during the switch.
Returns true if the track exists and was successfully selected, note that selection may take time to take effect. ClosedCaptionsTrackInfo::OFF_TRACK_ID is a special value used to disable closed captions rendering.
Returns false if no track with uID is available, or if uID is not ClosedCaptionsTrackInfo::OFF_TRACK_ID.
| void CYIAbstractVideoPlayer::SetMaxBitrate | ( | uint64_t | uMaxBitrate | ) |
Sets the maximum bitrate to uMaxBitrate, in bits per second, which the player will use when streaming from an adaptive media source. By default there is no bitrate restriction applied.
| void CYIAbstractVideoPlayer::SetUserAgent | ( | const CYIString & | userAgent | ) |
Set the user agent to be used by the player for requests on manifests and video segments.
| void CYIAbstractVideoPlayer::SetVideoMetadata | ( | const CYIAbstractVideoPlayer::VideoMetadata & | metadata | ) |
|
protected |
Sets the video surface size, in pixels.
| void CYIAbstractVideoPlayer::Stop | ( | ) |
Stops the video playback. This will unload the current video and set the player into the CYIAbstractVideoPlayer::MEDIA_UNLOADED state.
| bool CYIAbstractVideoPlayer::SupportsFormat | ( | STREAMING_FORMAT | eStreamingFormat, |
| DRM_SCHEME | eDRMScheme = DRM_NONE |
||
| ) |
Query the player to determine if eStreamingFormat and eDRMScheme combination is supported by the player. Returns true if the provided format and DRM scheme combination is supported by the player.
|
protected |
Refreshes the playback time internal to the CYIAbstractVideoPlayer. Emits CYIAbstractVideoPlayer::CurrentTimeUpdated and calls the associated caption render's IYIClosedCaptionsRenderer::OnVideoTimeUpdated if the time has changed since the last time this method was called.
|
friend |
|
friend |
| CYISignal<std::vector<AudioTrackInfo> > CYIAbstractVideoPlayer::AvailableAudioTracksChanged |
Signals that the available audio tracks for the current media have changed. This may be emitted at any point.
| CYISignal<std::vector<ClosedCaptionsTrackInfo> > CYIAbstractVideoPlayer::AvailableClosedCaptionsTracksChanged |
Signals that the available closed captions tracks for the current media have changed. This may be emitted at any point.
| CYISignal CYIAbstractVideoPlayer::BufferingEnded |
Player buffering ended notification. An application can clear a buffering indicator, if one has been displayed, when this signal is emitted. After this signal is emitted the player will be in the CYIAbstractVideoPlayer::PLAYBACK_PLAYING or CYIAbstractVideoPlayer::PLAYBACK_PAUSED state depending on the state the player was in prior to entering the CYIAbstractVideoPlayer::PLAYBACK_BUFFERING state.
| CYISignal CYIAbstractVideoPlayer::BufferingStarted |
Player buffering started notification. An application can display a buffering indicator when this signal is emitted. After this signal is emitted the player will be in the CYIAbstractVideoPlayer::PLAYBACK_BUFFERING state.
| CYISignal<uint64_t> CYIAbstractVideoPlayer::CurrentTimeUpdated |
Signals that the current time in the video playback has updated.
| CYISignal<uint64_t> CYIAbstractVideoPlayer::DurationChanged |
Signals that the duration of the loaded video media has changed. This typically occurs after loading new video media with a call to Prepare(). It is recommended to update the duration visible to the application user when this signal is emitted.
Player reported an error. An application can display an error notification his signal is emitted.
| CYISignal CYIAbstractVideoPlayer::Finalized |
Signals that the player has shutdown and cleaned up. On PlayStation 3 and PlayStation 4, the player will stall if deleted or prepared while already being stopped. It is recommanded to listen to this signal before doing so. On other platforms this signal is sent right away on Stop().
|
protected |
The closed captions dispatcher of this player. This is used to dispatch closed caption cues to the surface view's rendering scene node.
|
protected |
The DRM configuration that was provided to the player when CYIAbstractVideoPlayer::Prepare was called. This configuration will be provided when the media is DRM protected. Concrete player implementations must use this configuration to prepare the DRM protected media for playback.
|
protected |
The CYIAbstractVideoPlayer's instance of the CYIVideoPlayerStateManager. This is used to manage media and state transitions within the player.
|
protected |
The last known maximum bitrate.
|
protected |
Notifies the CYIAbstractVideoPlayer that the duration of the current video media has changed. This typically only occurs when the media is changed.
Notifies the CYIAbstractVideoPlayer that an error has occured, this will transition the player into the CYIAbstractVideoPlayer::MEDIA_UNLOADED state. The CYIAbstractVideoPlayer::Error object parameter should be populated with the error that has occured.
|
protected |
Notifies the CYIAbstractVideoPlayer that the video has reached the end of stream for the current video media.
| CYISignal CYIAbstractVideoPlayer::Paused |
Signals that playback has paused. After this signal is emitted the player will be in the CYIAbstractVideoPlayer::PLAYBACK_PAUSED state.
| CYISignal CYIAbstractVideoPlayer::PlaybackComplete |
Signals that the playback of the currently loaded video media has completed. After this signal is emitted the player will be in the CYIAbstractVideoPlayer::PLAYBACK_PAUSED state.
| CYISignal<const CYIAbstractVideoPlayer::PlayerState &> CYIAbstractVideoPlayer::PlayerStateChanged |
Signals that the internal player state has changed.
| CYISignal CYIAbstractVideoPlayer::Playing |
Signals that playback has began. This can either be the initial playback or playback resuming after CYIAbstractVideoPlayer::PLAYBACK_PAUSED or CYIAbstractVideoPlayer::PLAYBACK_BUFFERING states. After this signal is emitted the player will be in the CYIAbstractVideoPlayer::PLAYBACK_PLAYING state.
| CYISignal CYIAbstractVideoPlayer::Preparing |
Signals that the the player has started preparing a video for playback. This occurs after a call to Prepare() given the provided video format is supported by the target platform. After this signal is emitted the player will be in the CYIAbstractVideoPlayer::MEDIA_PREPARING state.
| CYISignal CYIAbstractVideoPlayer::Ready |
Signals that the call to Prepare() was successful. The video is ready to be interacted with and information about the video can be queried. After this signal is emitted the player will be in the CYIAbstractVideoPlayer::MEDIA_READY state.