Having issues with ScreenOrientation.Portrait to Screen.AutoOrientation and Back to Portrait

My app is in portrait view for the iPhone, but when I play a video I want to set the orientation to Auto to allow the user the choice to see it full screen or not. I have iOS Pro and have tried Handheld.PlayFullScreenMovie along with prime31’s etcetera 2 plugin that has movie player capabilities. I get the same results which is when right before the movie starts playing I set it to AutoRotation and on movie complete I set it back to Portrait. The autorotation works great but when the app comes back, it does not switch back to portrait, it stays in landscape if that’s where the movie left off. It not ONLY stays in Landscape but it flickers, so the UI keeps switching between LandscapeRight and LandscapeLeft even though I have never set it to Landscape anywhere. I tried having Unity wait a second before it switches UI hoping that would help but no luck. My code is below.

void _playMovie (string __mediaUrlStr)
{
       	Handheld.StartActivityIndicator();
       	_allowAutoRotation(true);
       	EtceteraTwoManager.moviePlayerDidFinishEvent += _moviePlayerDidFinishEvent;
       	EtceteraTwoBinding.playMovie( __mediaUrlStr, false, true, true );
}
        
private void _moviePlayerDidFinishEvent()
{
       	Debug.Log( "moviePlayerDidFinishEvent" );
       	_allowAutoRotation(false);
       	Handheld.StopActivityIndicator();
       	EtceteraTwoManager.moviePlayerDidFinishEvent -= _moviePlayerDidFinishEvent;
       	StartCoroutine(_delaySwitchView());
}
    
private void _allowAutoRotation( bool __statusBol )
{
	Debug.Log ("_allowAutoRotation called..."+__statusBol);
	if ( __statusBol)
	{
		Screen.orientation = ScreenOrientation.AutoRotation;
		Screen.autorotateToLandscapeLeft = true;
		Screen.autorotateToLandscapeRight = true;
		Screen.autorotateToPortrait = true;
		Screen.autorotateToPortraitUpsideDown = true;
	}
	else
	{
		Screen.autorotateToLandscapeRight = false;
		Screen.autorotateToPortrait = false;
		Screen.autorotateToPortraitUpsideDown = false;
		Screen.autorotateToLandscapeLeft = false;
		Screen.orientation = ScreenOrientation.Portrait;
	}
}
    
IEnumerator _delaySwitchView ()
{
       	yield return new WaitForSeconds(1f);
       	ViewToMediatorSig.Dispatch(PrefabIdStr, "switchview");
}

Hi,

We have a known bug that has similar symptoms to this: Unity Issue Tracker - iOS 8.3 SDK causes orientation to reverse on every frame after Unity Ads is closed

It’s not certain to be the same issue, but I mentioned it so you can track its progress and vote for it if you like.

I can’t say when that will be fixed, so for a workaround could you use the recommendation here? Unity - Manual: Movie Textures (see “The video player does not respect the device’s orientation”). The trouble is, the user would be holding the device in portrait mode initially, so playback would start in that mode. You could just restart the video in landscape mode if they changed orientation; it depends how long it is etc.

I hope this helps,

Dan,
Unity Support