Playing Video

Playing video in games is sometimes inevitable, especially when there's some cutscenes, which is too complicated to implement in codes.

At first, when it comes to playing video in Unity, there's only MovieTexture, which didn't support iOS or Android.

In the manual of MovieTexture, it suggests that you can use Handheld.PlayFullScreenMovie on iOS or Android. I tried this, it actually works well on iOS devices, but it doesn't support preview on the editor mode.

  • remember to switch build platform to iOS/Android, or you will get build failure
  • remember to put your video inside StreamingAssets folder inside Asset folder
void OnGUI () {

    if (GUI.Button (new Rect (20,10,200,50), "PLAY ControlMode.CancelOnTouch")) {
        Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
    }
 
    if (GUI.Button (new Rect (20,90,200,25), "PLAY ControlMode.Full")) {
        Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.Full);
    }
 
    if (GUI.Button (new Rect (20,170,200,25), "PLAY ControlMode.Hidden")) {
        Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.Hidden);    
    }
 
    if (GUI.Button (new Rect (20,250,200,25), "PLAY ControlMode.Minimal")) {
        Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.Minimal);
    }
 
}

After 5.6 updates, VideoPlayer comes out and it supports cross-platform.

I've tried VideoPlayer several times, and it really drives me crazy. Not until it's built to the devices, it starts to acting weird, ex. unacceptable latency, freezing frames or glitch effects, even though the video size is compressed to as lightweight as possible (< 5Mb).

After discussing with other senior game developers, they gave me two suggestions:

Aforementioned animation in my project is way too complicated, so I purchased the wheel again. There are other similar assets on the asset store, I tried AVPro Video ($450) in my master project, but it's way too expensive.

EasyMovieTexture is an acceptable solution with less expense and workable scripts. And it supports preview in editor mode, which makes debugging less painful. Now I can play video smoothly on iOS devices.

Just follow the example in the package to learn the usage of it.
It's literally easy to use, but it isn't flawless. (see the following pic) f:id:fervor:20180628165504p:plain