I’m trying to download a movie from the web and then play it on my phone using the native video player. I’m working with an LG Nexus 5 and an iPad 3. I’ve got Unity Pro, Android Pro, and iOS Pro. I can get the builds up and running just fine, and when I point Handheld.PlayFullScreenMovie() to an mp4 on the internet, it works fine on both devices. The problem I’m having is getting a downloaded movie file to play on the iPad. Using the code below, the movie will download just fine and play on my Nexus 5, but it won’t play the movie using the iPad, even thought it seems to download just fine on the iPad. Any thoughts?
Here’s what I’ve got… (this same script is set on two different buttons in the scene, one is a download button, one is a play button.)
string filepath;
void OnMouseDown () {
if (buttontype == ButtonType.Download)
StartCoroutine(BeginDownload());
if (buttontype == ButtonType.Play)
Play ();
}
void Play(){
Handheld.PlayFullScreenMovie("file://"+filepath);
}
IEnumerator BeginDownload(){
filepath = Application.persistentDataPath + "/test.mp4";
WWW www = new WWW("http://www.example.com/test.mp4");
while (!www.isDone){
yield return null;
}
Debug.Log("DONE!");
System.IO.File.WriteAllBytes(filepath,www.bytes);
}
I’m thinking the problem might lay somewhere in the directory path and how iOS stores the data.