Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Playing video on Android

Discussion in 'Android' started by FennecMoon, Oct 14, 2015.

  1. FennecMoon

    FennecMoon

    Joined:
    Aug 12, 2015
    Posts:
    13
    I know this question has been asked in numerous threads; however, none of the answers have worked for me, so I am asking again (and I apologize if this should have been asked in a different area, I'm still new to Unity and the forum.)

    How do I use 'Handheld.PlayFullScreenMovie' to play a movie in my Android app?

    My code is:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class nGPm : MonoBehaviour {
    5.  
    6.     void Start()
    7.     {
    8.  
    9.         Handheld.PlayFullScreenMovie("http://www.movie.address/title.mp4", Color.red, FullScreenMovieControlMode.Full);
    10.  
    11.     }
    12.     }
    13.  
    When I play this on my Android device I get simply a blue screen with black bars. The color red in the code is ignored, and no video or movie controls are displayed. From everything I've read, this seems like it should be such a simple task, but I have had no luck. Any help will be greatly appreciated.
     
  2. MaestroMMT

    MaestroMMT

    Joined:
    May 31, 2015
    Posts:
    26
    Hello,

    The code below seems to be correct, are you sure that you are testing on a android device ? (On Unity Editor, it couldn't work). On PC, you will need movie texture and .ogv or ogg.
     
  3. FennecMoon

    FennecMoon

    Joined:
    Aug 12, 2015
    Posts:
    13
    Yup, I tried it on my Alcatel Onetouch, which has properly played all of my previous projects. Should I be placing the code in something other than Start()?
     
  4. MaestroMMT

    MaestroMMT

    Joined:
    May 31, 2015
    Posts:
    26
    All my Handled.PlayFullScreenMovie call are placed in other function than Start().

    Code (CSharp):
    1.     void LoadVideo(string url)
    2.     {
    3.  
    4.         #if (UNITY_IOS || UNITY_IPHONE || UNITY_ANDROID)
    5.        
    6.         Handheld.PlayFullScreenMovie(YoutubeVideo.GetComponent<YoutubeVideo>().GetYoutubeDirectLink(url),Color.black);
    7.        
    8.         #endif
    9.  
    10.     }
     
  5. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    @FhVG check the log of your device to make sure there isn't something wrong with the video format or url.

    Code (csharp):
    1. >adb logcat
     
    MaestroMMT likes this.