Lire une vidéo dans une scène Unity avec du Code C#
VideoPlayer component Reference
Grace au composant « VideoPlayer » d’unity il est très simple de lire une vidéo dans une scène de jeu. Son utilisation est multiple : Créer une cinématique, un cinéma virtuel ou encore diffuser une vidéo sur un écran de Tv dans vos scènes de jeux.
Dans cette vidéo je vous propose d’apprendre a interagir avec ce composant par le biais du code afin de pouvoir la mettre en pause , ou encore avancer , ou tout simplement détecter la fin de la vidéo.

Properties
aspectRatio | Defines how the video content will be stretched to fill the target area. |
audioOutputMode | Destination for the audio embedded in the video. |
audioTrackCount | Number of audio tracks found in the data source currently configured. (Read Only) |
canSetDirectAudioVolume | Whether direct-output volume controls are supported for the current platform and video format. (Read Only) |
canSetPlaybackSpeed | Whether the playback speed can be changed. (Read Only) |
canSetSkipOnDrop | Whether frame-skipping to maintain synchronization can be controlled. (Read Only) |
canSetTime | Whether current time can be changed using the time or timeFrames property. (Read Only) |
canSetTimeSource | Whether the time source followed by the VideoPlayer can be changed. (Read Only) |
canStep | Returns true if the VideoPlayer can step forward through the video content. (Read Only) |
clip | The clip being played by the VideoPlayer. |
clockTime | The clock time that the VideoPlayer follows to schedule its samples. The clock time is expressed in seconds. (Read Only) |
controlledAudioTrackCount | Number of audio tracks that this VideoPlayer will take control of. |
externalReferenceTime | Reference time of the external clock the VideoPlayer uses to correct its drift. |
frame | The frame index of the currently available frame in VideoPlayer.texture. |
frameCount | Number of frames in the current video content. (Read Only) |
frameRate | The frame rate of the clip or URL in frames/second. (Read Only) |
height | The height of the images in the VideoClip, or URL, in pixels. (Read Only) |
isLooping | Determines whether the VideoPlayer restarts from the beginning when it reaches the end of the clip. |
isPaused | Whether playback is paused. (Read Only) |
isPlaying | Whether content is being played. (Read Only) |
isPrepared | Whether the VideoPlayer has successfully prepared the content to be played. (Read Only) |
length | The length of the VideoClip, or the URL, in seconds. (Read Only) |
pixelAspectRatioDenominator | Denominator of the pixel aspect ratio (num:den) for the VideoClip or the URL. (Read Only) |
pixelAspectRatioNumerator | Numerator of the pixel aspect ratio (num:den) for the VideoClip or the URL. (Read Only) |
playbackSpeed | Factor by which the basic playback rate will be multiplied. |
playOnAwake | Whether the content will start playing back as soon as the component awakes. |
renderMode | Where the video content will be drawn. |
sendFrameReadyEvents | Enables the frameReady events. |
skipOnDrop | Whether the VideoPlayer is allowed to skip frames to catch up with current time. |
source | The 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. |
targetCamera3DLayout | Type of 3D content contained in the source video media. |
targetCameraAlpha | Overall 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. |
texture | Internal texture in which video content is placed. (Read Only) |
time | The presentation time of the currently available frame in VideoPlayer.texture. |
timeReference | The 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. |
url | The file or HTTP URL that the VideoPlayer reads content from. |
waitForFirstFrame | Determines whether the VideoPlayer will wait for the first frame to be loaded into the texture before starting playback when VideoPlayer.playOnAwake is on. |
width | The width of the images in the VideoClip, or URL, in pixels. (Read Only) |
Public Methods
EnableAudioTrack | Enable/disable audio track decoding. Only effective when the VideoPlayer is not currently playing. |
GetAudioChannelCount | The number of audio channels in the specified audio track. |
GetAudioLanguageCode | Returns the language code, if any, for the specified track. |
GetAudioSampleRate | Gets the audio track sampling rate in Hertz. |
GetDirectAudioMute | Gets the direct-output audio mute status for the specified track. |
GetDirectAudioVolume | Return the direct-output volume for specified track. |
GetTargetAudioSource | Gets the AudioSource that will receive audio samples for the specified track if VideoPlayer.audioOutputMode is set to VideoAudioOutputMode.AudioSource. |
IsAudioTrackEnabled | Whether decoding for the specified audio track is enabled. See VideoPlayer.EnableAudioTrack for distinction with mute. |
Pause | Pauses the playback and leaves the current time intact. |
Play | Starts playback. |
Prepare | Initiates playback engine preparation. |
SetDirectAudioMute | Set the direct-output audio mute status for the specified track. |
SetDirectAudioVolume | Set the direct-output audio volume for the specified track. |
SetTargetAudioSource | Sets the AudioSource that will receive audio samples for the specified track if this audio target is selected with VideoPlayer.audioOutputMode. |
StepForward | Advances the current time by one frame immediately. |
Stop | Stops the playback and sets the current time to 0. |