Playing Video in Unity 5 (on mobile)

I’m using Unity 5 free and wondering if there’s a way to play back a movie (I’m using it for the intro movie the first time you play the game).

I’m fine with either loading the video directly or streaming it from the web if that’s the only possible way.

All the answers I find mention Unity Pro, but they’re also pre-Unity5, so I’m not sure if its changed since then.

When I try to bring a video file into Unity, it does not give me import options. I’m not able to assign it to a MovieTexture. I have Quicktime installed on Windows.

How does everyone else do it? Is there a plugin or an asset that would help me?

Answering my own question…

I can’t believe I didn’t find this while searching the forums, but as of Unity 5, you can use
Handheld.PlayFullScreenMovie() to play a video file in StreamingAssets.

Read the info on file formats in there. I used VLC Player to export my movie to H.264 mp4 file.

I then Imported the file into an arbitrary folder under Assets in Unity (Not the streaming assets folder).
Unity should recognize this file as a movie and give you some options in the inspector.

NOW, move the file into StreamingAssets. If you do it directly, it doesn’t recognize it as a movie for some reason. *shrug.

I hope this helps someone!

Hi all Guru here , i was searching for the same but after a pro long struggle i have made it work…

I just wanted people to know about the complete process here itself…

Question : How to playback a video in android platform using unity c-sharp ?

Answer :

Step 1< — Make sure about the formats and the settings of the video , mp4 h.264 (640x480) worked for me.

Step 2< — Create a folder inside your Assets folder and name it as “StreamingAssets” (without space , it is case sensitive). Place your video in the folder.

Step 3< — Write a new c-sharp script using the code below :

“using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;”

public class playbackVideoHandHeld : MonoBehaviour {

private string movie = "yourVideoNameHere.mp4";
public int sceneNumber;

// Use this for initialization
void Start () 
{
	StartCoroutine(streamVideo(movie));
}

private IEnumerator streamVideo(string video)
{
	Handheld.PlayFullScreenMovie(video, Color.black, FullScreenMovieControlMode.Full, FullScreenMovieScalingMode.AspectFill);
	yield return new WaitForEndOfFrame();
	Debug.Log("The Video playback is now completed.");
	SceneManager.LoadScene (sceneNumber);
}

}

Step 4< — Create an empty GameObject and attach the script to it.

Note : You will not see the video playing in the editor or by using build and run , you have to build the app and install in order to check it.

Step 5< — The step four’s note session is the most important part where i have spent a loads of time.

Note : If unity throws error while building it to an apk which says like something went wrong in the AndroidManifest.xml or some winsdk error just change the Minimum API Level under Other Settings of the Player Settings and see which one works for you.

Thanks,
Guru

There is two plugins that can do that on mobile. Mobile Movie Texture and Easy Movie Texture.

These two work fine. I have tested them.