Class VideoPlayer
Video playback utility. Video content can be presented in UI (via VideoBrush), used in materials (via texture parameter bind) or used manually in shaders.
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[ActorContextMenu("New/Visuals/Video Player")]
[ActorToolbox("Visuals")]
[Unmanaged]
public class VideoPlayer : Actor, ISerializable
Constructors
VideoPlayer()
Properties
AudioAttenuation
Gets or sets the attenuation that controls how quickly does audio volume drop off as the listener moves further from the video player. Used by spatial audio only.
Declaration
[EditorOrder(130)]
[Limit(0F, 3.40282347E+38F, 0.1F)]
[EditorDisplay("Video Player", null)]
[VisibleIf("IsAudioSpatial", false)]
[Unmanaged]
public float AudioAttenuation { get; set; }
Property Value
System.Single
|
AudioMinDistance
Gets or sets the minimum distance at which audio attenuation starts. When the listener is closer to the video player than this value, audio is heard at full volume. Once farther away the audio starts attenuating. Used by spatial audio only.
Declaration
[EditorOrder(120)]
[Limit(0F, 3.40282347E+38F, 0.1F)]
[EditorDisplay("Video Player", null)]
[VisibleIf("IsAudioSpatial", false)]
[Unmanaged]
public float AudioMinDistance { get; set; }
Property Value
System.Single
|
AudioPan
Gets or sets the stereo pan of the played audio (-1 is left speaker, 1 is right speaker, 0 is balanced). The default is 0. Used by non-spatial audio only.
Declaration
[EditorOrder(110)]
[Limit(-1F, 1F, 1F)]
[EditorDisplay("Video Player", null)]
[VisibleIf("IsAudioSpatial", true)]
[Unmanaged]
public float AudioPan { get; set; }
Property Value
System.Single
|
AudioVolume
Gets or sets the volume of the audio played from this video, in [0, 1] range.
Declaration
[EditorOrder(100)]
[Limit(0F, 1F, 0.01F)]
[EditorDisplay("Video Player", null)]
[Unmanaged]
public float AudioVolume { get; set; }
Property Value
System.Single
|
Duration
Gets the media duration of playback (in seconds). Valid only when media was loaded by the video backend.
Declaration
[Unmanaged]
public float Duration { get; }
Property Value
System.Single
|
Frame
Gets the video frame texture (GPU resource). Created on the playback start. Can be binded to materials and shaders to display the video image.
Declaration
[Unmanaged]
public GPUTexture Frame { get; }
Property Value
GPUTexture
|
FrameRate
Gets the media frame rate of playback (amount of frames to be played per second). Valid only when media was loaded by the video backend.
Declaration
[Unmanaged]
public float FrameRate { get; }
Property Value
System.Single
|
FramesCount
Gets the amount of video frames decoded and send to GPU during playback. Can be used to detect if video has started playback with any visible changes (for video frame texture contents). Valid only when media was loaded by the video backend.
Declaration
[Unmanaged]
public int FramesCount { get; }
Property Value
System.Int32
|
IsAudioSpatial
If checked, video player us using spatialization to play 3d audio, otherwise will always play as 2d sound.
Declaration
[EditorOrder(50)]
[EditorDisplay("Video Player", null)]
[Unmanaged]
public bool IsAudioSpatial { get; set; }
Property Value
System.Boolean
|
IsLooping
Determines whether the video clip should loop when it finishes playing.
Declaration
[EditorOrder(20)]
[EditorDisplay("Video Player", null)]
[Unmanaged]
public bool IsLooping { get; set; }
Property Value
System.Boolean
|
PlayOnStart
Determines whether the video clip should autoplay on level start.
Declaration
[EditorOrder(30)]
[EditorDisplay("Video Player", "Play On Start")]
[Unmanaged]
public bool PlayOnStart { get; set; }
Property Value
System.Boolean
|
Size
Gets the video frame dimensions (in pixels). Valid only when media was loaded by the video backend.
Declaration
[Unmanaged]
public Int2 Size { get; }
Property Value
Int2
|
StartTime
Determines the time (in seconds) at which the video clip starts playing if Play On Start is enabled.
Declaration
[EditorOrder(35)]
[Limit(0F, 3.40282347E+38F, 0.01F)]
[EditorDisplay("Video Player", null)]
[VisibleIf("PlayOnStart", false)]
[Unmanaged]
public float StartTime { get; set; }
Property Value
System.Single
|
State
Gets the current state of the video playback (playing/paused/stopped).
Declaration
[Unmanaged]
public VideoPlayer.States State { get; }
Property Value
VideoPlayer.States
|
Url
The video clip Url path used as a source of the media. Can be local file (absolute or relative path), or streamed resource ('http://').
Declaration
[EditorOrder(10)]
[EditorDisplay("Video Player", null)]
[AssetReference(".mp4", false)]
[CustomEditorAlias("FlaxEditor.CustomEditors.Editors.FilePathEditor")]
[Unmanaged]
public string Url { get; set; }
Property Value
System.String
|
Methods
Pause()
Pauses the video playback.
Declaration
[Unmanaged]
public void Pause()
Play()
Starts playing the currently assigned video Url.
Declaration
[Unmanaged]
public void Play()
Stop()
Stops video playback, rewinding it to the start.
Declaration
[Unmanaged]
public void Stop()