ProgrammingUnity

Unity Video Player Explained Fully | Learn Unity Mir Imad Ahmed

Unity Video Player Explained Fully

unity video player

unity video player

New unity video player component has been introduced lately from Unity. I have had a chance to play around with the component in my applications.

I wrote about using video player with Vuforia AR here.

I am going explain as much as I can. Here is how it looks like:

unity video player component

unity video player component

I will try to explain things one by one.

Source

  • Video Clip – It can be a video clip imported inside unity project.
  • URL – You can play a video directly from a URL be it served over web or file:// protocols.

Play On Awake

If you keep this checked unity video player will automatically play your video as soon as you run the project.

Wait For First Frame

If you keep this checked unity video player will wait till it gets the first frame of the video loaded into the memory.

Loop

Self explanatory, helps you if you want to loop your video and want it to play itself again when it ends.

Playback Speed

It helps you speed up or down your video speed.

Render Mode

It requires more than just one line explanation. It has 5 different rendering modes as shown:

unity video player render modes

unity video player render modes

Camera Far Plane

Render the video on the Camera’s far plane.

Camera Near Plane.

Render the video on the Camera’s near plane.

Render Texture

Render the video into a Render Texture.

Material Override

Render the video into a selected Texture property of a GameObject through its Renderer’s Material.

API Only

Render the video into the VideoPlayer.texture Scripting API property. You must use scripting to assign the Texture to its intended destination.

Aspect Ratio

The aspect ratio of the images that fill the Camera Near Plane, Camera Far Plane or Render Texture when the corresponding Render Mode is used.

Following are the aspect ratio options we have:

No Scaling

No scaling is used. The video is centered on the destination rectangle.

Fit Vertically

Scale the source to fit the destination rectangle vertically, cropping the left and right sides or leaving black areas on each side if necessary. The source aspect ratio is preserved.

Fit Horizontally

Scale the source to fit the destination rectangle horizontally, cropping the top and bottom regions or leaving black areas above and below if needed. The source aspect ratio is preserved.

Fit Inside

Scale the source to fit the destination rectangle without having to crop. Leaves black areas on the left and right or above and below as needed. The source aspect ratio is preserved.

Fit Outside

Scale the source to fit the destination rectangle without leaving black areas on the left and right or above and below, cropping as required. The source aspect ratio is preserved.

Stretch

Scale both horizontally or vertically to fit the destination rectangle. The source aspect ratio is not preserved.

Audio

Then comes another crucial part of how you want your video’s audio to be considered. Do you want no audio, play directly on the hardware or do you want to do audio tweaking as well. For that you will have to select Audio Source option.

If you select Audio source as the option you will have to provide the reference of the audio source component where you want the audio to be played through. Then in that audio source component you can do the tweaking.

Watch my All unity tutorials.

Learn how to unity play video on canvas in unity.