Class BaseMediaPlayer
Base class for all platform specific MediaPlayers
Inheritance
System.Object
BaseMediaPlayer
Implements
System.Collections.Generic.IEnumerable
System.IDisposable
Assembly: cs.temp.dll.dll
public abstract class BaseMediaPlayer : IMediaPlayer, IMediaControl, IMediaInfo, IMediaCache, ITextureProducer, IMediaSubtitles, IVideoTracks, IAudioTracks, ITextTracks, ITimedMetadata, IVariants, IDisposable
Constructors
Declaration
Properties
Declaration
public int Count { get; }
Property Value
| Type |
Description |
| System.Int32 |
|
Declaration
public Variant Current { get; }
Property Value
Declaration
public Variant this[int index] { get; }
Parameters
| Type |
Name |
Description |
| System.Int32 |
index |
|
Property Value
Methods
Declaration
public virtual bool AddChunkToMediaBuffer(byte[] chunk, ulong offset, ulong length)
Parameters
| Type |
Name |
Description |
| System.Byte[] |
chunk |
|
| System.UInt64 |
offset |
|
| System.UInt64 |
length |
|
Returns
| Type |
Description |
| System.Boolean |
|
Cache the media specified by url.
Declaration
public virtual void AddMediaToCache(string url, string headers, MediaCachingOptions options)
Parameters
| Type |
Name |
Description |
| System.String |
url |
The url of the media.
|
| System.String |
headers |
|
| MediaCachingOptions |
options |
|
ApplyTextureProperties(Texture)
Declaration
protected virtual void ApplyTextureProperties(Texture texture)
Parameters
| Type |
Name |
Description |
| Texture |
texture |
|
Declaration
public virtual void AudioConfigurationChanged(bool deviceChanged)
Parameters
| Type |
Name |
Description |
| System.Boolean |
deviceChanged |
|
Declaration
public virtual void BeginRender()
Cancels the download of the media specified by url.
Declaration
public virtual void CancelDownloadOfMediaToCache(string url)
Parameters
| Type |
Name |
Description |
| System.String |
url |
The url of the media.
|
Declaration
public abstract bool CanPlay()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public virtual void CloseMedia()
Declaration
public abstract void Dispose()
Declaration
public virtual bool EndOpenMediaFromBuffer()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public virtual void EndUpdate()
Declaration
public AudioTrack GetActiveAudioTrack()
Returns
GetActiveTextTrack()
Declaration
public TextTrack GetActiveTextTrack()
Returns
Declaration
public VideoTrack GetActiveVideoTrack()
Returns
The affine transform of the texture as an array of six floats: [a, b, c, d, tx, ty].
Declaration
public virtual float[] GetAffineTransform()
Returns
| Type |
Description |
| System.Single[] |
|
Declaration
public virtual int GetAudioBufferedSampleCount()
Returns
| Type |
Description |
| System.Int32 |
|
Declaration
public virtual int GetAudioChannelCount()
Returns
| Type |
Description |
| System.Int32 |
|
Declaration
public virtual AudioChannelMaskFlags GetAudioChannelMask()
Returns
Declaration
public AudioTracks GetAudioTracks()
Returns
Declaration
public virtual float GetBalance()
Returns
| Type |
Description |
| System.Single |
|
Declaration
public TimeRanges GetBufferedTimes()
Returns
Get the cached status for the media specified.
Declaration
public virtual CachedMediaStatus GetCachedMediaStatus(string url, ref float progress)
Parameters
| Type |
Name |
Description |
| System.String |
url |
The url of the media.
|
| System.Single |
progress |
The amount of the media that has been cached in the range [0...1].
|
Returns
GetCompatibleRenderTextureFormat(GetCompatibleRenderTextureFormatOptions, Int32)
Get a render texture format that is compatible with the textures internal format
Declaration
public virtual RenderTextureFormat GetCompatibleRenderTextureFormat(GetCompatibleRenderTextureFormatOptions options, int plane)
Parameters
| Type |
Name |
Description |
| GetCompatibleRenderTextureFormatOptions |
options |
Any options that may change the choice of render texture format, defaults to None
|
| System.Int32 |
plane |
Index of the plane to get compatible render texture format for, defaults to the first plane
|
Returns
| Type |
Description |
| RenderTextureFormat |
A compatible render texture format
|
GetCurrentTextCue()
Declaration
public TextCue GetCurrentTextCue()
Returns
Returns the current video time in seconds
Declaration
public abstract double GetCurrentTime()
Returns
| Type |
Description |
| System.Double |
|
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
Declaration
public int GetCurrentTimeFrames(float overrideFrameRate = 0F)
Parameters
| Type |
Name |
Description |
| System.Single |
overrideFrameRate |
|
Returns
| Type |
Description |
| System.Int32 |
|
Declaration
public virtual bool GetDecoderPerformance(ref int activeDecodeThreadCount, ref int decodedFrameCount, ref int droppedFrameCount)
Parameters
| Type |
Name |
Description |
| System.Int32 |
activeDecodeThreadCount |
|
| System.Int32 |
decodedFrameCount |
|
| System.Int32 |
droppedFrameCount |
|
Returns
| Type |
Description |
| System.Boolean |
|
Returns media duration in seconds
Declaration
public abstract double GetDuration()
Returns
| Type |
Description |
| System.Double |
|
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
Declaration
public int GetDurationFrames(float overrideFrameRate = 0F)
Parameters
| Type |
Name |
Description |
| System.Single |
overrideFrameRate |
|
Returns
| Type |
Description |
| System.Int32 |
|
Declaration
public virtual IEnumerator GetEnumerator()
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerator |
|
Gets the estimated bandwidth used by all video players (in bits per second)
Currently only supported on Android when using ExoPlayer API
Declaration
public virtual long GetEstimatedTotalBandwidthUsed()
Returns
| Type |
Description |
| System.Int64 |
|
Declaration
public abstract string GetExpectedVersion()
Returns
| Type |
Description |
| System.String |
|
Declaration
public ErrorCode GetLastError()
Returns
GetLastExtendedErrorCode()
Declaration
public virtual long GetLastExtendedErrorCode()
Returns
| Type |
Description |
| System.Int64 |
|
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
Declaration
public int GetMaxFrameNumber(float overrideFrameRate = 0F)
Parameters
| Type |
Name |
Description |
| System.Single |
overrideFrameRate |
|
Returns
| Type |
Description |
| System.Int32 |
|
Declaration
public virtual IntPtr GetNativePlayerHandle()
Returns
Declaration
public PlaybackQualityStats GetPlaybackQualityStats()
Returns
Declaration
public abstract float GetPlaybackRate()
Returns
| Type |
Description |
| System.Single |
|
Declaration
public string GetPlayerDescription()
Returns
| Type |
Description |
| System.String |
|
Declaration
public virtual DateTime GetProgramDateTime()
Returns
| Type |
Description |
| DateTime |
|
Declaration
public TimeRanges GetSeekableTimes()
Returns
Declaration
public virtual Variant GetSelectedVariant()
Returns
Declaration
public virtual int GetSubtitleIndex()
Returns
| Type |
Description |
| System.Int32 |
|
GetSubtitleText()
Declaration
public virtual string GetSubtitleText()
Returns
| Type |
Description |
| System.String |
|
GetTextTrackArrayIndexFromUid(Int32)
Declaration
public int GetTextTrackArrayIndexFromUid(int Uid)
Parameters
| Type |
Name |
Description |
| System.Int32 |
Uid |
|
Returns
| Type |
Description |
| System.Int32 |
|
GetTextTracks()
Declaration
public TextTracks GetTextTracks()
Returns
GetTexture(Int32)
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.
Declaration
public abstract Texture GetTexture(int index = 0)
Parameters
| Type |
Name |
Description |
| System.Int32 |
index |
|
Returns
GetTextureAlphaPacking()
Declaration
public AlphaPacking GetTextureAlphaPacking()
Returns
GetTextureCount()
Gets the number of textures produced by the media player.
Declaration
public virtual int GetTextureCount()
Returns
| Type |
Description |
| System.Int32 |
|
GetTextureFrameCount()
Returns a count of how many times the texture has been updated
Declaration
public abstract int GetTextureFrameCount()
Returns
| Type |
Description |
| System.Int32 |
|
GetTextureMatrix()
The full 4x4 transform of the texture
Declaration
public virtual Matrix4x4 GetTextureMatrix()
Returns
| Type |
Description |
| Matrix4x4 |
|
GetTexturePixelAspectRatio()
Returns the DAR/SAR ratio
Declaration
public virtual float GetTexturePixelAspectRatio()
Returns
| Type |
Description |
| System.Single |
|
GetTextureProperties(out FilterMode, out TextureWrapMode, out Int32)
Declaration
public void GetTextureProperties(out FilterMode filterMode, out TextureWrapMode wrapMode, out int anisoLevel)
Parameters
| Type |
Name |
Description |
| FilterMode |
filterMode |
|
| TextureWrapMode |
wrapMode |
|
| System.Int32 |
anisoLevel |
|
GetTextureStereoPacking()
Declaration
public StereoPacking GetTextureStereoPacking()
Returns
GetTextureTimeStamp()
Returns the presentation time stamp of the current texture
Declaration
public virtual long GetTextureTimeStamp()
Returns
| Type |
Description |
| System.Int64 |
|
GetTextureTransform()
The affine transform of the texture as an array of six floats: a, b, c, d, tx, ty.
Declaration
public virtual float[] GetTextureTransform()
Returns
| Type |
Description |
| System.Single[] |
|
GetTextureTransparency()
Declaration
public virtual TransparencyMode GetTextureTransparency()
Returns
Declaration
public TimedMetadataItem GetTimedMetadataItem()
Returns
Declaration
public abstract string GetVersion()
Returns
| Type |
Description |
| System.String |
|
Returns the current achieved display rate in frames per second
Declaration
public virtual float GetVideoDisplayRate()
Returns
| Type |
Description |
| System.Single |
|
Returns the frame rate of the media.
Declaration
public abstract float GetVideoFrameRate()
Returns
| Type |
Description |
| System.Single |
|
Returns video height in pixels
Declaration
public abstract int GetVideoHeight()
Returns
| Type |
Description |
| System.Int32 |
|
Declaration
public VideoTracks GetVideoTracks()
Returns
Returns video width in pixels
Declaration
public abstract int GetVideoWidth()
Returns
| Type |
Description |
| System.Int32 |
|
Declaration
public abstract float GetVolume()
Returns
| Type |
Description |
| System.Single |
|
Returns the current transformation required to convert from YpCbCr to RGB colorspaces.
Declaration
public virtual Matrix4x4 GetYpCbCrTransform()
Returns
| Type |
Description |
| Matrix4x4 |
|
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
Declaration
public virtual int GrabAudio(float[] audioData, int audioDataFloatCount, int channelCount)
Parameters
| Type |
Name |
Description |
| System.Single[] |
audioData |
|
| System.Int32 |
audioDataFloatCount |
|
| System.Int32 |
channelCount |
|
Returns
| Type |
Description |
| System.Int32 |
|
Returns true if the media has a audio track
Declaration
public abstract bool HasAudio()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public abstract bool HasMetaData()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public bool HasNewTimedMetadataItem()
Returns
| Type |
Description |
| System.Boolean |
|
Returns true if the media has a visual track
Declaration
public abstract bool HasVideo()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
protected virtual TimedMetadataItem InternalGetTimedMetadataItem()
Returns
Declaration
protected virtual bool InternalHasUpdatedTimedMetadata()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public abstract bool IsBuffering()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
protected bool IsExpectingNewVideoFrame()
Returns
| Type |
Description |
| System.Boolean |
|
Check to see if external playback is currently active on the player.
Declaration
public virtual bool IsExternalPlaybackActive()
Returns
| Type |
Description |
| System.Boolean |
|
Checks if the media is compatible with external playback, for instance via AirPlay.
Declaration
public virtual bool IsExternalPlaybackSupported()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public abstract bool IsFinished()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public abstract bool IsLooping()
Returns
| Type |
Description |
| System.Boolean |
|
Test to see if the player can cache media.
Declaration
public virtual bool IsMediaCachingSupported()
Returns
| Type |
Description |
| System.Boolean |
True if media caching is supported.
|
Declaration
public abstract bool IsMuted()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public abstract bool IsPaused()
Returns
| Type |
Description |
| System.Boolean |
|
Checks if the playback is in a stalled state
Declaration
public virtual bool IsPlaybackStalled()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public abstract bool IsPlaying()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public abstract bool IsSeeking()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public bool IsVideoStereo()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public bool LoadSubtitlesSRT(string data)
Parameters
| Type |
Name |
Description |
| System.String |
data |
|
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public abstract void MuteAudio(bool bMuted)
Parameters
| Type |
Name |
Description |
| System.Boolean |
bMuted |
|
Declaration
public virtual void OnEnable()
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"=
Declaration
public abstract bool OpenMedia(string path, long offset, string customHttpHeaders, MediaHints mediaHints, int forceFileFormat = 0, bool startWithHighestBitrate = false)
Parameters
| Type |
Name |
Description |
| System.String |
path |
|
| System.Int64 |
offset |
|
| System.String |
customHttpHeaders |
|
| MediaHints |
mediaHints |
|
| System.Int32 |
forceFileFormat |
|
| System.Boolean |
startWithHighestBitrate |
|
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public virtual bool OpenMediaFromBuffer(byte[] buffer)
Parameters
| Type |
Name |
Description |
| System.Byte[] |
buffer |
|
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public abstract void Pause()
Pause the download of the media specified by url.
Declaration
public virtual void PauseDownloadOfMediaToCache(string url)
Parameters
| Type |
Name |
Description |
| System.String |
url |
The url of the media.
|
Declaration
public abstract void Play()
Whether this MediaPlayer instance supports linear color space
If it doesn't then a correction may have to be made in the shader
Declaration
public virtual bool PlayerSupportsLinearColorSpace()
Returns
| Type |
Description |
| System.Boolean |
|
Remove the cached media specified by url.
Declaration
public virtual void RemoveMediaFromCache(string url)
Parameters
| Type |
Name |
Description |
| System.String |
url |
The url of the media.
|
Declaration
public abstract void Render()
Returns true if the image on the texture is upside-down
Declaration
public abstract bool RequiresVerticalFlip()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public virtual void ResetAudioFocus()
Declaration
public virtual void ResetAudioHeadRotation()
Resume the download of the media specified by url.
Declaration
public virtual void ResumeDownloadOfMediaToCache(string url)
Parameters
| Type |
Name |
Description |
| System.String |
url |
The url of the media.
|
Declaration
public virtual void Rewind()
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
Declaration
public abstract void Seek(double time)
Parameters
| Type |
Name |
Description |
| System.Double |
time |
|
The time in seconds seeked will be to the closest keyframe
Declaration
public abstract void SeekFast(double time)
Parameters
| Type |
Name |
Description |
| System.Double |
time |
|
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
Declaration
public void SeekToFrame(int frame, float overrideFrameRate = 0F)
Parameters
| Type |
Name |
Description |
| System.Int32 |
frame |
|
| System.Single |
overrideFrameRate |
|
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
Declaration
public void SeekToFrameRelative(int frameOffset, float overrideFrameRate = 0F)
Parameters
| Type |
Name |
Description |
| System.Int32 |
frameOffset |
|
| System.Single |
overrideFrameRate |
|
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()
Declaration
public virtual void SeekWithTolerance(double time, double timeDeltaBefore, double timeDeltaAfter)
Parameters
| Type |
Name |
Description |
| System.Double |
time |
|
| System.Double |
timeDeltaBefore |
|
| System.Double |
timeDeltaAfter |
|
Declaration
public virtual void SelectVariant(Variant variant)
Parameters
| Type |
Name |
Description |
| Variant |
variant |
|
Declaration
public void SetActiveAudioTrack(AudioTrack track)
Parameters
SetActiveTextTrack(TextTrack)
Declaration
public void SetActiveTextTrack(TextTrack track)
Parameters
Declaration
public void SetActiveVideoTrack(VideoTrack track)
Parameters
Set whether the player is allowed to switch to external playback, e.g. AirPlay.
Declaration
public virtual void SetAllowsExternalPlayback(bool enable)
Parameters
| Type |
Name |
Description |
| System.Boolean |
enable |
|
Declaration
public virtual void SetAudioChannelMode(Audio360ChannelMode channelMode)
Parameters
Declaration
public virtual void SetAudioFocusEnabled(bool enabled)
Parameters
| Type |
Name |
Description |
| System.Boolean |
enabled |
|
Declaration
public virtual void SetAudioFocusProperties(float offFocusLevel, float widthDegrees)
Parameters
| Type |
Name |
Description |
| System.Single |
offFocusLevel |
|
| System.Single |
widthDegrees |
|
Declaration
public virtual void SetAudioFocusRotation(Quaternion q)
Parameters
| Type |
Name |
Description |
| Quaternion |
q |
|
Declaration
public virtual void SetAudioHeadRotation(Quaternion q)
Parameters
| Type |
Name |
Description |
| Quaternion |
q |
|
Declaration
public virtual void SetBalance(float balance)
Parameters
| Type |
Name |
Description |
| System.Single |
balance |
|
SetExternalPlaybackVideoGravity(ExternalPlaybackVideoGravity)
Sets the video gravity of the player for external playback only.
Declaration
public virtual void SetExternalPlaybackVideoGravity(ExternalPlaybackVideoGravity gravity)
Parameters
Declaration
public virtual void SetKeyServerAuthToken(string token)
Parameters
| Type |
Name |
Description |
| System.String |
token |
|
Declaration
public abstract void SetLooping(bool looping)
Parameters
| Type |
Name |
Description |
| System.Boolean |
looping |
|
Declaration
public virtual void SetOverrideDecryptionKey(byte[] key)
Parameters
| Type |
Name |
Description |
| System.Byte[] |
key |
|
Declaration
public abstract void SetPlaybackRate(float rate)
Parameters
| Type |
Name |
Description |
| System.Single |
rate |
|
Declaration
public virtual void SetPlayWithoutBuffering(bool playWithoutBuffering)
Parameters
| Type |
Name |
Description |
| System.Boolean |
playWithoutBuffering |
|
SetTextureProperties(FilterMode, TextureWrapMode, Int32)
Declaration
public void SetTextureProperties(FilterMode filterMode = null, TextureWrapMode wrapMode = null, int anisoLevel = 0)
Parameters
| Type |
Name |
Description |
| FilterMode |
filterMode |
|
| TextureWrapMode |
wrapMode |
|
| System.Int32 |
anisoLevel |
|
Declaration
public abstract void SetVolume(float volume)
Parameters
| Type |
Name |
Description |
| System.Single |
volume |
|
Declaration
public virtual bool StartOpenMediaFromBuffer(ulong length)
Parameters
| Type |
Name |
Description |
| System.UInt64 |
length |
|
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public abstract void Stop()
SupportsTextureFrameCount()
Returns whether this platform supports counting the number of times the texture has been updated
Declaration
public virtual bool SupportsTextureFrameCount()
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
public abstract void Update()
Declaration
protected void UpdateDisplayFrameRate()
Declaration
public virtual void UpdateSubtitles()
UpdateTextCue(Boolean)
Declaration
protected bool UpdateTextCue(bool force = false)
Parameters
| Type |
Name |
Description |
| System.Boolean |
force |
|
Returns
| Type |
Description |
| System.Boolean |
|
Declaration
protected void UpdateTimedMetadata()
Declaration
protected void UpdateTracks()
Declaration
protected virtual void UpdateVariants()
Declaration
public virtual bool WaitForNextFrame(Camera dummyCamera, int previousFrameCount)
Parameters
| Type |
Name |
Description |
| Camera |
dummyCamera |
|
| System.Int32 |
previousFrameCount |
|
Returns
| Type |
Description |
| System.Boolean |
|
Implements
System.Collections.Generic.IEnumerable
System.IDisposable