- Home /
why cannot build movie texture on android?
hi all, i want to play video in unity, and i found that using movie texture, and i can use it on standalone, but when i want to build on android device, i get some error just like here :
The type or namespace name `MovieTexture' could not be found. Are you missing a using directive or an assembly reference?
Error building Player because scripts had compiler errors
this is my code:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
[RequireComponent(typeof(AudioListener))]
public class Movie : MonoBehaviour {
public MovieTexture movie;
private float movieTimer;
void OnGUI(){
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), movie);
movie.Play();
if(movie.duration < movieTimer){
movie.Stop();
print("Movie Finish");
}
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
movieTimer += Time.deltaTime;
}
}
anything wrong? or i have miss something so i can't build movie texture on android?
please help me..
Thanks
Answer by Arrod55 · Aug 01, 2013 at 01:18 AM
I realize this is a bit old, but it still came up in my search results when trying to solve a similar problem.
There are two parts to this solution...
First, any code using "MovieTexture" MUST be set only for PC builds. The game I am working on is for Android and PC, so I use the following preprocessor commands:
#if UNITY_ANDROID
Handheld.PlayFullScreenMovie("");
#else
MovieTexture stuff;
#endif
The second part is that you cannot have any movies applied as textures in your scenes. Even if you are not using them, they cannot be set as a texture.
Hey man. I know this is very old, but how did you play videos on Android using the PlayFullScreen$$anonymous$$ovie method? The package is jar compressed, so you can't just pass a string to it...
Answer by Bunny83 · Jan 10, 2013 at 09:29 AM
Because it's not supported on iOS or Android as you can read in the docs
oh nooo, so how can i play video on android with unity? any other way?
sorry i want to ask why in this thread $$anonymous$$ovieTexture can work on android? with some code and i don't understand about the code.
Thanks
Answer by Xorxor · Dec 15, 2015 at 09:52 PM
It's an annoyance that any code including MovieTexture won't compile for Android etc. This means that you need to preprocess your code, including any public fields to exclude the code from the compiler. This seems fine since MovieTexture fields will get serialized as development happens in the Editor, but if there were classes that didn't exist on the desktop, but needed to get serialized for Android etc. then this wouldn't work. Smells bad to me.
Answer by Incept_test · Apr 24, 2016 at 03:09 PM
I tried to make this plugin demo(10 seconds video max) work on android but keep getting the error that I can not build using $$anonymous$$ovieTextures on Android, I removed all references to movie textures in my coding so I think there's a reference to $$anonymous$$ovieTexture in the source code of SPlugin which withheld unity from building at all(both asset bundles and build for Android). It works fine on pc though but our main target is Android.