- Home /
iOS: Play video in Landscape, rest in Portrait
Hi!
We are developing an app (with lots of videos) that we want to render in Portrait mode, except when playing a video. We would like the orientation to be on Autorotate, or at least LandscapeLeft, when a video is playing but can't get this to work at all.
I've searched a lot for answers on this but can't find anything that will work for us. Setting "Screen.orientation = ScreenOrientation.LandscapeLeft" in code before playing a video doesn't work. Neither does changing the orientation setting in "Player Settings" in Unity; it just messes up the UI when not playing a video.
Any help would be very much appreciated! Our release date is very very soon and being forced to play videos in Portrait mode is a major drawback for our app, considering videos is one of the biggest features in it.
Unity version: 3.5.7
//Louise
Did you ever find the solution to this issue ? I am using Unity 5 now and I have the exact same issue.
Thanks.
kenny_cj: I'm sorry but I have kinda forgotten how I solved this (it was 2 years ago). One thing comes to $$anonymous$$d though, I think I had "Autorotation" on in Player Settings and then I controlled the orientation in code (Portrait at start of app, Autorotation right before playing a movie then back to Portrait after played movie). Back then there was some kind of bug with setting the rotation in Player Settings I think. I'm sorry I can't be of more help!
//Louise
as you said , i set oritation landscape before play , and reset it to portrait follow the Handheld.PlayFullScreen$$anonymous$$ovie . the video still play on the portrait mode. could you tell me what should i do ?
This was years ago now but I think I did set it to Landscape mode by ivoking my own "Play$$anonymous$$ovie()" function 0.5 seconds (or something) after I set the orientation to Landscape. Then, after the movie has finished playing, I put it back to Portrait by invoking my own "SetOrientationToPortrait()" function after like 0.5-1.0 seconds. This is to make sure Unity has time to finish Handheld.PlayFullScreen$$anonymous$$ovie() before trying to set the orientation to Portrait.
With invoking I mean Unity's Invoke() function:
void Start()
{
Screen.orientation = ScreenOrientation.LandscapeLeft;
Invoke("Play$$anonymous$$ovie", 0.5f);
}
private void Play$$anonymous$$ovie()
{
Handheld.PlayFullScreen$$anonymous$$ovie(...);
Invoke("SetOrientationToPortrait, 0.5f);
}
private void SetOrieantationToPortrait()
{
Screen.orientation = ScreenOrientation.Portrait;
}
Haven't tried this code but I believe I did something like that. Good luck!
Thanks for the reply Louise. In the end, I added a WaitForSeconds in my coroutine just after setting the screen orientation to make sure that the orientation change was right before playing the video.
Answer by Graham-Dunnett · Jul 16, 2013 at 03:39 PM
There is code in AppController.mm
that handles the movie viewer, search for video view controller
. It's possible that changing some of the logic there for handling the orientation of the UnityVideoViewController
will achieve what you want. Alternatively, rotate the video before you render it out, so the video is portrait and not landscape. When you play a portrait video back in a portrait game, it'll look landscape, if you get what I mean.
(Have you checked that playing back landscape video when the game is portrait is acceptable to Apple?)
Thanks for quick answer Dunnett! Sadly, we've already tried changing some stuff in AppController.mm but without success. If someone could pin-point something critical in AppController.mm related to our problem that we could try changing, it would be great though.
About rotating the video before rendering: do you mean rotating the video in an editing program beforehand? We considered that too, but the video controller (which is very necessary in our kind of app) will still be in Portrait mode, which would look a bit ugly.
(Haven't checked with Apple yet but our app is not a game and I would be very surprised if they wouldn't accept it. You never know though, I guess. x))
Answer by rohankad · Aug 28, 2015 at 10:23 AM
@LouiseW If you're using Handhed.PlayFullScreenMovie
API to play, then you can use the parameter
FullScreenMovieScalingMode fs = FullScreenMovieScalingMode.Application.DeviceOrientation
It's mentioned here http://docs.unity3d.com/ScriptReference/Handheld.PlayFullScreenMovie.html
I never tried this thing, hope you'll get some idea about changing it on runtime from the above link.
Thanks
Answer by vfxjex · Aug 04, 2016 at 12:54 PM
Uncheck the Portrait orientation and that should make the movie to land scape