How to make app rotate only when playing videos? - ios

Im trying to the set the orientation of my app so that it rotates when it is playing a video. Changing the "Supported Interface Orientations" in info.plist changes the orientation for the whole app but I just want it to change orientation when a video is playing. Any ideas of how to do this?

You can use CoreMotion to detect the current interface orientation, and the only change interface orientation if your video is playing.
Try checking out the CMMotionManager class.
Alternatively, try checking out preferredInterfaceOrientationForPresentation on your UIViewController.

Related

Is it possible to autorotate AVPlayer even if the device turned on "Lock Portrait Orientation"?

I want to play a video with AVPlayerViewController() from Apple's AVKit framework. well, the video plays nicely, auto rotate works well and rotate smoothly. But, is it possible to autorotate that (so it could rotate to landscape or rotate to portrait, not just one of it) even if the device turned on "Lock Portrait Orientation" ?
What i mean for "Lock Portrait Orientation" is the one from device's Control Center like this : Lock Portrait Orientation

How to detect device rotation despite locked display orientation?

So I have an app that needs to not use autorotate. Instead of rotating the screen the buttons on the screen are just supposed to rotate.
I have the interface locked in landscape left. How do I detect what rotation the buttons should be?
I am using a custom opengl engine so I can set the rotation of objects.
You can get the device orientation from:
UIDevice.orientation
This is not the interface orientation, so you get two more possible values for face up and face down. Also the landscape left and right are swapped compared to UIInterfaceOrientation.
You can listen for changes in device orientation by subscribing to the UIDeviceOrientationDidChange notification from NSNotificationCenter. You may have to enable these notifications by calling UIDevice.beginGeneratingDeviceOrientationNotifications().
If the interface orientation is locked on the device, it is not listening to any delegate methods related to orientation changes.

how to use html5 video landscape in ios

I use phonegap to create a ios project.I want to use htmlt5 video to play a video in landscape.
So there is a way from webkit or in my application to switch in landscape mode only when i showing a HTML5 video?
Thanks!
Create view and add webView as subview to that view. Set orientation of that view to LandscapeLeft and LandScapeRight and load HTML5 video on webview. call that view when ever you want to play video; view will always appear in landscape mode.

Modifying allowed orientations on MPMoviePlayerViewController (called from UIWebView). iOS 5 and iOS 6

I have an app working on iOS 5 and 6. This app must run only in portrait mode (it's done). But in this app I have to show and play some YouTube videos.
To achieve this I use a UIWebView to show the thumbnail YouTube video. So, I have a nice thumbnail and when the user touches it the app shows automatically a MPMoviePlayerController playing the video. Almost all is perfect...
My problem is that I need the MPMoviePlayerController supports both orientation (but only this controller). How could I achieve this?
Thanks a lot,
Carlos
Add the desired orientations to your Info.plist
Subclass MPMoviePlayerViewController
Override shouldAutorotate and supportedInterfaceOrientations to return YES and all the orientations you wish to support, respectively.

play video landscape Iphone sdk 3.2 4.0 with standard api

how to play video landscape with standard api?
video play only portrait !!!
change the app orientation landscape is not useful, because video start portrait forever.
i have a portrait app with a button, when pressed video must play landscape.
yourmoviecontrollername setOrientation:UIDeviceOrientationPortrait animated:NO];
is not allowed by Apple
Maybe the regular videoplayercontroller doesnt do landscape by itself...i would suggest using MPMoviePlayerViewController available in 3.2, you set it up and use view controllers presentMoviePlayerController method in order to display, should work fine for you. here is a ref MPViewcontroller

Resources