2 Best Ways to play video inside Unity Game




Nowadays each and every game has a video inside it to showcase its product, organization or advertise their goods.Today we are going to learn something which demonstrating movie player inside unity.

Video




There are several ways to play a movie inside unity, but here we are discussing 2 best ways.




Handheld Class

Handheld Class from unity provides functionality like full-screen movie player, vibrate, activity indicator.This can stream a movie from the device storage.Thus, you have to provide movie in a separated file with extensions such as mp4,3gp,mov, and mpv with compression standard of H.264 and MPEG-4.This will play video on iOS, android, and windows.

This is the syntax of Handheld.PlayFullScreenMovie.

  1. path – Clearly indicating the folder named StreamingAssets inside your Unity project (inside your Assets folder).
  2. bg-color – Background color.
  3. FullScreenMovieControlMode – Movie playback control.
  4. FullScreenMovieScalingMode – scaling modes for displaying movies.




Akki.mp4 is a movie file inside StreamingAssets folder.

Video Player

Unity introduces a new feature called video player from unity 5.6.It will help you to play video in Camera render texture, Render texture, Materials and much more.It is a gameobject component for playback movie in your Unity scene.




Let’s see how we can do it.

  1. Import your movie clip in Unity store in any folder.
  2. Go to Hierarchy→Create→Video→VideoPlayer and it will create an object in the hierarchy.
  3. Assign your movie clip.
  4. Assing audio Source to movie player component.




This component has different render mode for playing a movie on it, we can here play a movie on RawImage component.




For script to run successfully,

  1. Assign script to empty Gameobject.
  2. Assign RawImage and VideoPlayer Component to script.
  3. You did it, Play Now.




You can also play any movie from its URL only, To do so change VideoPlayer Component Source from VideoClip to URL and Setup a proper URL to play the movie.

More helpful assets:

6 thoughts on “2 Best Ways to play video inside Unity Game”

  1. Good work bro. Can we play youtube videos inside unity with all features like play,pause, buffer, forward video with hand etc?

  2. Thanks a lot for sharing this with alll folks you really recognise what you are speaking about!
    Bookmarked. Kindlpy also consult with my site =). We could have a hyperlink change arrangement among us

Leave a Reply

Your email address will not be published. Required fields are marked *