Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Handheld.PlayFullScreenMovie on Android

Discussion in 'Android' started by tinmanassets, Mar 9, 2012.

  1. tinmanassets

    tinmanassets

    Joined:
    Jan 6, 2009
    Posts:
    61
    Hey All!

    I have been banging my head on this one for a few days now and I am hoping someone here can help me out a bit. I am doing Android deployment (Pro Unity, Pro Android if it matters) and I am trying to get the Handheld.PlayFullScreenMovie working.

    What I have is an empty scene with one plane that has the our game logo on it (so you will see the logo when the movie is not playing) and then one object that simply calls Handheld.PlayFullScreenMovie. (and a camera, of course :)

    like so:
    Code (csharp):
    1.  
    2.         public string moviePath = "orlandesIntroGood480.320.mp4";
    3.     // Use this for initialization
    4.     void Start () {
    5.         Invoke("doPlay",1.0f);
    6.     }
    7.    
    8.     void doPlay()
    9.     {
    10.            Debug.Log("Starting Movie: " + moviePath);  
    11.            Handheld.PlayFullScreenMovie (moviePath, Color.black, FullScreenMovieControlMode.Full);
    12.            Debug.Log("All Done!"); 
    13.     }
    14.  
    I have the movie in a Streaming Assets folder that is at the top level of the hierarchy, and it is an mp4 container with h.264 baseline. (tho I have tried a few other variations, following the guidelines here: http://developer.android.com/guide/appendix/media-formats.html )

    When I run it on device, I see the logo textured plane for 1 second, then it fades very quickly to black and fades just as quickly back to the scene. The fade to black and back probably takes about half to 3/4 of a second. I never see the 'All Done' debug log.

    The logcat has no big errors, here is the relevant logcat output:

    Code (csharp):
    1.  
    2. I/Unity   (11574): Starting Movie: orlandesIntroGood480.320.320.mp4
    3. I/Unity   (11574): UnityEngine.Debug:Internal_Log(Int32, String, Object)
    4. I/Unity   (11574): UnityEngine.Debug:Log(Object)
    5. I/Unity   (11574): BBHandheldMoviePlayer:doPlay() (at /Users/bsmith/dev/Gamebooks/UnityDev/GAEnginePrototype/Assets/Scripts/BBHandheldMoviePlayer.cs:19)
    6. I/Unity   (11574):  
    7. I/Unity   (11574): (Filename: /Users/bsmith/dev/Gamebooks/UnityDev/GAEnginePrototype/Assets/Scripts/BBHandheldMoviePlayer.cs Line: 19)
    8. I/Unity   (11574):
    9. I/ActivityManager( 2485): Starting activity: Intent { flg=0x10000 cmp=au.com.tinmangames.gamebook1/com.unity3d.player.VideoPlayer (has extras) }
    10. D/PhoneWindow(11574): couldn't save which view has focus because the focused view com.unity3d.player.UnityPlayer$17@484abfc8 has no id.
    11. I/Unity   (11574): onPause
    12. I/Unity   (11574): All Done!
    13. I/Unity   (11574): UnityEngine.Debug:Internal_Log(Int32, String, Object)
    14. I/Unity   (11574): UnityEngine.Debug:Log(Object)
    15. I/Unity   (11574): BBHandheldMoviePlayer:doPlay() (at /Users/bsmith/dev/Gamebooks/UnityDev/GAEnginePrototype/Assets/Scripts/BBHandheldMoviePlayer.cs:21)
    16. I/Unity   (11574):  
    17. I/Unity   (11574): (Filename: /Users/bsmith/dev/Gamebooks/UnityDev/GAEnginePrototype/Assets/Scripts/BBHandheldMoviePlayer.cs Line: 21)
    18. I/Unity   (11574):
    19.  
    20.  
    Which I have no idea what that means.

    Any help would be greatly appreciated!

    Cheers!
    -Ben Britten
     
  2. tinmanassets

    tinmanassets

    Joined:
    Jan 6, 2009
    Posts:
    61
    Ok, so I spent nearly a half an hour writing the above post. I double checked everything to make sure I wasnt being a jackass and doing something really stupid.

    Only AFTER I had posted this I noticed that the moviePath had been typoed somewhere along the lines in the editor to be "orlandesIntroGood480.320.320.mp4" (which has one too many '320's)

    So I changed it and Viola! it works now!

    So. I am an eeediot. Apologies for wasting everyone's time!

    Cheers!
    -Ben
     
    Beennn and topherbwell like this.
  3. huruena

    huruena

    Joined:
    Jul 31, 2012
    Posts:
    2
    Hi Ben,
    I´m trying to include an small video in my android project, but I have problems. Please help me!!! I created the file StreamingAssets, inside i put my video named pruebaVideo.mp4 and create the c# file with the Handheld.PlayFullScreenMovie but nothing happened. You know that could be my problem with the construction?


    using UnityEngine;
    using System.Collections;

    public class videoplay : MonoBehaviour {

    // Use this for initialization

    void Start () {

    Handheld.PlayFullScreenMovie ("pruebaVideo.mp4", Color.black, FullScreenMovieControlMode.Full);

    }


    }


    Thank you,

    Hugo Urueña
     
  4. tinmanassets

    tinmanassets

    Joined:
    Jan 6, 2009
    Posts:
    61
    One thing to check is to make sure that you have compressed the video properly. Just because it is an mp4 doesnt mean that it has the right codec settings. The docs say:

    H.264 Baseline Profile Level 3.0 video, up to 640 x 480 at 30 fps. Note that B frames are not supported in the Baseline profile.
    MPEG-4 Part 2 video (Simple Profile).

    So double check that!

    Cheers!
    -Ben
     
  5. cloudfun

    cloudfun

    Joined:
    Oct 2, 2011
    Posts:
    35
    hi anyone could help me?
    im trying to execute from my gui the visualitation of a .mp4 video

    public void playbutton12_Click(iGUIButton caller){
    // arranco el video
    Handheld.PlayFullScreenMovie ( "90.mp4", Color.black, FullScreenMovieControlMode.Full,FullScreenMovieScalingMode.AspectFit);

    }
    on ios woks ok
    the docs of unity sayd that is the same instruction Handheld.PlayFullScreenMovie
    i put the videos on the streamingassets folder, and theres no errors but the video doesnt play on the device
    is android 4.0

    the videos alone play ok on the device , but im not able to load and play from my app

    someone could help me?

    thanks in advance
     
  6. Val_89

    Val_89

    Joined:
    Dec 11, 2013
    Posts:
    2
    hi thr...
    i am trying to develop a AR program using Unity 3d ,run in android.i am adding video in to the project and i have some scripting problem.Then,i got to know that android doesnt support "MovieTexture".Since,then i try to figure out some other script which support my project but i am lost.My script is as below
    PLEASE SOME ONE ASSIST ME.......I AM LOOKING FORWARD FOR THE THE REPLY ASAP........
    using UnityEngine;
    using System.Collections;

    [RequireComponent(typeof(AudioSource))]

    public class ImageTargetVideoPlay : MonoBehaviour {
    public MovieTexture movie;

    // Use this for initialization
    void Start () {
    renderer.material.mainTexture = movie as MovieTexture;
    audio.clip = movie.audioClip;
    movie.Play ();
    audio.Play ();

    }
    void OnMouseDown()
    {
    movie.Stop();
    Application.LoadLevel("");
    }

    // Update is called once per frame
    void Update () {
    if(!movie.isPlaying)Application.LoadLevel("");
    }
    }
     
  7. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
  8. magonicolas

    magonicolas

    Joined:
    Dec 4, 2013
    Posts:
    30
    Hello, I have make this work, But How Can I Loop the Video?

    Best!
     
  9. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    One little observation, it not stated anywhere in the manual, but path is case sensitive! (at least on Android devices)... I have this line on my code:

    Handheld.PlayFullScreenMovie("Intro.mp4",Color.black,FullScreenMovieControlMode.Hidden);

    It worked fine... then I upgraded the video to a newer version, but I accidentally changed the name of the file from "Intro.mp4" to "intro.mp4" and re-imported it, but when I tested on the Android device the video didn't played, I didn't had a clue about what was going on, but then when I examined the previous version I realized the name of the file had an uppercase "I", so I renamed the file and re-imported it again, this time it worked all right... so better be sure your file names are exactly the same you use in your code.