Bundle up a movie file for handheld

From what I understand, currently (as of 3.5 beta) we can only play movies in iPhone / Android that are inside Assets/StreamingAssets or directly from a URL.

I want to be able to stream the video from a URL while caching it up, like in a bundle. Or at very least just be able to download the bundle so every time I play the movie after the first time it will already be local. Is this possible?

When I try to build the bundle (just like we already do for many different assets) I get a dreaded 'MovieTexture' is not supported when building for Android.. Though I haven’t tried it on iPhone build yet, I bet it’d be the same.

Can’t remember exactly when or how Leandro got to this solution.

Basically, use www to download, then Handheld.PlayFullScreenMovie to play. With a magical setting on iPhone:

private Color bgColor = Color.black;
private FullScreenMovieControlMode controlMode = FullScreenMovieControlMode.Full;
private FullScreenMovieScalingMode scalingMode = FullScreenMovieScalingMode.AspectFill;

private string videoFile = Application.persistentDataPath + "/your-video-file.mp4";

IEnumerator DownloadAndPlayVideo () {
  string playVideoFile = videoFile;
  #if UNITY_IPHONE
    playVideoFile = "file://" + videoFile;
  #end if

  WWW www = new WWW("http://www.example.com/video.mp4");
  yield return www;

  if (www != null && www.isDone && www.error == null) {
    FileStream stream = new FileStream(videoFile, FileMode.Create);
    stream.Write(www.bytes, 0, www.bytes.Length);
    stream.Close();
  }

  Handheld.PlayFullScreenMovie(playVideoFile, bgColor, controlMode, scalingMode);
}

As the playing part implies, this is for handhelds only. It won’t work anywhere else. Though we’d “just” need to replace Handheld with MovieTexture, AudioSource and maybe yet another www (haven’t tested if it’d work with same one).

Hi,

I’m trying to play a video on android to, as I read we need to use this :

Handheld.PlayFullScreenMovie

But for me it still not work so if you found a way …