I'm trying to stream a video in my app. The method I've found is :
NSURL *theMovieURL = [NSURL URLWithString:self.data.trailer];
if (theMovieURL)
{
self.movieController = [[MPMoviePlayerViewController alloc] initWithContentURL:theMovieURL];
[self presentMoviePlayerViewControllerAnimated:self.movieController];
[self.movieController.moviePlayer play];
}
I'm not sure if it's the most conventional, but it works.
The problem is that I can't figure out how to allow the landscape mode, for the video only. Should I use something like shouldAutorotate
or shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
, and how ?
FYI, the entire app allows only the portrait mode.
Thanks for your help.
Change orientation of whole document To change the orientation of the whole document, select Layout > Orientation. Choose Portrait or Landscape.
Setting the app upWhen on the main screen, under the orientation section, you will see a number of options like 'Auto-rotate OFF', 'Auto-rotate ON', 'Forced Portrait' and 'Forced Landscape'. As the names suggest, you can use these buttons as one-tap shortcuts to toggle the orientation of your device.
shouldAutoRotate
is deprecated as of iOS 6 and should be avoided unless you're going for < 6 .
Instead, you'd want to override the supportedInterfaceOrientations
and preferredInterfaceOrientationForPresentation
methods.
In this case, if you don't want to subclass the media player you could override a method in the app delegate like so:
- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if ([[self.window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]])
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else
{
return UIInterfaceOrientationMaskPortrait;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With