Table of Contents

Class BaseMediaPlayer

Namespace
RenderHeads.Media.AVProVideo
Assembly
AVProVideo.Runtime.dll

Base class for all platform specific MediaPlayers

public abstract class BaseMediaPlayer : IVideoTracks, IAudioTracks, ITextTracks, IMediaPlayer, IMediaControl, IMediaInfo, IMediaCache, ITextureProducer, IMediaSubtitles, IBufferedDisplay
Inheritance
object
BaseMediaPlayer
Implements
Derived

Constructors

Name Description
BaseMediaPlayer()

Fields

Name Description
_audioTracks
_bufferedTimes
_currentSubtitle
_currentTextCue
_defaultTextureAnisoLevel
_defaultTextureFilterMode
_defaultTextureWrapMode
_lastError
_mediaHints
_playbackQualityStats
_playerDescription
_seekableTimes
_subtitles
_textTracks
_trackCollections
_videoTracks

Methods

Name Description
AddChunkToMediaBuffer(byte[], ulong, ulong)
AddMediaToCache(string, string, MediaCachingOptions)

Cache the media specified by url.

ApplyTextureProperties(Texture)
AudioConfigurationChanged(bool)
BeginRender()
CanPlay()
CancelDownloadOfMediaToCache(string)

Cancels the download of the media specified by url.

CloseMedia()
Dispose()
EndOpenMediaFromBuffer()
EndUpdate()
GetActiveAudioTrack()
GetActiveTextTrack()
GetActiveVideoTrack()
GetAffineTransform()

The affine transform of the texture as an array of six floats: [a, b, c, d, tx, ty].

GetAudioBufferedSampleCount()
GetAudioChannelCount()
GetAudioChannelMask()
GetAudioTracks()
GetBalance()
GetBufferedFramesState()
GetBufferedTimes()

Returns a range of time values that contain fully downloaded segments, which can be seeked to immediately without requiring additional downloading

GetCachedMediaStatus(string, ref float)

Get the cached status for the media specified.

GetCurrentTextCue()
GetCurrentTime()

Returns the current video time in seconds

GetCurrentTimeFrames(float)

Returns the current video time in frames, range is [0, GetMaxFrameNumber()] NOTE: For best results the video should be encoded as keyframes only and have no audio track, or an audio track with the same length as the video track

GetDecoderPerformance(ref int, ref int, ref int)
GetDuration()

Returns media duration in seconds

GetDurationFrames(float)

Returns media duration in frames NOTE: For best results the video should be encoded as keyframes only and have no audio track, or an audio track with the same length as the video track

GetEstimatedTotalBandwidthUsed()

Gets the estimated bandwidth used by all video players (in bits per second) Currently only supported on Android when using ExoPlayer API

GetExpectedVersion()
GetLastError()
GetLastExtendedErrorCode()
GetMaxFrameNumber(float)

Returns highest frame number that can be seeked to NOTE: For best results the video should be encoded as keyframes only and have no audio track, or an audio track with the same length as the video track

GetNativePlayerHandle()
GetPlaybackQualityStats()
GetPlaybackRate()
GetPlayerDescription()

Returns the a description of which playback path is used internally. This can for example expose whether CPU or GPU decoding is being performed For Windows the available player descriptions are: "DirectShow" - legacy Microsoft API but still very useful especially with modern filters such as LAV "MF-MediaEngine-Software" - uses the Windows 8.1 features of the Microsoft Media Foundation API, but software decoding "MF-MediaEngine-Hardware" - uses the Windows 8.1 features of the Microsoft Media Foundation API, but GPU decoding Android has "MediaPlayer" and "ExoPlayer" macOS / tvOS / iOS just has "AVFoundation"

GetProgramDateTime()

Returns the current video date and time usually from the EXT-X-PROGRAM-DATE-TIME tag on HLS streams Only supported on macOS, iOS, tvOS and Android (using ExoPlayer API) And Windows 10 using WinRT API

GetSeekableTimes()

Returns a range of time values that can be seeked in seconds

GetSubtitleIndex()
GetSubtitleText()
GetTextTracks()
GetTexture(int)

Returns the Unity texture containing the current frame image. The texture pointer will return null while the video is loading This texture usually remains the same for the duration of the video. There are cases when this texture can change, for instance: if the graphics device is recreated, a new video is loaded, or if an adaptive stream (eg HLS) is used and it switches video streams.

GetTextureAlphaPacking()

Returns the type of packing used for alpha content

GetTextureCount()

Gets the number of textures produced by the media player.

GetTextureFrameCount()

Returns a count of how many times the texture has been updated

GetTextureMatrix()

The full 4x4 transform of the texture

GetTexturePixelAspectRatio()

Returns the DAR/SAR ratio

GetTextureProperties(out FilterMode, out TextureWrapMode, out int)
GetTextureStereoPacking()

Returns the type of packing used for stereo content

GetTextureTimeStamp()

Returns the presentation time stamp of the current texture

GetTextureTransform()

The affine transform of the texture as an array of six floats: a, b, c, d, tx, ty.

GetTextureTransparency()

Returns the whether the texture has transparency

GetVersion()
GetVideoDisplayRate()

Returns the current achieved display rate in frames per second

GetVideoFrameRate()

Returns the frame rate of the media.

GetVideoHeight()

Returns video height in pixels

GetVideoTracks()
GetVideoWidth()

Returns video width in pixels

GetVolume()
GetYpCbCrTransform()

Returns the current transformation required to convert from YpCbCr to RGB colorspaces.

GrabAudio(float[], int, int)

Copies the specified amount of audio into the buffer If the specified amount is not yet available then nothing no samples are copied The number of audio samples grabbed are returned

HasAudio()

Returns true if the media has a audio track

HasMetaData()
HasVideo()

Returns true if the media has a visual track

IsBuffering()
IsExpectingNewVideoFrame()
IsExternalPlaybackActive()

Check to see if external playback is currently active on the player.

IsExternalPlaybackSupported()

Checks if the media is compatible with external playback, for instance via AirPlay.

IsFinished()
IsLooping()
IsMediaCachingSupported()

Test to see if the player can cache media.

IsMuted()
IsPaused()
IsPlaybackStalled()

Checks if the playback is in a stalled state

IsPlaying()
IsSeeking()
IsVideoStereo()
LoadSubtitlesSRT(string)
MuteAudio(bool)
OnEnable()
OpenMedia(string, long, string, MediaHints, int, bool)

Be careful using this method directly. It is best to instead use the OpenMedia() method in the MediaPlayer component as this will set up the events correctly and also perform other checks customHttpHeaders is in the format "key1:value1\r\nkey2:value2\r\n"=

OpenMediaFromBuffer(byte[])
Pause()
PauseDownloadOfMediaToCache(string)

Pause the download of the media specified by url.

Play()
PlayerSupportsLinearColorSpace()

Whether this MediaPlayer instance supports linear color space If it doesn't then a correction may have to be made in the shader

RemoveMediaFromCache(string)

Remove the cached media specified by url.

Render()
RequiresVerticalFlip()

Returns true if the image on the texture is upside-down

ResetAudioFocus()
ResetAudioHeadRotation()
ResumeDownloadOfMediaToCache(string)

Resume the download of the media specified by url.

Rewind()
Seek(double)

The time in seconds seeked will be to the exact time This can take a long time is the keyframes are far apart Some platforms don't support this and instead seek to the closest keyframe

SeekFast(double)

The time in seconds seeked will be to the closest keyframe

SeekToFrame(int, float)

Seek to a specific frame, range is [0, GetMaxFrameNumber()] NOTE: For best results the video should be encoded as keyframes only and have no audio track, or an audio track with the same length as the video track

SeekToFrameRelative(int, float)

Seek forwards or backwards relative to the current frame NOTE: For best results the video should be encoded as keyframes only and have no audio track, or an audio track with the same length as the video track

SeekWithTolerance(double, double, double)

The time in seconds seeked to will be within the range [time-timeDeltaBefore, time+timeDeltaAfter] for efficiency. Only supported on macOS, iOS and tvOS. Other platforms will automatically pass through to Seek()

SetActiveAudioTrack(AudioTrack)
SetActiveTextTrack(TextTrack)
SetActiveVideoTrack(VideoTrack)
SetAllowsExternalPlayback(bool)

Set whether the player is allowed to switch to external playback, e.g. AirPlay.

SetAudioChannelMode(Audio360ChannelMode)
SetAudioFocusEnabled(bool)
SetAudioFocusProperties(float, float)
SetAudioFocusRotation(Quaternion)
SetAudioHeadRotation(Quaternion)
SetBalance(float)
SetBufferedDisplayMode(BufferedFrameSelectionMode, IBufferedDisplay)
SetBufferedDisplayOptions(bool)
SetExternalPlaybackVideoGravity(ExternalPlaybackVideoGravity)

Sets the video gravity of the player for external playback only.

SetKeyServerAuthToken(string)
SetLooping(bool)
SetOverrideDecryptionKey(byte[])
SetPlayWithoutBuffering(bool)
SetPlaybackRate(float)
SetSlaves(IBufferedDisplay[])
SetTextureProperties(FilterMode, TextureWrapMode, int)
SetVolume(float)
StartOpenMediaFromBuffer(ulong)
Stop()
SupportsTextureFrameCount()

Returns whether this platform supports counting the number of times the texture has been updated

Update()
UpdateBufferedDisplay()

We need to manually call UpdateBufferedDisplay() in the case of master-slave synced playback so that master is updated before slaves

UpdateDisplayFrameRate()
UpdateSubtitles()
UpdateTextCue(bool)
UpdateTracks()
WaitForNextFrame(Camera, int)