Media Player
The MediaPlayer component is the primary component of AVPro Video. It handles loading of media, setting playback options, playback and interacting with the other AVPro Video components.
This component does not display the video in the Unity scene. For this you need to use one of these components: ApplyToMesh, ApplyToMaterial, DisplayUGUI, DisplayIMGUI or your own custom script.
This is a complex component and is split into several sections.
Preview
Shows a preview of the playing media and allows control of playback and loading of media. The currently buffered range is shown in green on the timeline control.
Media Info
Shows information about the media that is currently loaded, including resolution, frame rate (if known), current playback frame rate and track information. Tracks can be switched between and the active text track will show a preview of the current text cue.
Source
Specifies the location of the media to load. The Load button will load the media immediately. The folder button will show a popup menu allowing file browsing, or shortcuts to recently loaded media or MediaReference assets. See the Loading Media section for more information.
Properties
Property | Function |
---|---|
Media Source | Specifies the type of source - either Media Reference or Path. Media Reference allows selection of an existing media asset. Path allows specifying media direct into the MediaPlayer. |
Media Reference | The MediaReference asset to use for loading. |
Source Path | The location of the media (URL or file path). |
Fallback Media Hints | |
Transparency | This hint specified whether the media contains any transparency |
Alpha Packing | If the transparency hint is enabled then an optional Alpha Packing hint can be specified. |
Stereo Packing | The packing layout for stereo video |
Main
Properties
Property | Function |
---|---|
Auto Open | Open/Load the media on Start |
Auto Play | Play the media as soon as it has loaded |
Loop | Loop the playback |
Playback Rate | Speed up or slow down playback by this rate |
Persistent | Uses Unity's Object.DontDestroyOnLoad() to preserve this GameObject during scene loads |
Force File Format | Allows a format to be specified when the correct file extension is not used. This is only supported on Android (using ExoPlayer). |
Audio
Properties
Property | Function |
---|---|
Volume | Volume in 0..1 range |
Balance | Stereo balance in -1..1 range |
Muted | Whether to mute audio playback |
Audio 360 | |
Head Transform | Set to the transform that represents the player's head so that rotation and positional changes affect the audio rendering. Usually this is the main camera |
Enable Focus | Enable when a specific region of audio in the 360 field needs to be given focus. The rest of the audio has its volume reduced. |
Off Focus Level DB | -24..0 range in decibels. How much to reduce the volume by for out of focus audio |
Focus Width Degrees | 40..120 range in degrees. The angle range for in focus audio |
Focus Transform | Transform to use for focus if different from the head transform. |
Visual
Properties
Property | Function |
---|---|
Filter | The texture filter mode to set on the video frame texture |
Wrap | The texture wrap mode to set on the video frame texture |
Aniso | The anisotropic filter level to set on the video frame texture |
Video Mapping | A hint to specify the layout of the video (eg equirectangular, or 180 degree). This is used by some AVPro Video shaders to determine how to display the video |
Use Resampler | Enable the video frame resampler. This is useful to smooth out rendering by buffering frame textures and showing them at the correct time, or even blending frames together |
Resample Mode | POINT selects the best buffered frame texture to display. BILINEAR allows blending between the two best frames |
Network
Properties
Property | Function |
---|---|
Custom HTTP Headers | Set multiple custom HTTP headers by specifying the header key and value pair. |
Auth Token | The authorisation token to pass to the key server for HLS AES-128 decryption. |
Key Override (Base64) | The authorisation key to use for HLS AES-128 decryption. This allows a key to be forced in debugging cases where the key server is offline. |
Subtitles
Properties
Property | Function |
---|---|
Sideload Subtitles | Enable sideloading of subtitles |
Source Path | The location of the subtitle SRT file to sideload |
Events
Properties
Property | Function |
---|---|
Events | Specify methods to call for triggered events |
Triggered Events | A mask to allow events to be disabled for performance reasons |
Pause Media On App Pause | Pause media playback when the application is paused (eg switched to the background) |
Play Media On App Unpause | Resumed media playback when the application is unpaused (eg switched to foreground) |
Platform Specific - Windows
Properties
Property | Function |
---|---|
Video API | Select the video API to use. Media Foundation is the default. DirectShow is a legacy API but can be useful for loading many file formats when a codec pack is installed (eg LAV Filters). WinRT is the new Windows API and has better support for adaptive streaming media, but doesn't support many other features (eg Unity audio) |
Media Foundation API Options | |
Hardware Decoding | Enable hardware decoding |
Use Low Latency | Enable low latency mode (not recommended as it degrades playback performance) |
Use Stereo Detection | Disable for extra performance if stereo packed videos are not required or the stereo packing mode is manually specified |
Use Text Tracks | Disable if text track support is not required as this can improve loading time. Enabled by default. |
Frame Selection | Experimental feature to allow prebuffering of frames and then logic to decide which frame to display, allowing for smoother playback and easier syncing of multiple videos. |
Frame Selection Options | |
Pause After Preroll Complete | Whether to pause playback automatically once prerolling has completed. Disabled by default. |
Hap / NotchLC Options | |
Use Hap/NotchLC | Disable for extra performance if Hap/NotchLC are not required |
Use Custom MOV Parser | Enabled our custom MOV parser to be used, which is useful for Hap and NotchLC codecs, as a Microsoft parser is not able to open very high bit-rate MOV files. |
Parallel Frame Count | Maximum number of threads to use for parallel frame decoding. Less threads for less latency in playback operations (seeking, playing etc), more threads for better performance. |
Preroll Frame Count | Amount of frames to decoder before starting playback, less frames for less latency in seeking, more frames for less chance of buffer emptying too quickly. |
Use Facebook Audio 360 | Disable if Facebook Audio 360 support is not required as this can improve loading time. Enabled by default. |
Audio Output | The audio output mode. System Direct (default): Plays the audio directly to the hardware bypassing Unity. Unity: Sends the audio to Unity for playback via the AudioOutput component.Facebook Audio 360: Supports playing MKV files with spatial audio encoded using Facebook Audio 360. |
Facebook Audio 360 Options | |
Channel Mode | The channel layout to use, usually TBE_8_2 or AMBIX_4 |
WinRT API Options | |
Start Max Bitrate | Forces adaptive streams to begin at the highest bitrate available |
Use Low Live Latency | Use the lowest latency possible when playing a live stream |
Custom HTTP Headers | Set multiple custom HTTP headers by specifying the header key and value pair. |
Auth Token | The authorisation token to pass to the key server for HLS AES-128 decryption. |
Key Override (Base64) | The authorisation key to use for HLS AES-128 decryption. This allows a key to be forced in debugging cases where the key server is offline. |
DirectShow API Options | |
Force Audio Output Device | Specify name of the audio output device to use if using the default device is not desired |
Preferred Filters | Force named DirectShow filters to be used as first priority. For example, "LAV Video Decoder" could be specified here to prefer it over the Microsoft decoders. Use "GDCL-MPEG4" to force internal MP4 demuxer which can be needed using OpenMediaFromBuffer() as some codec packs (eg StarCodec64) cause problems opening MP4 files into a buffer. |
Platform Specific - iOS / macOS / tvOS
Properties
Property | Function |
---|---|
Texture Format | BGRA is the default. YCbCr420 can be specified to save memory and potentially improve performance. With YCbCr420 the AVPro Video shaders are required for display, unless the texture resolve option is used. |
Generate Mipmaps | Enable generation of texture mipmaps which is useful to improve filtering quality when the video texture is scaled down on screen. |
Audio Mode | System Direct: Audio is played directly by the device bypassing Unity. This is the default mode. Unity: Audio is played by Unity via the AudioOutput component. HLS media is not supported and will play as if in system direct mode. System Direct With Capture: Audio is played directly by the hardware bypassing Unity with PCM data being available via MediaPlayer.Control.GrabAudio() . HLS media is not supported. |
Allow External Playback | Enable playback on external devices via Airplay |
Resume Playback After Audio Session Route Change | The default behaviour is for playback to pause when the audio route changes, for instance when disconnecting headphones. |
Max Playback Rate | Set the maximum playback rate that you expect to use |
Network | |
---|---|
Preferred Maximum Resolution | Limits the maximum resolution the video will playback at (HLS only). |
Preferred Peak Bitrate | Puts an upper limit on the network bandwidth used for playback. Use 0 for no limit. Defaults to 0. |
Preferred Forward Buffer Duration | The preferred duration in seconds to buffer in advance of the playhead position in order to minimise stalls. Use 0 to let the system decide based on the current network conditions. Defaults to 0. |
Play Without Buffering | Reduces latency when starting playback from a network source at the risk of an increased chance of playback stalling |
HLS Decryption | |
---|---|
Auth Token | The authorisation token to pass to the key server for HLS AES-128 decryption. |
Key Override (Base64) | The authorisation key to use for HLS AES-128 decryption. This allows a key to be forced in debugging cases where the key server is offline. |
Custom HTTP Headers |
---|
Set multiple custom HTTP headers by specifying the header key and value pair. |
Platform Specific - Android
Properties
Property | Function |
---|---|
Video API | Select the media API to use. ExoPlayer is the default and is the most flexible option. MediaPlayer uses the built-in Android API. |
Use OES Rendering | Enables the OES rendering optimisation. This saves memory and improves performance and is most useful for very high resolution video playback. See Android platform notes for more details. |
Custom HTTP Headers | Set multiple custom HTTP headers by specifying the header key and value pair. |
MediaPlayer API Options | |
Show Poster Frame | If the video is not set to auto play, then when it is loaded this option will force a play and then pause so that the first (poster) frame is rendered. |
ExoPlayer API Options | |
Prefer Software Decoder | Use the software video decoder when possible. This is mostly for internal debugging and should never be used for production. |
Force Rtp TCP | Force using TCP as the default RTP transport. |
Audio Output | System Direct (default): Audio is played directly to the hardware, bypassing Unity. Unity: Audio is played by Unity via the AudioOutput component.Facebook Audio 360: Supports playing MKV files with spatial audio encoded using Facebook Audio 360. |
Facebook Audio 360 Options | |
Channel Mode | The channel layout to use, usually TBE_8_2 or AMBIX_4 |
Audio Latency (ms) | Audio latency to add (-ve will play audio sooner, +ve later) |
Adaptive Stream Options | |
Start Max Bitrate | Start an adaptive stream (eg HLS) at the highest bit-rate possible |
Preferred Maximum Resolution | Specify the maximum resolution to limit bandwidth usage |
Preferred Peak Bitrate | For HLS videos, puts an upper limit on the network bandwidth used for playback. |
Minimum Buffer Ms | The minimum duration of media that the player will attempt to ensure is buffered at all times, in milliseconds. |
Maximum Buffer Ms | The maximum duration of media that the player will attempt to buffer, in milliseconds. |
Buffer for Playback Ms | The duration of media that must be buffered for playback to start or resume following a user action such as a seek, in milliseconds. |
Buffer for Playback After Rebuffer Ms | The default duration of media that must be buffered for playback to resume after a rebuffer, in millisecond. |
Platform Specific - Windows UWP
Properties
Property | Function |
---|---|
Video API | Select the video API to use. WinRT is the default. WinRT is the new Windows API and has better support for adaptive streaming media, but doesn't support many other features (eg Unity audio) which Media Foundation API does support. |
Media Foundation API Options | |
Hardware Decoding | Enable hardware decoding |
Generate Mipmaps | Generate textures with mip maps |
Use Low Latency | Enable low latency mode (not recommended as it degrades playback performance) |
Audio Output | The audio output mode. System Direct (default): Plays the audio directly to the hardware bypassing Unity. Unity: Sends the audio to Unity for playback via the AudioOutput component.Facebook Audio 360: Supports playing MKV files with spatial audio encoded using Facebook Audio 360. |
Facebook Audio 360 Options | |
Channel Mode | The channel layout to use, usually TBE_8_2 or AMBIX_4 |
WinRT API Options | |
Start Max Bitrate | Forces adaptive streams to begin at the highest bitrate available |
Use Low Live Latency | Use the lowest latency possible when playing a live stream |
Custom HTTP Headers | Set multiple custom HTTP headers by specifying the header key and value pair. |
Auth Token | The authorisation token to pass to the key server for HLS AES-128 decryption. |
Key Override (Base64) | The authorisation key to use for HLS AES-128 decryption. This allows a key to be forced in debugging cases where the key server is offline. |
Platform Specific - WebGL
Properties
Property | Function |
---|---|
External Library | Whether to use any external JS library for video decoding. This requires that the javascript is included in the HTML. Currently Dash.JS and HLS.JS are supported. A custom library can also be specified and would require editing of the AVProVideo.js file to add support for it. See WebGL streaming information for more details. |
Generate Mipmaps | Enable generation of texture mipmaps which is useful to improve filtering quality when the video texture is scaled down on screen. |
Global
Global per-platform settings. These options need to be set for each platform (via Build Settings > Switch).
Properties
Property | Function |
---|---|
TimeScale Support | Enable support for video playback to react to changes in Time.TimeScale. This is mostly useful for offline video capture where capturing is not running in real-time. Audio playback will not work during captures as the video is paused and simply seeks to the desired position. |
Disable Debug GUI | Deprecated |
Disable Logging | Disables all the "[AVProVideo]" debug logging |
Developer Mode | Enables the Developer section on the MediaPlayer inspector view which shows internal state |