Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

MovieTexture has no definition for iPhone/Android

Discussion in 'Scripting' started by vladk, Jan 9, 2011.

  1. vladk

    vladk

    Joined:
    Jul 10, 2008
    Posts:
    153
    Hello,

    Here is the problem I have.

    I've got a multiplatform-wannabe project :D

    It has some use of MovieTexture objects, but when I try to make a build for a mobile it drops me an error: "error CS0246: The type or namespace name `MovieTexture' could not be found. Are you missing a using directive or an assembly reference?"

    As far as I understand you guys (Unity development team) forgot to make a MovieTexture object for mobile platforms, which is really bad for me, because since there are no preprocessor directives available I can't do something like:

    #ifdef IPHONE
    #else
    public MovieTexture mTex;
    #endif

    So how can I solve this issue without making 2 separate folders in my SVN, because I really need to make changes for all the files in project (not only mobile related)?

    Help me please! :(
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,598
    They didn't forget it, its technically not possible to use MovieTextures on mobiles, only fullscreen playback, so making any code that tries to use it fail is the best thing to do so you know the code is not mobile usable.


    As for your approach: You are looking for
    Code (csharp):
    1.  
    2. #if !UNITY_IPHONE
    3.   ... use movie texture
    4. #else
    5.   ... now we are on iphone
    6. #endif
    7.  
    :)

    Take look at the manual page for platform dependent compilation for all possible defines
     
  3. vladk

    vladk

    Joined:
    Jul 10, 2008
    Posts:
    153
    yeah, thanks, actually already figured out that myself.

    I just created this:

    Code (csharp):
    1. //#define MOBILE_PLATFORM
    2.  
    3. using UnityEngine;
    4. using System.Collections;
    5.  
    6. #if (MOBILE_PLATFORM)
    7. public class MovieTexture : Texture
    8. {
    9.     // Constructors
    10.     public MovieTexture ();
    11.    
    12.     // Methods
    13.     public void Play ();
    14.     public void Stop ();
    15.     public void Pause ();
    16.    
    17.     // Properties
    18.     public AudioClip audioClip { get; }
    19.     public bool loop { get; set; }
    20.     public bool isPlaying { get; }
    21.     public bool isReadyToPlay { get; }
    22. }
    23. #endif
    so when you uncomment the first row - you're ready to go mobile compilation :) A bit crippled solution but it works.
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,598
    I would recommend to do yourself the favor and follow the adviced manual page, then yo ucan get rid of this crippled solution in favor of one that will work just automatically
     
  5. vladk

    vladk

    Joined:
    Jul 10, 2008
    Posts:
    153
    can you provide a link? because it's to abstract to say "see the manual" - I don't even know what do I need to find.

    P.S. wait a minute, Marc, is that you? We've been working together on "Zombies" project, remember? :)
     
    Last edited: Jan 11, 2011
  6. AndreasBL

    AndreasBL

    Joined:
    May 2, 2010
    Posts:
    5
  7. quantum_rez

    quantum_rez

    Joined:
    Oct 23, 2012
    Posts:
    35
    sorry i know this is old thread, but i have the same problem i can't build my MovieTexture on android, but i can play it on standalone.

    i look the code above solved it, but i don't understand how to use it and what's inside of that code..

    anyone can please help me?

    this is my code for detail :

    Code (csharp):
    1.  
    2.  
    3. using UnityEngine;
    4. using System.Collections;
    5.  
    6. [RequireComponent(typeof(AudioSource))]
    7. [RequireComponent(typeof(AudioListener))]
    8.  
    9. public class Movie : MonoBehaviour {
    10.    
    11.     public MovieTexture movie;
    12.    
    13.     private float movieTimer;
    14.    
    15.     void OnGUI(){
    16.         GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), movie);
    17.         movie.Play();
    18.        
    19.         if(movie.duration < movieTimer){
    20.             movie.Stop();
    21.             print("Movie Finish");
    22.         }
    23.     }
    24.    
    25.     // Use this for initialization
    26.     void Start () {
    27.    
    28.     }
    29.    
    30.     // Update is called once per frame
    31.     void Update () {
    32.         movieTimer += Time.deltaTime;
    33.     }
    34. }
    i hope anyone want to help me here. :D

    Thanks
     
  8. Lumen-Digital

    Lumen-Digital

    Joined:
    Aug 3, 2012
    Posts:
    13
    The code above simply creates a stub class to replace the desktop MovieTexture class that is unavailable on mobile platforms. It doesn't actually allow you to play a MovieTexture on a mobile device.
     
  9. batmobile

    batmobile

    Joined:
    May 20, 2013
    Posts:
    104
    Of course mobiles can use movie textures.
     
  10. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    548
    I used following way to run movie texture on android platfrom

    Code (CSharp):
    1. //#define MOBILE_PLATFORM
    2. using UnityEngine;
    3. using System.Collections;
    4. #if (MOBILE_PLATFORM)
    5. public class MovieTexture : Texture
    6. {
    7.     // Constructors
    8.     public MovieTexture ();
    9.  
    10.     // Methods
    11.     public void Play ();
    12.     public void Stop ();
    13.     public void Pause ();
    14.  
    15.     // Properties
    16.     public AudioClip audioClip { get; }
    17.     public bool loop { get; set; }
    18.     public bool isPlaying { get; }
    19.     public bool isReadyToPlay { get; }
    20. }
    21. #endif
    But after using above code I am getting following errors.

    Screen Shot 2015-07-04 at 1.19.58 pm.png

    Please give some suggestion on how to come over this problem?
     
  11. vladk

    vladk

    Joined:
    Jul 10, 2008
    Posts:
    153
    You should just make it abstract or define the constructor. I wrote it just as an example.
     
  12. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    548
    @vladk, I will try this and reply back to you.
    Thanks for your reply :)
     
  13. riccardo_fablab

    riccardo_fablab

    Joined:
    Sep 15, 2015
    Posts:
    2
    no, they couldn't, and they still can't :(

    For those who will stumble on this thread, and will read the last few posts (which are technically correct but kind of misleading if you don't read the whole thread): as of 2015/10/6, MovieTextures are still not supported on Android and iOs, and the aforementioned workaround is just a mean to allow a smooth compilation on mixed platforms (and not a way to enable some hidden feature).

    If you want to play movie texture-like content, you can roll it yourself (ouch!) or use one of the many plugin on the store. The good news is that they are quite cheap, and work with unity personal edition (for those who are eligible), the bad one, is that your mileage for what concern the integration might vary...
     
  14. batmobile

    batmobile

    Joined:
    May 20, 2013
    Posts:
    104
    Unity has no proper support for this. But you can make a native plugin and render the video to an unity texture, the mobile phones themselves support this. I wrote such a plugin for Android a while ago and can confirm it works, although you need some opengl experience. I made a similar one for ios.

    The majority of "video" players in the unity store are just able to show slideshows from a series of images you extract from a video. This results in gigantic "video" files, with no synced audio track, and is not the proper way to play videos.
     
  15. Lucas7CL

    Lucas7CL

    Joined:
    Sep 28, 2015
    Posts:
    5
    @riccardo_fablab @batmobile which plugin would you suggest? I am making a mobile platform project, that uses videotexture with alpha. I already made the alpha videotexture work using a special shader and a "special video" (see sample pic attached): has two sections, the upper one has the color map, and the lower one has the mask.
    I have done this kind of project using Total Immersion D´fusion SDK, but it´s not supported anymore.... now I am having headaches using Unity + Vuforia!
    Thanks in advanced for your advice
     

    Attached Files:

  16. Razek07

    Razek07

    Joined:
    Sep 10, 2014
    Posts:
    2
    Hi, sorry, wich plugin do you recommend?

    Thank you in advance!
     
  17. Adrian_pro

    Adrian_pro

    Joined:
    May 23, 2013
    Posts:
    21
    How you manage to write the code to work on Android?
     
  18. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    196
    Bummer, maybe an animated GIF is the solution?
     
  19. sovan

    sovan

    Joined:
    Jun 22, 2015
    Posts:
    2
    @Dreamora @gayasoft Could you let us know how to use the movietexture for mobile devices. None of the above answer lets me make an android build.
     
  20. Tecknowser

    Tecknowser

    Joined:
    Jan 10, 2017
    Posts:
    1
    What to do if I'm not using the script. Because the error only appears when I'm not using.
     
  21. CloudFire

    CloudFire

    Joined:
    Dec 8, 2015
    Posts:
    27
    Hi All I have also same problem with this. Is there any way that we can streaming the video from online I dont want using any plugins.
     
  22. imran4125

    imran4125

    Joined:
    Jul 12, 2017
    Posts:
    11

    Hi,
    Did you find any luck with playing video in android with alpha transparency ? My requirement is same as yours and i have the video file like your same...can you help me playing it in android ? Thanks
     
  23. imran4125

    imran4125

    Joined:
    Jul 12, 2017
    Posts:
    11
    Hi,
    Did anyone else has had some luck playing video in unity on mobile using movie texture?
    Thanks
     
  24. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    548