//
// 摘要:
// Plays video content onto a target.
[NativeHeader("Modules/Video/Public/VideoPlayer.h")]
[RequireComponent(typeof(Transform))]
[RequiredByNativeCode]
public sealed class VideoPlayer : Behaviour
{
public VideoPlayer();
//
// 摘要:
// Maximum number of audio tracks that can be controlled. (Read Only)
可以控制的最大音轨数。(只读)
public static ushort controlledAudioTrackMaxCount { get; }
//
// 摘要:
// Whether playback is paused. (Read Only)
播放是否暂停。(只读)
public bool isPaused { get; }
//
// 摘要:
// Whether current time can be changed using the time or timeFrames property. (Read
// Only)
是否可以使用time或timeFrames属性更改当前时间(只读)
public bool canSetTime { get; }
//
// 摘要:
// The presentation time of the currently available frame in VideoPlayer.texture.
在VideoPlayer.texture中当前可用帧的显示时间。
[NativeName("SecPosition")]
public double time { get; set; }
//
// 摘要:
// The clock time that the VideoPlayer follows to schedule its samples. The clock
// time is expressed in seconds. (Read Only)
视频播放器所遵循的时钟时间来安排它的样本。时钟时间用秒表示。(只读)
public double clockTime { get; }
//
// 摘要:
// Returns true if the VideoPlayer can step forward through the video content. (Read
// Only)
如果视频播放器可以在视频内容中前进,则返回true。(只读)
(可不可以跳到后面)
public bool canStep { get; }
//
// 摘要:
// Whether the playback speed can be changed. (Read Only)
播放速度是否可以改变。(只读)
public bool canSetPlaybackSpeed { get; }
//
// 摘要:
// Factor by which the basic playback rate will be multiplied.
基本播放速率乘以的因数。(改变播放速度)
public float playbackSpeed { get; set; }
//
// 摘要:
// Determines whether the VideoPlayer restarts from the beginning when it reaches
// the end of the clip.
确定视频播放器到达时是否从头重新播放视频。
[NativeName("Loop")]
public bool isLooping { get; set; }
//
// 摘要:
// Whether the time source followed by the VideoPlayer can be changed. (Read Only)
是否可以更改视频播放器后面的时间源。(只读)
public bool canSetTimeSource { get; }
//
// 摘要:
// [NOT YET IMPLEMENTED] The source used used by the VideoPlayer to derive its current
// time.
(还没有实现)视频播放器用来获得当前时间的源。
public VideoTimeSource timeSource { get; set; }
//
// 摘要:
// The clock that the Video.VideoPlayer observes to detect and correct drift.
闹钟响了。视频播放器通过观察来检测和纠正偏移(没看懂)
public VideoTimeReference timeReference { get; set; }
//
// 摘要:
// Reference time of the external clock the Video.VideoPlayer uses to correct its
// drift.
参考时间的外部时钟的视频。视频播放器用来纠正它漂移。(???)
public double externalReferenceTime { get; set; }
//
// 摘要:
// Whether frame-skipping to maintain synchronization can be controlled. (Read Only)
是否可以控制跳帧来保持同步。(只读)(这是能不能跳到视频后面的判断)
public bool canSetSkipOnDrop { get; }
//
// 摘要:
// Whether the VideoPlayer is allowed to skip frames to catch up with current time.
是否允许视频播放器跳过当前帧以赶上当前时间。
public bool skipOnDrop { get; set; }
//
// 摘要:
// Number of frames in the current video content. (Read Only)
当前视频内容中的帧数。(只读)
public ulong frameCount { get; }
//
// 摘要:
// The frame rate of the clip or URL in frames/second. (Read Only)
以帧/秒为单位的剪辑或URL的帧速率。(只读)
public float frameRate { get; }
//
// 摘要:
// The length of the VideoClip, or the URL, in seconds. (Read Only)
视频的长度,或者URL,以秒为单位。(只读)
[NativeName("Duration")]
public double length { get; }
//
// 摘要:
// The width of the images in the VideoClip, or URL, in pixels. (Read Only)
在VideoClip或URL中图像的宽度(以像素为单位)。(只读)
public uint width { get; }
//
// 摘要:
// The height of the images in the VideoClip, or URL, in pixels. (Read Only)
//在VideoClip或URL中图像的高度(以像素为单位)。(只读)
public uint height { get; }
//
// 摘要:
// Numerator of the pixel aspect ratio (num:den) for the VideoClip or the URL. (Read
// Only)
像素长宽比的分子(num:den)为视频或URL。(只读)
public uint pixelAspectRatioNumerator { get; }
//
// 摘要:
// Denominator of the pixel aspect ratio (num:den) for the VideoClip or the URL.
// (Read Only)
//像素长宽比的分子(num:den)为视频嘴唇或URL。(只读)
public uint pixelAspectRatioDenominator { get; }
//
// 摘要:
// Number of audio tracks found in the data source currently configured. (Read Only)
在当前配置的数据源中找到的音频轨数。(只读)
public ushort audioTrackCount { get; }
//
// 摘要:
// Number of audio tracks that this VideoPlayer will take control of.
这个视频播放器将控制的音轨数。
public ushort controlledAudioTrackCount { get; set; }
//
// 摘要:
// Destination for the audio embedded in the video.
目标音频嵌入到视频。
public VideoAudioOutputMode audioOutputMode { get; set; }
//
// 摘要:
// Whether direct-output volume controls are supported for the current platform
// and video format. (Read Only)
当前平台和视频格式是否支持直接输出音量控制。(只读)
public bool canSetDirectAudioVolume { get; }
//
// 摘要:
// Enables the frameReady events.
启用frameReady事件。
public bool sendFrameReadyEvents { get; set; }
//
// 摘要:
// Whether content is being played. (Read Only)
是否播放内容。(只读)
public bool isPlaying { get; }
//
// 摘要:
// Whether the content will start playing back as soon as the component awakes.
组件一开启,内容是否立即开始播放。
public bool playOnAwake { get; set; }
//
// 摘要:
// The frame index of the currently available frame in VideoPlayer.texture.
在VideoPlayer.texture中当前可用帧的帧索引。
[NativeName("FramePosition")]
public long frame { get; set; }
//
// 摘要:
// Whether the VideoPlayer has successfully prepared the content to be played. (Read
// Only)
视频播放器是否成功地准备了要播放的内容。(只读)
public bool isPrepared { get; }
//
// 摘要:
// The source that the VideoPlayer uses for playback.
视频播放器用于回放的源。
public VideoSource source { get; set; }
//
// 摘要:
// The file or HTTP URL that the VideoPlayer reads content from.
视频播放器读取内容的文件或HTTP URL。
[NativeName("VideoUrl")]
public string url { get; set; }
//
// 摘要:
// The clip being played by the VideoPlayer.
视频播放器播放的视频。
[NativeName("VideoClip")]
public VideoClip clip { get; set; }
//
// 摘要:
// Where the video content will be drawn.
视频内容将被绘制到哪里。
public VideoRenderMode renderMode { get; set; }
//
// 摘要:
// Camera component to draw to when Video.VideoPlayer.renderMode is set to either
// Video.VideoRenderMode.CameraFarPlane or Video.VideoRenderMode.CameraNearPlane.
摄像元件可在录影时绘制。渲染模式设置为视频。VideoRenderMoCameraFarPlane或Video.VideoRenderMode.CameraNearPlane。
[NativeHeader("Runtime/Camera/Camera.h")]
public Camera targetCamera { get; set; }
//
// 摘要:
// Determines whether the VideoPlayer will wait for the first frame to be loaded
// into the texture before starting playback when Video.VideoPlayer.playOnAwake
// is on.
确定视频播放器是否将等待加载第一帧当Video.VideoPlayer.playOnAwake开始播放之前,进入纹理
public bool waitForFirstFrame { get; set; }
//
// 摘要:
// RenderTexture to draw to when Video.VideoPlayer.renderMode is set to Video.VideoTarget.RenderTexture.
渲染纹理绘制到视频播放器。渲染模式设置为Video.VideoTarget.RenderTexture。
[NativeHeader("Runtime/Graphics/RenderTexture.h")]
public RenderTexture targetTexture { get; set; }
//
// 摘要:
// Material texture property which is targeted when Video.VideoPlayer.renderMode
// is set to Video.VideoTarget.MaterialOverride.
材质纹理属性,当使用Video.VideoPlayer.renderMode时可以使用
设置为Video.VideoTarget.MaterialOverride。
public string targetMaterialProperty { get; set; }
//
// 摘要:
// Defines how the video content will be stretched to fill the target area.
定义如何拉伸视频内容以填充目标区域。
public VideoAspectRatio aspectRatio { get; set; }
//
// 摘要:
// Overall transparency level of the target camera plane video.
目标摄像机平面视频的整体透明度水平。
public float targetCameraAlpha { get; set; }
//
// 摘要:
// Type of 3D content contained in the source video media.
源视频媒体中包含的3D内容类型。
public Video3DLayout targetCamera3DLayout { get; set; }
//
// 摘要:
// Internal texture in which video content is placed. (Read Only)
放置视频内容的内部纹理。(只读)
[NativeHeader("Runtime/Graphics/Texture.h")]
public Texture texture { get; }
//
// 摘要:
// Renderer which is targeted when Video.VideoPlayer.renderMode is set to Video.VideoTarget.MaterialOverride
渲染器的目标是当视频。渲染模式设置为Video.VideoTarget.MaterialOverride
[NativeHeader("Runtime/Graphics/Renderer.h")]
public Renderer targetMaterialRenderer { get; set; }
public event EventHandler started;
public event EventHandler frameDropped;
public event ErrorEventHandler errorReceived;
public event TimeEventHandler clockResyncOccurred;
public event EventHandler seekCompleted;
public event EventHandler loopPointReached;
public event FrameReadyEventHandler frameReady;
public event EventHandler prepareCompleted;
//
// 摘要:
// Enable/disable audio track decoding. Only effective when the VideoPlayer is not
// currently playing.
启用/禁用音轨解码。只有在视频播放器不能播放时才有效当前播放。
// 参数:
// trackIndex:
// Index of the audio track to enable/disable.
要启用/禁用的音轨的索引。
// enabled:
// True for enabling the track. False for disabling the track.
启用音轨是true的。禁用音轨为False。
public void EnableAudioTrack(ushort trackIndex, bool enabled);
//
// 摘要:
// The number of audio channels in the specified audio track.
指定音轨中的音频通道数。
//
// 参数:
// trackIndex:
// Index for the audio track being queried.
正在查询的音轨的索引。
// 返回结果:
// Number of audio channels.
音频通道的数量。
public ushort GetAudioChannelCount(ushort trackIndex);
//
// 摘要:
// Returns the language code, if any, for the specified track.
返回指定音轨的语言代码(如果有)。
// 参数:
// trackIndex:
// Index of the audio track to query.
要查询的音轨的索引。
// 返回结果:
// Language code.
语言码
public string GetAudioLanguageCode(ushort trackIndex);
//
// 摘要:
// Gets the audio track sampling rate in Hertz.
获取音频轨道采样率(以赫兹为单位)。
// 参数:
// trackIndex:
// Index of the audio track to query.
要查询的音轨的索引。
// 返回结果:
// The sampling rate in Hertz.
采样率(赫兹)
public uint GetAudioSampleRate(ushort trackIndex);
//
// 摘要:
// Gets the direct-output audio mute status for the specified track.
获取指定音轨的直接输出音频静音状态。
// 参数:
// trackIndex:
public bool GetDirectAudioMute(ushort trackIndex);
//
// 摘要:
// Return the direct-output volume for specified track.
返回指定音轨的直接输出音量。
// 参数:
// trackIndex:
// Track index for which the volume is queried.
指定音轨的跟踪索引。
// 返回结果:
// Volume, between 0 and 1.
音量,在0和1之间。
public float GetDirectAudioVolume(ushort trackIndex);
//
// 摘要:
// Gets the AudioSource that will receive audio samples for the specified track
// if Video.VideoPlayer.audioOutputMode is set to Video.VideoAudioOutputMode.AudioSource.
获取将接收指定音轨的音频样本的AudioSource如果Video.VideoPlayer。audioOutputMode设置为 Video.VideoAudioOutputMode.AudioSource。
// 参数:
// trackIndex:
// Index of the audio track for which the AudioSource is wanted.
需要音源的音轨的索引。
// 返回结果:
// The source associated with the audio track.
与音轨相关联的源。
[NativeHeader("Modules/Audio/Public/AudioSource.h")]
public AudioSource GetTargetAudioSource(ushort trackIndex);
//
// 摘要:
// Whether decoding for the specified audio track is enabled. See Video.VideoPlayer.EnableAudioTrack
// for distinction with mute.
是否启用指定音轨的解码。看到Video.VideoPlayer。EnableAudioTrack与静音的区别。
// 参数:
// trackIndex:
// Index of the audio track being queried.
正在查询的音轨的索引。
// 返回结果:
// Returns true if decoding for the specified audio track is enabled.
如果已启用指定音轨的解码,则返回true。
public bool IsAudioTrackEnabled(ushort trackIndex);
//
// 摘要:
// Pauses the playback and leaves the current time intact.
暂停播放并保持当前时间不变。
public void Pause();
//
// 摘要:
// Starts playback.
开始播放。
public void Play();
//
// 摘要:
// Initiates playback engine preparation.
启动播放引擎准备。
public void Prepare();
//
// 摘要:
// Set the direct-output audio mute status for the specified track.
设置指定音轨的直接输出音频静音状态。
// 参数:
// trackIndex:
// Track index for which the mute is set.
为其设置静音的跟踪索引。
// mute:
// Mute on/off.
沉默 on/off。
public void SetDirectAudioMute(ushort trackIndex, bool mute);
//
// 摘要:
// Set the direct-output audio volume for the specified track.
设置直接输出音频音量为指定的轨道。
// 参数:
// trackIndex:
// Track index for which the volume is set.
需要设置的跟踪索引。
// volume:
// New volume, between 0 and 1.
音量 0到1之间
public void SetDirectAudioVolume(ushort trackIndex, float volume);
//
// 摘要:
// Sets the AudioSource that will receive audio samples for the specified track
// if this audio target is selected with Video.VideoPlayer.audioOutputMode.
设置将接收指定音轨的音频样本的AudioSource如果这个音频目标是用Video.VideoPlayer.audioOutputMode选择的。
// 参数:
// trackIndex:
// Index of the audio track to associate with the specified AudioSource.
将音轨的索引与指定的音源关联。
// source:
// AudioSource to associate with the audio track.
音源与音轨相关联。
public void SetTargetAudioSource(ushort trackIndex, AudioSource source);
//
// 摘要:
// Advances the current time by one frame immediately.
立即将当前时间提前一帧。
public void StepForward();
//
// 摘要:
// Stops the playback and sets the current time to 0.
停止播放并将当前时间设置为0。
public void Stop();
//
// 摘要:
// Delegate type for VideoPlayer events that carry a frame number.
带有帧号的视频播放器事件的委托类型。
// 参数:
// source:
// The VideoPlayer that is emitting the event.
发出事件的视频播放器。
// frameNum:
// The current frame of the VideoPlayer.
视频播放器的当前帧。
// frameIdx:
这大概是播放到指定帧调用者委托
public delegate void FrameReadyEventHandler(VideoPlayer source, long frameIdx);
//
// 摘要:
// Delegate type for all parameterless events emitted by VideoPlayers.
视频播放器发出的所有无参数事件的委托类型。
// 参数:
// source:
// The VideoPlayer that is emitting the event.
发出事件的视频播放器。
public delegate void EventHandler(VideoPlayer source);
//
// 摘要:
// Delegate type for VideoPlayer events that contain an error message.
包含错误消息的视频播放器事件的委托类型。
// 参数:
// source:
// The VideoPlayer that is emitting the event.
发出事件的视频播放器。
// message:
// Message describing the error just encountered.
描述刚刚遇到的错误的消息。
public delegate void ErrorEventHandler(VideoPlayer source, string message);
//
// 摘要:
// Delegate type for VideoPlayer events that carry a time position.
带有时间位置的视频播放器事件的委托类型。
// 参数:
// source:
// The VideoPlayer that is emitting the event.
发出事件的视频播放器。
// seconds:
// Time position.
时间的位置。
public delegate void TimeEventHandler(VideoPlayer source, double seconds);
}
只能点原创了
遇到的坑:
1.VideoPlayer.length在改变VideoPlayer.time之后的一帧里会变为0,下一帧才会变回原样,做视频进度条的话要注意