Version: 2021.2
언어: 한국어

VideoPlayer

class in UnityEngine.Video

/

다음으로부터 상속:Behaviour

매뉴얼로 전환

설명

Plays video content onto a target.

Content can be either a VideoClip imported asset or a URL such as file:// or http://. Video content will be projected onto one of the supported targets, such as camera background or RenderTexture. If the video content includes transparency, this transparency will be present in the target, allowing objects behind the video target to be visible. When the data VideoPlayer.source is set to URL, the audio and video description of what is being played will only be initialized once the VideoPlayer preparation is completed. You can test this with VideoPlayer.isPrepared.

The following demonstrates a few features of the VideoPlayer:

// Examples of VideoPlayer function

using UnityEngine;

public class Example : MonoBehaviour { void Start() { // Will attach a VideoPlayer to the main camera. GameObject camera = GameObject.Find("Main Camera");

// VideoPlayer automatically targets the camera backplane when it is added // to a camera object, no need to change videoPlayer.targetCamera. var videoPlayer = camera.AddComponent<UnityEngine.Video.VideoPlayer>();

// Play on awake defaults to true. Set it to false to avoid the url set // below to auto-start playback since we're in Start(). videoPlayer.playOnAwake = false;

// By default, VideoPlayers added to a camera will use the far plane. // Let's target the near plane instead. videoPlayer.renderMode = UnityEngine.Video.VideoRenderMode.CameraNearPlane;

// This will cause our Scene to be visible through the video being played. videoPlayer.targetCameraAlpha = 0.5F;

// Set the video to play. URL supports local absolute or relative paths. // Here, using absolute. videoPlayer.url = "/Users/graham/movie.mov";

// Skip the first 100 frames. videoPlayer.frame = 100;

// Restart from beginning when done. videoPlayer.isLooping = true;

// Each time we reach the end, we slow down the playback by a factor of 10. videoPlayer.loopPointReached += EndReached;

// Start playback. This means the VideoPlayer may have to prepare (reserve // resources, pre-load a few frames, etc.). To better control the delays // associated with this preparation one can use videoPlayer.Prepare() along with // its prepareCompleted event. videoPlayer.Play(); }

void EndReached(UnityEngine.Video.VideoPlayer vp) { vp.playbackSpeed = vp.playbackSpeed / 10.0F; } }

정적 변수

controlledAudioTrackMaxCountMaximum number of audio tracks that can be controlled. (Read Only)

변수

aspectRatioDefines how the video content will be stretched to fill the target area.
audioOutputModeDestination for the audio embedded in the video.
audioTrackCountNumber of audio tracks found in the data source currently configured. (Read Only)
canSetDirectAudioVolumeWhether direct-output volume controls are supported for the current platform and video format. (Read Only)
canSetPlaybackSpeedWhether the playback speed can be changed. (Read Only)
canSetSkipOnDropWhether frame-skipping to maintain synchronization can be controlled. (Read Only)
canSetTimeWhether current time can be changed using the time or timeFrames property. (Read Only)
canSetTimeSourceWhether the time source followed by the VideoPlayer can be changed. (Read Only)
canStepReturns true if the VideoPlayer can step forward through the video content. (Read Only)
clipThe clip being played by the VideoPlayer.
clockTimeThe clock time that the VideoPlayer follows to schedule its samples. The clock time is expressed in seconds. (Read Only)
controlledAudioTrackCountNumber of audio tracks that this VideoPlayer will take control of.
externalReferenceTimeReference time of the external clock the VideoPlayer uses to correct its drift.
frameThe frame index of the currently available frame in VideoPlayer.texture.
frameCountNumber of frames in the current video content. (Read Only)
frameRateThe frame rate of the clip or URL in frames/second. (Read Only)
heightThe height of the images in the VideoClip, or URL, in pixels. (Read Only)
isLoopingDetermines whether the VideoPlayer restarts from the beginning when it reaches the end of the clip.
isPausedWhether playback is paused. (Read Only)
isPlayingWhether content is being played. (Read Only)
isPreparedWhether the VideoPlayer has successfully prepared the content to be played. (Read Only)
lengthThe length of the VideoClip, or the URL, in seconds. (Read Only)
pixelAspectRatioDenominatorDenominator of the pixel aspect ratio (num:den) for the VideoClip or the URL. (Read Only)
pixelAspectRatioNumeratorNumerator of the pixel aspect ratio (num:den) for the VideoClip or the URL. (Read Only)
playbackSpeedFactor by which the basic playback rate will be multiplied.
playOnAwakeWhether the content will start playing back as soon as the component awakes.
renderModeWhere the video content will be drawn.
sendFrameReadyEventsEnables the frameReady events.
skipOnDropWhether the VideoPlayer is allowed to skip frames to catch up with current time.
sourceThe source that the VideoPlayer uses for playback.
targetCamera Camera component to draw to when VideoPlayer.renderMode is set to either VideoRenderMode.CameraFarPlane or VideoRenderMode.CameraNearPlane.
targetCamera3DLayoutType of 3D content contained in the source video media.
targetCameraAlphaOverall transparency level of the target camera plane video.
targetMaterialProperty Material texture property which is targeted when VideoPlayer.renderMode is set to Video.VideoTarget.MaterialOverride.
targetMaterialRenderer Renderer which is targeted when VideoPlayer.renderMode is set to Video.VideoTarget.MaterialOverride
targetTexture RenderTexture to draw to when VideoPlayer.renderMode is set to Video.VideoTarget.RenderTexture.
textureInternal texture in which video content is placed. (Read Only)
timeThe presentation time of the currently available frame in VideoPlayer.texture.
timeReferenceThe clock that the VideoPlayer observes to detect and correct drift.
timeSource[NOT YET IMPLEMENTED] The source used used by the VideoPlayer to derive its current time.
urlThe file or HTTP URL that the VideoPlayer reads content from.
waitForFirstFrameDetermines whether the VideoPlayer will wait for the first frame to be loaded into the texture before starting playback when VideoPlayer.playOnAwake is on.
widthThe width of the images in the VideoClip, or URL, in pixels. (Read Only)

Public 함수

EnableAudioTrackEnable/disable audio track decoding. Only effective when the VideoPlayer is not currently playing.
GetAudioChannelCountThe number of audio channels in the specified audio track.
GetAudioLanguageCodeReturns the language code, if any, for the specified track.
GetAudioSampleRateGets the audio track sampling rate in Hertz.
GetDirectAudioMuteGets the direct-output audio mute status for the specified track.
GetDirectAudioVolumeReturn the direct-output volume for specified track.
GetTargetAudioSourceGets the AudioSource that will receive audio samples for the specified track if VideoPlayer.audioOutputMode is set to VideoAudioOutputMode.AudioSource.
IsAudioTrackEnabledWhether decoding for the specified audio track is enabled. See VideoPlayer.EnableAudioTrack for distinction with mute.
PausePauses the playback and leaves the current time intact.
PlayStarts playback.
PrepareInitiates playback engine preparation.
SetDirectAudioMuteSet the direct-output audio mute status for the specified track.
SetDirectAudioVolumeSet the direct-output audio volume for the specified track.
SetTargetAudioSourceSets the AudioSource that will receive audio samples for the specified track if this audio target is selected with VideoPlayer.audioOutputMode.
StepForwardAdvances the current time by one frame immediately.
StopStops the playback and sets the current time to 0.

Events

clockResyncOccurredInvoked when the VideoPlayer clock is synced back to its VideoTimeReference.
errorReceivedErrors such as HTTP connection problems are reported through this callback.
frameDropped[NOT YET IMPLEMENTED] Invoked when the video decoder does not produce a frame as per the time source during playback.
frameReadyInvoked when a new frame is ready.
loopPointReachedInvoked when the VideoPlayer reaches the end of the content to play.
prepareCompletedInvoked when the VideoPlayer preparation is complete.
seekCompletedInvoke after a seek operation completes.
startedInvoked immediately after Play is called.

델리게이트

ErrorEventHandlerDelegate type for VideoPlayer events that contain an error message.
EventHandlerDelegate type for all parameterless events emitted by VideoPlayers.
FrameReadyEventHandlerDelegate type for VideoPlayer events that carry a frame number.
TimeEventHandlerDelegate type for VideoPlayer events that carry a time position.

상속된 멤버

변수

enabledEnabled Behaviours are Updated, disabled Behaviours are not.
isActiveAndEnabledReports whether a GameObject and its associated Behaviour is active and enabled.
gameObjectThe game object this component is attached to. A component is always attached to a game object.
tagThe tag of this game object.
transformThe Transform attached to this GameObject.
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.

Public 함수

BroadcastMessageCalls the method named methodName on every MonoBehaviour in this game object or any of its children.
CompareTagChecks the GameObject's tag against the defined tag.
GetComponentReturns the component of type if the GameObject has one attached.
GetComponentInChildrenReturns the Component of type in the GameObject or any of its children using depth first search.
GetComponentInParentReturns the Component of type in the GameObject or any of its parents.
GetComponentsReturns all components of Type type in the GameObject.
GetComponentsInChildrenReturns all components of Type type in the GameObject or any of its children. Works recursively.
GetComponentsInParentReturns all components of Type type in the GameObject or any of its parents.
SendMessageCalls the method named methodName on every MonoBehaviour in this game object.
SendMessageUpwardsCalls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.
TryGetComponentGets the component of the specified type, if it exists.
GetInstanceIDGets the instance ID of the object.
ToStringReturns the name of the object.

정적 함수

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeGets a list of all loaded objects of Type type.
InstantiateClones the object original and returns the clone.

연산자

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.