- Home /
video & mobile
hi everybody, I wanted to know how to read a little intro video in a mobile application?
For now, I have this code that there is supposed to work on phones but when we tested, it does not work :/
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (GUITexture))]
[RequireComponent (typeof (AudioSource))]
public class SplashScriptScreen : MonoBehaviour
{
public float m_timer = 12.0f;
public string m_loadLevel = "MainMenu";
//the GUI texture
private GUITexture videoGUItex;
#if UNITY_STANDALONE_WIN
//the Movie texture
private MovieTexture mTex;
#endif
//the AudioSource
private AudioSource movieAS;
//the movie name inside the resources folder
public string movieName;
void Awake()
{
//get the attached GUITexture
videoGUItex = this.GetComponent<GUITexture>();
//get the attached AudioSource
movieAS = this.GetComponent<AudioSource>();
#if UNITY_STANDALONE_WIN
//load the movie texture from the resources folder
mTex = (MovieTexture)Resources.Load("Video/"+movieName);
//set the AudioSource clip to be the same as the movie texture audio clip
movieAS.clip = mTex.audioClip;
//letterbox
float newHeight = -(Screen.height-(Screen.width/(mTex.width/(float)mTex.height)));
float yOffset = (-Screen.height-newHeight)/2;
videoGUItex.pixelInset = new Rect(Screen.width/2, yOffset, 0, newHeight);
#endif
}
//On Script Start
void Start()
{
StartCoroutine("SplashDisplay");
}
IEnumerator SplashDisplay()
{
#if UNITY_ANDROID
iPhoneUtils.PlayMovie("Intro.mp4", Color.black);
#else
//set the videoGUItex.texture to be the same as mTex
videoGUItex.texture = mTex;
//Plays the movie
mTex.Play();
//plays the audio from the movie
movieAS.Play();
#endif
yield return new WaitForSeconds(m_timer);
Application.LoadLevel(m_loadLevel);
}
}
mp4 format give me some problems at the moment of the importation in Unity (Quicktime problems). So I convert my video in ogv then I import it in Unity and this works. But, this format is not suppoted on mobile. mp4 and 3gpp only on Android.
If someone already import and use a video on a mobile application, I'm willing him to explain how.
And we follow the instructions on $$anonymous$$obile page but create a folder named Strea$$anonymous$$gAssets doesn't solve the problem (except if we do this wrong)
Your answer
Follow this Question
Related Questions
Android MP4 Video Playback 2 Answers
Handheld.PlayFullScreenMovie memory leak? 1 Answer
Record a video in unity on mobile (Android, IOS) 1 Answer
StreamingAssets on Android. 1 Answer