FMediaPlayerFacade

Facade for low-level media player objects.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

MediaUtils

Header

/Engine/Source/Runtime/MediaUtils/Public/MediaPlayerFacade.h

Include

#include "MediaPlayerFacade.h"

Syntax

class FMediaPlayerFacade :
    public IMediaClockSink,
    public IMediaTickable,
    protected IMediaEventSink,
    public TSharedFromThis< FMediaPlayerFacade, ESPMode::ThreadSafe >

Remarks

Facade for low-level media player objects.

The purpose of this class is to provide a simpler interface to low-level media player implementations. It implements common functionality, such as translating between time codes and play times, and manages the selection and creation of player implementations for a given media source.

Note that, unlike the low-level methods in IMediaTracks, most track and track format related methods in this class allow for INDEX_NONE to be used as track and format indices in order to indicate the 'current selection'.

Variables

Name Description

Public variable

TOptional< FMed...

 

ActivePlayerOptions

Active media player options.

Public variable

FName

 

DesiredPlayerName

Name of the desired native player, if any.

Public variable

FTimespan

 

TimeDelay

Extra time to reduce from current player's time.

Constructors

Name Description

Public function

FMediaPlayerFacade()

Default constructor.

Destructors

Name Description

Public function Virtual

~FMediaPlayerFacade()

Virtual destructor.

Functions

Name Description

Public function

void

 

AddAudioSampleSink

(
    const TSharedRef< FMediaAudioSample...
)

Add the given audio sample sink to this player.

Public function

void

 

AddCaptionSampleSink

(
    const TSharedRef< FMediaOverlaySamp...
)

Add the given audio sample sink to this player.

Public function

void

 

AddMetadataSampleSink

(
    const TSharedRef< FMediaBinarySampl...
)

Add the given audio sample sink to this player.

Public function

void

 

AddSubtitleSampleSink

(
    const TSharedRef< FMediaOverlaySamp...
)

Add the given audio sample sink to this player.

Public function

void

 

AddVideoSampleSink

(
    const TSharedRef< FMediaTextureSamp...
)

Add the given audio sample sink to this player.

Protected function Const

bool

 

BlockOnFetch()

Whether sample fetching should block.

Public function Const

bool

 

CanPause()

Whether playback can be paused.

Public function

bool

 

CanPlayUrl

(
    const FString& Url,
    const IMediaOptions* Options
)

Whether the specified URL can be played by this player.

Public function Const

bool

 

CanResume()

Whether playback can be resumed.

Public function Const

bool

 

CanScrub()

Whether playback can be scrubbed.

Public function Const

bool

 

CanSeek()

Whether playback can jump to a position.

Public function

void

 

Close()

Close the currently open media, if any.

Protected function

void

 

FlushSinks()

Flush all media sample sinks.

Public function Const

uint32

 

GetAudioTrackChannels

(
    int32 TrackIndex,
    int32 FormatIndex
)

Get the number of channels in the specified audio track.

Protected function Const

bool

 

GetAudioTrackFormat

(
    int32 TrackIndex,
    int32 FormatIndex,
    FMediaAudioTrackFormat& OutFormat
)

Get details about the specified audio track format.

Public function Const

uint32

 

GetAudioTrackSampleRate

(
    int32 TrackIndex,
    int32 FormatIndex
)

Get the sample rate of the specified audio track.

Public function Const

FString

 

GetAudioTrackType

(
    int32 TrackIndex,
    int32 FormatIndex
)

Get the type of the specified audio track format.

Public function Const

FTimespan

 

GetDuration()

Get the media's duration.

Public function

const FGuid ...

 

GetGuid()

Get the player's globally unique identifier.

Public function Const

FString

 

GetInfo()

Get debug information about the player and currently opened media.

Public function Const

FTimespan

 

GetLastAudioRenderedSampleTime()

Get time of last audio sample played

Public function Const

FTimespan

 

GetLastAudioSampleProcessedTime()

Get time of last audio sample decoded

Public function Const

FTimespan

 

GetLastVideoSampleProcessedTime()

Get time of last video sample decoded

Public function Const

FText

 

GetMediaName()

Get the human readable name of the currently loaded media source.

Public function Const

int32

 

GetNumTrackFormats

(
    EMediaTrackType TrackType,
    int32 TrackIndex
)

Get the number of formats of the specified track.

Public function Const

int32

 

GetNumTracks

(
    EMediaTrackType TrackType
)

Get the number of tracks of the given type.

Public function Const

TSharedPtr< ...

 

GetPlayer()

Get the low-level player associated with this object.

Protected function

TSharedPtr< ...

 

GetPlayerForUrl

(
    const FString& Url,
    const IMediaOptions* Options
)

Get a player that can play the specified media URL.

Public function Const

FName

 

GetPlayerName()

Get the name of the current native media player.

Public function Const

float

 

GetRate()

Get the media's current playback rate.

Public function Const

int32

 

GetSelectedTrack

(
    EMediaTrackType TrackType
)

Get the index of the currently selected track of the given type.

Public function Const

FString

 

GetStats()

Get playback statistics information.

Public function Const

TRangeSet< f...

 

GetSupportedRates

(
    bool Unthinned
)

Get the supported playback rates.

Public function Const

FTimespan

 

GetTime()

Get the media's current playback time.

Public function Const

FText

 

GetTrackDisplayName

(
    EMediaTrackType TrackType,
    int32 TrackIndex
)

Get the human readable name of the specified track.

Public function Const

int32

 

GetTrackFormat

(
    EMediaTrackType TrackType,
    int32 TrackIndex
)

Get the index of the active format of the specified track.

Public function Const

FString

 

GetTrackLanguage

(
    EMediaTrackType TrackType,
    int32 TrackIndex
)

Get the language tag of the specified track.

Public function Const

const FStrin...

 

GetUrl()

Get the URL of the currently loaded media, if any.

Public function Const

float

 

GetVideoTrackAspectRatio

(
    int32 TrackIndex,
    int32 FormatIndex
)

Get the aspect ratio of the specified video track.

Public function Const

FIntPoint

 

GetVideoTrackDimensions

(
    int32 TrackIndex,
    int32 FormatIndex
)

Get the width and height of the specified video track.

Protected function Const

bool

 

GetVideoTrackFormat

(
    int32 TrackIndex,
    int32 FormatIndex,
    FMediaVideoTrackFormat& OutFormat
)

Get details about the specified audio track format.

Public function Const

float

 

GetVideoTrackFrameRate

(
    int32 TrackIndex,
    int32 FormatIndex
)

Get frame rate of the specified video track.

Public function Const

TRange< floa...

 

GetVideoTrackFrameRates

(
    int32 TrackIndex,
    int32 FormatIndex
)

Get the supported range of frame rates of the specified video track.

Public function Const

FString

 

GetVideoTrackType

(
    int32 TrackIndex,
    int32 FormatIndex
)

Get the type of the specified video track format.

Public function Const

bool

 

GetViewField

(
    float& OutHorizontal,
    float& OutVertical
)

Get the field of view.

Public function Const

bool

 

GetViewOrientation

(
    FQuat& OutOrientation
)

Get the view's orientation.

Public function Const

bool

 

HasError()

Check whether the player is in an error state.

Public function Const

bool

 

IsBuffering()

Whether the player is currently buffering data.

Public function Const

bool

 

IsClosed()

Whether media is currently closed.

Public function Const

bool

 

IsConnecting()

Whether the player is currently connecting to a media source.

Public function Const

bool

 

IsLooping()

Whether playback is looping.

Public function Const

bool

 

IsPaused()

Whether playback is currently paused.

Public function Const

bool

 

IsPlaying()

Whether playback is in progress.

Public function Const

bool

 

IsPreparing()

Whether the media is currently opening or buffering.

Public function Const

bool

 

IsReady()

Whether media is ready for playback.

Public function

FMediaPlayer...

 

OnMediaEvent()

Public function

bool

 

Open

(
    const FString& Url,
    const IMediaOptions* Options,
    const FMediaPlayerOptions* Pla...
)

Open a media source from a URL with optional parameters.

Protected function

void

 

ProcessAudioSamples

(
    IMediaSamples& Samples,
    TRange< FTimespan > TimeRange
)

Fetch audio samples from the player and forward them to the registered sinks.

Protected function

void

 

ProcessCaptionSamples

(
    IMediaSamples& Samples,
    TRange< FTimespan > TimeRange
)

Fetch audio samples from the player and forward them to the registered sinks.

Protected function

void

 

ProcessEvent

(
    EMediaEvent Event
)

Process the given media event.

Protected function

void

 

ProcessMetadataSamples

(
    IMediaSamples& Samples,
    TRange< FTimespan > TimeRange
)

Fetch metadata samples from the player and forward them to the registered sinks.

Protected function

void

 

ProcessSubtitleSamples

(
    IMediaSamples& Samples,
    TRange< FTimespan > TimeRange
)

Fetch subtitle samples from the player and forward them to the registered sinks.

Protected function

void

 

ProcessVideoSamples

(
    IMediaSamples& Samples,
    TRange< FTimespan > TimeRange
)

Fetch video samples from the player and forward them to the registered sinks.

Public function Const

void

 

QueryCacheState

(
    EMediaTrackType TrackType,
    EMediaCacheState State,
    TRangeSet< FTimespan >& OutTimeRan...
)

Query the time ranges of cached media samples for the specified caching state.

Public function

bool

 

Seek

(
    const FTimespan& Time
)

Seeks to the specified playback time.

Protected function

void

 

SelectDefaultTracks()

Select the default media tracks.

Public function

bool

 

SelectTrack

(
    EMediaTrackType TrackType,
    int32 TrackIndex
)

Select the active track of the given type.

Public function

void

 

SetBlockOnTime

(
    const FTimespan& Time
)

Set the time on which to block.

Public function

void

 

SetCacheWindow

(
    FTimespan Ahead,
    FTimespan Behind
)

Set sample caching options.

Public function

void

 

SetGuid

(
    FGuid& Guid
)

Set the player's globally unique identifier.

Public function

void

 

SetLastAudioRenderedSampleTime

(
    FTimespan SampleTime
)

Record last audio sample played to track audio sync (for automated tests)

Public function

bool

 

SetLooping

(
    bool Looping
)

Enables or disables playback looping.

Public function

void

 

SetMediaOptions

(
    const IMediaOptions* Options
)

Changes media ooptions on the player.

Public function

bool

 

SetNativeVolume

(
    float Volume
)

Changes the media's native volume.

Public function

bool

 

SetRate

(
    float Rate
)

Changes the media's playback rate.

Public function

bool

 

SetTrackFormat

(
    EMediaTrackType TrackType,
    int32 TrackIndex,
    int32 FormatIndex
)

Set the format on the specified track.

Public function

bool

 

SetVideoTrackFrameRate

(
    int32 TrackIndex,
    int32 FormatIndex,
    float FrameRate
)

Set the frame rate of the specified video track.

Public function

bool

 

SetViewField

(
    float Horizontal,
    float Vertical,
    bool Absolute
)

Set the field of view.

Public function

bool

 

SetViewOrientation

(
    const FQuat& Orientation,
    bool Absolute
)

Set the view's orientation.

Public function Const

bool

 

SupportsRate

(
    float Rate,
    bool Unthinned
)

Whether the specified playback rate is supported.

Overridden from IMediaClockSink

Name Description

Public function Virtual

void

 

TickFetch

(
    FTimespan DeltaTime,
    FTimespan Timecode
)

Called each tick to handle updates after the Engine ticked.

Public function Virtual

void

 

TickInput

(
    FTimespan DeltaTime,
    FTimespan Timecode
)

Called each tick to handle input before the Engine is ticked.

Public function Virtual

void

 

TickOutput

(
    FTimespan DeltaTime,
    FTimespan Timecode
)

Called each tick to output the rendered frame.

Overridden from IMediaTickable

Name Description

Public function Virtual

void

 

TickTickable()

Tick the object.

Overridden from IMediaEventSink

Name Description

Protected function Virtual

void

 

ReceiveMediaEvent

(
    EMediaEvent Event
)

Receive the given media event.

Classes

Name

Description

Public class

FOnMediaEvent

Get an event delegate that is invoked when a media event occurred.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss