Unity 4.0 video playback

Hi,

I have a problem with the video playback in Unity4.0 i’m using NGUI to make a GUI and when i click on a button the movie starts playing with full control mode. But when i click on Done on the IOS movie player the screen goes back to the app but i don’t get focus on the Unity app and the video sound starts playing again.

I’ve tried the 2 movieplayback functions:
Handheld.PlayFullScreenMovie()
iPhoneUtils.PlayMovie() (which is deprecated)

But they both share the same problem. Anyone got a fix for this? Or could it be a problem that my iPad is a jailbroken device?

Please post bit more of code how and when you are launching video playback. Most likely your code is not properly managing the state and just restarts video playback.

The code i’m using now:

iPhoneUtils.PlayMovie("Chapter1.mp4", Color.black, iPhoneMovieControlMode.Full, iPhoneMovieScalingMode.AspectFit);

I mean some moooooore code :slight_smile: like the lines that surround it…

Right, here’s the whole script:

public static var MM : MenuManager; 

private var button01 : GameObject; 
private var button02 : GameObject;
private var button03 : GameObject;
private var button04 : GameObject; 
private var button05 : GameObject; 
private var hButton : GameObject;
private var overlay : GameObject;
private var videoPanel : GameObject;

private var radialActive : boolean = false;  
private var videoPanelActive : boolean = false;  

private var cube : GameObject;

public var radialTime : float; 


function Awake()
{
	MM = this;
	
	videoPanel = GameObject.Find("Video Page Panel");
	overlay = GameObject.Find("Overlay");
	videoPanel = GameObject.Find("Video Page Panel");
	cube = GameObject.Find("Cube");
	button01 = GameObject.Find("Button 01"); 
	button02 = GameObject.Find("Button 02");
	button03 = GameObject.Find("Button 03");
	button04 = GameObject.Find("Button 04");  
	button05 = GameObject.Find("Button 05");
	hButton = GameObject.Find("Button Home"); 
	
	TweenAlpha.Begin(overlay, 0F, 0);

}

function Home()
{ 
	if(!radialActive)
	{ 
		MakeRadial();
	}
	else
	{
		ReturnRadial();
	}
	
}  

function MakeRadial()
{  
		TweenAlpha.Begin(overlay, 1F, 1F);
		iTween.RotateTo(hButton, {"z": -45, "time": 0.6});
		iTween.MoveTo(button01, {"x": -937.9, "y": -263.8788, "z": 0, "time": radialTime, "islocal": true, "easetype": iTween.EaseType.easeOutBack});
		yield WaitForSeconds(0.25);
		iTween.MoveTo(button02, {"x": -770.3784, "y": -291.3788, "z": 0, "time": radialTime, "islocal": true, "easetype": iTween.EaseType.easeOutBack});
		yield WaitForSeconds(0.25);
		iTween.MoveTo(button03, {"x": -627.3784, "y": -378.3788, "z": 0, "time": radialTime, "islocal": true, "easetype": iTween.EaseType.easeOutBack});
		yield WaitForSeconds(0.25);
		iTween.MoveTo(button04, {"x": -540.3784, "y": -524.3788, "z": 0, "time": radialTime, "islocal": true, "easetype": iTween.EaseType.easeOutBack});
		yield WaitForSeconds(0.25);
		iTween.MoveTo(button05, {"x": -522.8784, "y": -688.8788, "z": 0, "time": radialTime, "islocal": true, "easetype": iTween.EaseType.easeOutBack, "oncompletetarget": gameObject, "onComplete": "setRadialTrue"});
}

function ReturnRadial()
{ 
		TweenAlpha.Begin(overlay, 1F, 0F);
		iTween.MoveTo(button01, {"x": -910, "y": -659, "z": 0, "time": radialTime, "islocal": true, "easetype": iTween.EaseType.easeInBack}); 
		yield WaitForSeconds(0.25); 
		iTween.MoveTo(button02, {"x": -910, "y": -659, "z": 0, "time": radialTime, "islocal": true, "easetype": iTween.EaseType.easeInBack}); 
		yield WaitForSeconds(0.25);
		iTween.MoveTo(button03, {"x": -910, "y": -659, "z": 0, "time": radialTime, "islocal": true, "easetype": iTween.EaseType.easeInBack}); 
		yield WaitForSeconds(0.25);
		iTween.MoveTo(button04, {"x": -910, "y": -659, "z": 0, "time": radialTime, "islocal": true, "easetype": iTween.EaseType.easeInBack}); 
		yield WaitForSeconds(0.25); 
		iTween.MoveTo(button05, {"x": -910, "y": -659, "z": 0, "time": radialTime, "islocal": true, "easetype": iTween.EaseType.easeInBack, "oncompletetarget": gameObject, "onComplete": "setRadialFalse"});
		iTween.RotateTo(hButton, {"z": 0, "time": 0.6});  
		
}

function Button01()
{
	 if(videoPanelActive)
	 {
	 	iTween.MoveTo(videoPanel, {"x": 2200, "time": 1.5, "islocal": true});
	 }
	 ReturnRadial();
}

function Button02()
{ 
	cube.renderer.material.color = Color.cyan; 
	ReturnRadial();
} 

function Button03()
{ 
	cube.renderer.material.color = Color.green; 
	ReturnRadial();
} 

function Button04()
{ 
	cube.renderer.material.color = Color.magenta; 
	ReturnRadial();
}

function Button05()
{ 
	iPhoneUtils.PlayMovie("Chapter1.mp4", Color.black, iPhoneMovieControlMode.Full, iPhoneMovieScalingMode.AspectFit);
	videoPanelActive = true;
	ReturnRadial();
}

function setRadialTrue()
{ 
	radialActive = true;
} 

function setRadialFalse()
{
	radialActive = false;
}

The video’s are placed in the StreaminAssets folder.

so any idea how to fix this problem?

This code is quite tightly integrated with your UI plugin, I can’t tell if everything is ok there or not. Try adding Debug.Log () statements before showing movie and just after showing it and then check Xcode console if there are multiple log entries for launching video.

Thx i found the problem, the event was firing multiple times which made the video start playing multiple times and stopping multiple times. thx for the help!