- Home /
Android Handheld.PlayFullScreenMovie Orientation Switch
How can I get the Android device to properly switch between orientations before and after a movie plays?
I have a co-routine that is working great on iOS devices, but not so well on Android. The concept: A simple toggle allows a switch between portrait mode and landscape mode, directly before playing a movie full screen. (Otherwise, the app is locked in portrait mode.)
Results:
If I do not switch orientation, the movie plays. If I only switch orientation once, (to landscape), the video plays. If I switch the orientation to landscape, play the video, and then back to protrait, the video 99% of the time does not play. (It did randomly work once....), and the screen will go black. I did get a dialogue box once asking me if I wanted to close the video or continue waiting for it (while the screen is black).
I know the orientation has changed as I can see the devices menu icons rotate appropriately.
There is an order of operations item I am missing - as the debug log shows that I am trying to switch back to portrait view even before the movie starts playing.
Code:
IEnumerator ScreenTapped () {
if (url == null)
{
Debug.Log("WARNING: Could not open URL: url is null");
}
else if (url.Equals(""))
{
Debug.Log("WARNING: Could not open URL: url is empty");
}
else
{
if ( StreamVideo )
{
if(PlaybackLandscape)
{
Debug.Log("Switching to Landscape Mode");
iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Landscape;
yield return new WaitForSeconds(.1f);
}
Debug.Log("About to Play Movie");
Handheld.PlayFullScreenMovie(url, Color.black, FullScreenMovieControlMode.Full, FullScreenMovieScalingMode.AspectFit);
Debug.Log("Movie Finished");
if(PlaybackLandscape)
{
Debug.Log("Switching to Portrait Mode");
iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Portrait;
}
yield return new WaitForSeconds(.1f);
}
else
{
Application.OpenURL(url);
}
}
// Set this to false since we are about to exit this coroutine
m_ScreenTappedActive = false;
}
Not solved - but worked around. I just enable auto rotate for portrait only, then have a boolean toggle to enable the other 3 axis while the video is playing. Still can't figure out a way to consistently have statements go off after the Android finally 'pauses' Unity, then plays the movie, then returns back to Unity.
Hey! Have you found the solution to your problem? I suspect that your code isn't working cos it never goes into the if(StreamVideo) block, rather strea$$anonymous$$g the video through Android's built-in player by having Application.OpenURL(url) called. I might be wrong, but lemme know if you've found the solution. Cheers!
Answer by centralvox · May 30, 2013 at 07:31 AM
hi, i have a solution. use this flow
screen orientation to landscape
play the video
wait for 3 seconds and switch it to portrait
so when the video is getting played the unity will switch to portrait on background and users will not be able to see it,when the video is complete users can see portrait view at unity, smooth transition
regards T S Gokul
Your answer
![](https://koobas.hobune.stream/wayback/20220613074709im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to check if Handheld.PlayFullScreenMovie has stopped playing 2 Answers
want to run a vid (movie) on my android application 2 Answers
Android screen orientation: why am I getting wrong screen size values? 1 Answer
Keep unity running when minimized on iOS and Android 2 Answers
How to make looped background?(Character enters left side and appears from right) 2 Answers