Highlighted

Can I limit / force orientation changes in Air app?

Community Beginner ,
Jun 18, 2014

Copy link to clipboard

Copied

I have an app that works great when restricted to portrait mode - for 99% of it that's exactly what I want. But, I have to play a video in one small portion of it which needs to allow the user to rotate to landscape. This is the only time I want the landscape to work though.

I have the app set to portrait mode with auto-orientation in my publishing settings - so it will allow you to view it in portrait normally and upside-down (but no landscape). I tried manually changing the screen using StageOrientation.ROTATED_RIGHT but it wouldn't work in my testing on iPad 3. 

I would be happy with rotating the entire video 90 degrees and the user would just have to turn the device - but I'm using stageVideo and I can't control the rotation (...or can i?). I would also be happy with setting some in-app variable that locks out landscape most of the time, is that possible?

Any suggestions/recommendations would be helpful. Thanks!

TOPICS
Development

Views

521

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Can I limit / force orientation changes in Air app?

Community Beginner ,
Jun 18, 2014

Copy link to clipboard

Copied

I have an app that works great when restricted to portrait mode - for 99% of it that's exactly what I want. But, I have to play a video in one small portion of it which needs to allow the user to rotate to landscape. This is the only time I want the landscape to work though.

I have the app set to portrait mode with auto-orientation in my publishing settings - so it will allow you to view it in portrait normally and upside-down (but no landscape). I tried manually changing the screen using StageOrientation.ROTATED_RIGHT but it wouldn't work in my testing on iPad 3. 

I would be happy with rotating the entire video 90 degrees and the user would just have to turn the device - but I'm using stageVideo and I can't control the rotation (...or can i?). I would also be happy with setting some in-app variable that locks out landscape most of the time, is that possible?

Any suggestions/recommendations would be helpful. Thanks!

TOPICS
Development

Views

522

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 18, 2014 0
Engaged ,
Jun 18, 2014

Copy link to clipboard

Copied

I made a quick Android(my device is a Moto X) test to see what could be done. I was able to successfully create a new FLA targeting Android with AIR 13.0.0.83, changed the "AIR for Android Settings" to have Aspect ratio set to Portrait and Auto orientation unchecked. Then with code, tap a button on the stage to change the orientation to StageOrientation.ROTATED_RIGHT and it works. So you should have no problems setting the Aspect ratio to Portrait and unchecking "Auto orientation" so it will be locked to Portrait. Then when you want to play the video, change the orientation with code to StageOrientation.ROTATED_RIGHT or StageOrientation.ROTATED_LEFT and then change it back to StageOrientation.DEFAULT when the video is done/exited. Below is a link to a zip of the project I created. You will probably have to update the certificate and password, change the target to AIR for iOS, and change the resolution to 768x1024 for your iPad if you wanted to use this for testing.

EDIT: I also just had a thought. If you have the rotation lock turned on in the iOS settings, that may prevent the forced rotation from happening. So I would check on that. If that was the cause of the app not changing orientation with code, you have just have to build a video player that has its container rotated by 90 degrees so it will have the appearance of being in landscape.

Dropbox - orientationTest.zip

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 18, 2014 0
Community Beginner ,
Jun 18, 2014

Copy link to clipboard

Copied

Thank you very much for your response and extra efforts. I wasn't able to pull down your code, the .zip file was empty for me - but I have had success with the rotation method in Android as well. Sorry, I should have been more specific - I need a solution that works in both Android and iOS, as iOS seems to be the picky one with the StageOrientation.methods.

I ended up using a workaround for the time being - I am using stageWebView, and loading in a web page with the YouTube video embedded. In the iOS app, when you click on the video, it opens the native iOS video player which allows rotation to landscape without messing up the app or even changing the stageWebView. For my needs, this works perfectly - but I will keep this thread open for anyone that may have a similar issue and need the solution.

Thanks again!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 18, 2014 0
Community Beginner ,
Jun 18, 2014

Copy link to clipboard

Copied

To your edit - I tried it in locked, unlocked, and removed entirely from the xml but couldn't get it to make a change. For the container idea, unfortunately stageVideo is not in the DisplayList, so there's no container to rotate. Thanks, I appreciate the creative thinking.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 18, 2014 0
Engaged ,
Jun 18, 2014

Copy link to clipboard

Copied

Sorry about the zip file. I just tried it myself and it unzipped ok. Was my first time trying to share a dropbox link so Im not sure if I was supposed to make a setting change to make it public or not.

What version of AIR are you using? It is possible that newer versions fixed that as it could have been a bug specific to iOS. I was about to run through the release notes of the past few AIR releases to see if that was on the list of any of them but the site is down for maintenance at the moment.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 18, 2014 0
Community Beginner ,
Jun 18, 2014

Copy link to clipboard

Copied

For the file, I just downloaded again and this time it opened - so it was just an issue on my end I'm sure.

I'm running AIR 14.0.0.110... it should be the latest I believe. It's very possible that I'm just not implementing the code correctly. I am going to circle back to your solution this afternoon and see if I can get it working on iOS. I'll keep you posted. Thank you!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 18, 2014 0