Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ayaz alavi · Sep 28, 2013 at 01:13 PM · unity ios

Unity iOS: Set Orientation for Handheld.PlayFullScreenMovie

Hi,

I am using following code to quickly switch from Portrait to landscape before playing video and then again back to portrait after video playing done.

 IEnumerator playVideo() {
         Screen.orientation = ScreenOrientation.Landscape;
         yield return new WaitForSeconds(.1f); 
         yield return new WaitForEndOfFrame();
         Handheld.PlayFullScreenMovie (background_.lastTrackableVideoPath_, Color.black, FullScreenMovieControlMode.Full, FullScreenMovieScalingMode.AspectFit);
         Screen.orientation = ScreenOrientation.Portrait;
         yield return new WaitForSeconds(.1f); 
     }

Above code is not working and video is always played in portrait. I have iOS 6.0.

Any idea why this is happening?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Abdullah-Khalid · Mar 03, 2017 at 06:22 PM 0
Share

hey @Deathfate can you help please ? i am unable to play video horizontally.. actually video played horizontally but when it close UI is disturbed.

here is ur solution i tried. http://answers.unity3d.com/questions/544848/unity-ios-set-orientation-for-handheldplayfullscre.html

thanks

avatar image Deathfate · Mar 03, 2017 at 06:46 PM 0
Share

Thats why I used a black image in between because the ui messes up in between the switch from portrait to landscape.

Create a Black image that fills all the screen then activate it before switching to landscape, then wait a frame, then play the video, and then switch back to portrait, wait a frame and then deactivate the black image

You can see in my answer below that I use blackbgImage.SetActive (true); and blackbgImage.SetActive (false); thats my back image that fills all the canvas and its on top of everything.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Deathfate · Jan 15, 2016 at 05:45 PM

In my case I had a portrait app and wanted to play the video in landscape. I managed to solve it this way:

 protected IEnumerator PlayBackRoutine(){
         blackbgImage.SetActive (true);
         Screen.orientation = ScreenOrientation.Landscape;
         while (Screen.currentResolution.height > Screen.currentResolution.width) {
             yield return null;
         }
         Handheld.PlayFullScreenMovie ("http://videourl.mp4");
         yield return null;
         Screen.orientation = ScreenOrientation.Portrait;
         while (Screen.currentResolution.height < Screen.currentResolution.width) {
             yield return null;
         }
         blackbgImage.SetActive (false);
     }

I created a black image that occpies all the screen called blackbgImage. So i show it before changing to landscape, switch to landscape, wait until the switch is done, play the video, wait 1 frame, switch to portrait, wait until the switch is done and unshow the image.

The result is super neat, i couldnt notice the difference between this and a native app.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image subjectZero · Aug 12, 2016 at 08:34 AM 0
Share

Thanks this works perfectly!!!

avatar image
0

Answer by Visual Programmer · Sep 28, 2013 at 04:02 PM

Try using LandscapeLeft or LandscapeRight. Landscape is not a valid ScreenOrientation.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by qoobit · Mar 10, 2015 at 02:40 PM

You need to put two copies of

 yield return new WaitForEndOfFrame();

After the PlayFullScreenMovie or else it will switch to portrait before the video finishes.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Benzor · Jan 15, 2016 at 08:44 PM 0
Share

You can also use yield return null; which is equivalent.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can the GameKit plugin establish BlueTooth communication between MacOS and iOS? 0 Answers

Unity -> Xcode 'Unknown Error Occurred' after it says running on device 3 Answers

How to create a reflective shader for unity ios 0 Answers

Can't found MapFileParser folder 0 Answers

Power Meter? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges