- Home /
Handheld.PlayFullScreenMovie() works on Android but not iOS?
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.
Finally figured this out. I made a simple programmer 101 mistake! I recently split this up onto two different buttons, so obviously the string filepath is only set on one button and not the other. During my android tests I had set the default value of filepath to the actual path that android was looking for, so it all worked fine for my android tests. I just set my filepath variable to static and everything works fine now. BAAAAHHHHHHHHHH I can't believe that took me so long!!!
Answer by Bovine · Mar 18, 2014 at 08:28 PM
On iOS your video must live in a folder in the root of your project called StreamingAssets otherwise it cannot be found. I don't know what the deal is on Android.
See here:
http://docs.unity3d.com/Documentation/Manual/StreamingAssets.html
In fact, that doc link should tell you all you need to know.
I believe full screen video is a Pro feature for iOS at least, not sure about on Android.
$$anonymous$$aybe my understanding is incorrect on this, but I was under the impression that the Strea$$anonymous$$gAssets folder was something that you set up in your Unity project in advance? I'm looking to download a movie from the web and then play it as a fullscreen video.
I'm going to try using Application.strea$$anonymous$$gAssetsPath. I can't imagine why Unity would label something as "strea$$anonymous$$g assets" and then intend it to not be streamed. That doesn't make sense.
edit: It doesn't fix the problem. Still works on Android, still doesn't work on iOS.
Sorry, yes I see you're downloading it. The path is indeed setup ahead time in the assets folder and I guess it is called strea$$anonymous$$g because the asset is streamed from storage rather than loaded into memory.
Hmmm seems there used to be a iPhoneUtils.Play$$anonymous$$ovieURL() method that is now deprecated and I don't see a replacement, though it may be there is an asset that will do this?
Answer by ksiUnity · Nov 06, 2015 at 02:26 PM
I have used this funtion on both platforms and it works for me. Just Handheld.PlayFullScreenMovie("file://"+filepath); would be enough. Try using loadfromcacheordownload instead of just www