MPMoviePlayer fullscreen playback orientation change - ios

I am developing an ios application with viewcontroller which has two subviews A) mpmoviecontroller and B) pageviewcontroller. if the player is not in full screen mode and I change orientation subviews alignment is ok (I handle orientation change and make new CGRects for subviews). When I switch my video mode to full screen, rotate to landscape and zoom out, my pageviewcontrollers view is gone out of the screen. Here is my code
- (void)viewDidLoad
{
[super viewDidLoad];
self.streamPlayer.controlStyle = MPMovieControlStyleDefault;
[self.view addSubview: self.streamPlayer.view];
[self.streamPlayer prepareToPlay];
NSURL *streamURL = [NSURL URLWithString:#"http://www.nasa.gov/multimedia/nasatv/NTV-Public-IPS.m3u8"];
[self.streamPlayer setContentURL:streamURL];
[self.streamPlayer play];
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"PageViewController"];
[self setFramesForPotrait];
[self addChildViewController:_pageViewController];
[self.view addSubview:_pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
}
- (void)orientationChanged:(NSNotification *)notification
{
[self adjustViewsForOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
}
- (void) adjustViewsForOrientation:(UIInterfaceOrientation) orientation {
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
[self setFramesForPotrait];
NSLog(#"%f",[[UIScreen mainScreen] bounds].size.height);
NSLog(#"%f",[[UIScreen mainScreen] bounds].size.width);
}
else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
[self setFramesForLandscapeMode];
// self.pageViewController.view.frame = self.pageViewContainterRect;
NSLog(#"%f",[[UIScreen mainScreen] bounds].size.height);
NSLog(#"%f",[[UIScreen mainScreen] bounds].size.width);
}
}
-(void)setFramesForPotrait
{
CGRect frame = [[UIScreen mainScreen] bounds];
_videoFrameRect = CGRectMake(0,_BAR_HEIGHT, frame.size.width,_VIDEO_HEIGHT_PORTRAIT);
_pageViewContainterRect = CGRectMake(frame.origin.x, _BAR_HEIGHT + _VIDEO_HEIGHT_PORTRAIT, frame.size.width, frame.size.height-_BAR_HEIGHT-_VIDEO_HEIGHT_PORTRAIT);
[self.pageViewController.view setFrame :self.pageViewContainterRect ];
[self.streamPlayer.view setFrame: _videoFrameRect];
}
-(void)setFramesForLandscaeMode
{
CGRect frame = [[UIScreen mainScreen] bounds];
_videoFrameRect = CGRectMake(0,_BAR_HEIGHT, frame.size.height/2,frame.size.width-_BAR_HEIGHT);
_pageViewContainterRect = CGRectMake(frame.size.height/2, _BAR_HEIGHT, frame.size.height/2,frame.size.width-_BAR_HEIGHT);
self.pageViewController.view.frame = self.pageViewContainterRect;
[self.streamPlayer.view setFrame: _videoFrameRect];
}

Related

Can't redraw the popover in correct place after changing the orientation of the device

I have a tabbar app in which I need to show a popover from the tabBarItem by clicking on it. So, I in my appDelegate:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
if (viewController == [self.objTabBarController.viewControllers objectAtIndex:2])
{
if (self.settingsPopover == nil) {
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main - iPad" bundle: nil];
SettingsViewController *settingsController = [mainStoryboard instantiateViewControllerWithIdentifier: #"SettingsPopover"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:settingsController];
self.settingsPopover = [[UIPopoverController alloc] initWithContentViewController:navigationController];
self.settingsPopover.delegate = self;
CGSize screenSize;
if ([[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationPortraitUpsideDown){
screenSize = CGSizeMake ([UIScreen mainScreen].applicationFrame.size.width, [UIScreen mainScreen].applicationFrame.size.height);
} else {
screenSize = CGSizeMake ([UIScreen mainScreen].applicationFrame.size.height, [UIScreen mainScreen].applicationFrame.size.width);
}
NSLog(#"WIDTH = %f, HEIGHT = %f", screenSize.width, screenSize.height);
screenSize.height -= 50;
screenSize.width = screenSize.width / 2 + 105;
CGRect rect = CGRectMake(screenSize.width, screenSize.height, 1, 1);
[self.settingsPopover presentPopoverFromRect:rect inView:self.window.rootViewController.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
} else {
[self.settingsPopover dismissPopoverAnimated:NO];
self.settingsPopover = nil;
}
return NO;
}
}
return YES;
}
So it displays correctly. But I need to redraw the popover after the change of the device orientation. For this purposes I made:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(handleDidChangeStatusBarOrientationNotification:)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:nil];
}
- (void) handleDidChangeStatusBarOrientationNotification:(NSNotification *)notification;
{
if (self.settingsPopover)
{
CGSize screenSize;
if ([[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationPortraitUpsideDown){
screenSize = CGSizeMake ([UIScreen mainScreen].applicationFrame.size.width, [UIScreen mainScreen].applicationFrame.size.height);
} else{
screenSize = CGSizeMake ([UIScreen mainScreen].applicationFrame.size.height, [UIScreen mainScreen].applicationFrame.size.width);
}
NSLog(#"WIDTH = %f, HEIGHT = %f", screenSize.width, screenSize.height);
screenSize.height -= 50;
screenSize.width = screenSize.width / 2 + 105;
CGRect rect = CGRectMake(screenSize.width, screenSize.height, 1, 1);
[self.settingsPopover presentPopoverFromRect:rect inView:self.window.rootViewController.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
}
So, the NSLog shows the correct screenSize after the changing the orientation but the popover shows in incorrect place. Can anyone help me to solve this?
For that you have to close your Popover first and then show it again as I have done to solve my problem
In case anyone is looking for an answer in Swift 3...
1) Register for orientation change events.
NotificationCenter.default.addObserver(self, selector: #selector(screenRotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
2) Inside your view controller being presented as a popover...
func screenRotated() {
// Redraw the popover.
DispatchQueue.main.async {
self.preferredContentSize = CGSize(width: UIScreen.main.bounds.width, height: self.view.frame.height)
}
}

rotation of video hide videocontroller

when i rotate a video from portrait to landscape then it opens in landscpae mode perfectly but hide video controller bar. code which i am using :
-(void) readyPlayer
{
mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"abc" ofType:#"mp4"]]];
[[NSNotificationCenter defaultCenter] removeObserver:mp
name:MPMoviePlayerPlaybackDidFinishNotification
object:mp.moviePlayer];
// Register this class as an observer instead
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:mp.moviePlayer];
// Set the modal transition style of your choice
mp.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
mp.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
for(UIView* subV in mp.moviePlayer.view.subviews) {
subV.backgroundColor = [UIColor clearColor];
}
mp.moviePlayer.fullscreen=YES;
[self.view addSubview:mp.view];
[mp.moviePlayer play];
}
- (void)deviceOrientationDidChange:(NSNotification *)notification {
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
rotation = 0;
// Later we may handle the Orientation of Faceup to show a Map. For now let's ignore it.
if (orientation == UIDeviceOrientationPortrait) {
{
NSLog(#"portrait");
[mp.view setFrame:CGRectMake(0,0,screenWidth,screenHeight)];
rotation = 0;
mp.view.transform = CGAffineTransformMakeRotation(rotation);
}
}
else if (orientation != UIDeviceOrientationUnknown) {
//CGRect bounds = [[UIScreen mainScreen] bounds];
switch (orientation) {
case UIDeviceOrientationLandscapeLeft:
{
NSLog(#"Case 1");
[mp.view setFrame:CGRectMake(0,0,screenWidth,screenHeight)];
rotation = M_PI_2;
mp.view.transform = CGAffineTransformMakeRotation(rotation);
}
break;
case UIDeviceOrientationLandscapeRight:
{
NSLog(#"Case 2");
rotation = -M_PI_2;
[mp.view setFrame:CGRectMake(0,0,screenWidth,screenHeight)];
mp.view.transform = CGAffineTransformMakeRotation(rotation);
}
break;
case UIDeviceOrientationPortraitUpsideDown:
{
NSLog(#"Case 3");
rotation = -M_PI;
[mp.view setFrame:CGRectMake(0,0,screenWidth,screenHeight)];
mp.view.transform = CGAffineTransformMakeRotation(rotation);
}
break;
default:
break;
}
}
}
Please help.
If your application needs to support only portrait orientation and all the videos need to play in both orientations, do the steps.
1->Project file->Summary->SupportedOrientations -> tick yes for all orientation values.
2->In your root view Controller implement (BOOL)shouldAutorotate and return NO.

Launching app in Landscape Mode

I have an app that I want to only work with in Landscape.
For the first time ever, I'm foregoing IB and trying to set up all my views programmatically, so I'm creating a view and adding a bunch of subviews in loadView method:
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
self.mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
self.mapView.myLocationEnabled = YES;
self.mapView.delegate = self;
self.mapView.mapType = kGMSTypeHybrid;
self.mapView.frame = self.view.frame;
[self.view addSubview:self.mapView];
// add the toolbar
UIToolbar* toolbar = [[UIToolbar alloc] init];
toolbar.frame = CGRectMake(0, self.view.frame.size.height - 44, self.view.frame.size.width, 44);
toolbar.barStyle = UIBarStyleDefault;
NSMutableArray* items = [NSMutableArray array];
[items addObject:[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"location-arrow.png"]
style:UIBarButtonItemStyleBordered
target:self
action:#selector(locateMe:)]];
[items addObject:[[UIBarButtonItem alloc] initWithTitle:#"Tools"
style:UIBarButtonItemStyleBordered
target:self
action:#selector(toolsButtonTapped:)]];
[toolbar setItems:items];
[self.view addSubview:toolbar];
In my project settings, I have disabled both portrait orientations. I also have this in my root view controller:
// Enforce Landscape Orientation
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
My problem is that the simulator starts in landscape mode, but all of the views are sized for portrait - so the bottom chunk of my views are below the screen and the right side of my screen is a big empty region.
I tried fixing this by switching the width and height of the application frame in the first line, but then that leaves some empty vertical room on the left edge of the screen for the status bar.
So, what's the correct way of doing what I'm trying to do?
Instead of using [[UIScreen mainScreen] applicationFrame]
try using [[[[[self view] window] rootViewController] view] bounds]
The bounds will represent the width and height correctly in Landscape orientation, because the bounds will take into account the transform (rotation) that has been applied, while the frame will not.
To see what I mean, set a breakpoint, and in the debugger print out the description of the top level view lldb> po [[[[self view] window] rootViewController] view]
You'll see that the view has a rotation transform and that its frame does not represent the dimensions of the screen in landscape, but represents the dimensions in portrait!
The long way to calculate the correct applicationFrame would be
BOOL iOS7 = NO;
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:#"7.0" options:NSNumericSearch] != NSOrderedAscending)
iOS7 = YES;
CGRect theFrame;
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
theFrame.origin = CGPointZero;
theFrame.size.width = screenBounds.size.height;
theFrame.size.height = screenBounds.size.width;
if (iOS7 == NO) {
// statusBarFrame will be CGRectZero if not visible, so this is safe
theFrame.size.height -= statusBarFrame.size.width; // because we're in landscape orientation
}
}
else {
theFrame = screenBounds;
if (iOS7 == NO) {
// statusBarFrame will be CGRectZero if not visible, so this is safe
theFrame.size.height -= statusBarFrame.size.height; // because we're in portrait orientation
}
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UIInterfaceOrientationIsLandscape( interfaceOrientation))
{
return YES;
}
return NO;
}
Put this code Appdelegate .M.....
Put this in current viewcontroller
// ios 5
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (UIInterfaceOrientationIsLandscape( interfaceOrientation)) {
return YES;
}
return NO;
}
// ios6
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}

Best practice to calculate view size within loadView method

What is the best practice to calculate the view size in the loadView method (in an UIViewController) without a XIB file?
Here is my solution:
- (void)loadView {
//Calculate Screensize
BOOL statusBarHidden = [[UIApplication sharedApplication] isStatusBarHidden ];
BOOL navigationBarHidden = [self.navigationController isNavigationBarHidden];
BOOL tabBarHidden = [self.tabBarController.tabBar isHidden];
CGRect frame = [[UIScreen mainScreen] bounds];
if (!statusBarHidden) {
frame.size.height -= [[UIApplication sharedApplication] statusBarFrame].size.height;
}
if (!navigationBarHidden) {
frame.size.height -= self.navigationController.navigationBar.frame.size.height;
}
if (!tabBarHidden) {
frame.size.height -= self.tabBarController.tabBar.frame.size.height;
}
UIView *v = [[UIView alloc] initWithFrame: frame];
[v setBackgroundColor: [UIColor whiteColor] ];
[v setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight ];
[self setView: v ];
[v release];
}
Is this code okay, or should I edit something?
The docs recommend using [[UIScreen mainScreen] applicationFrame] to get the screen bounds without the status bar
so for anyone who want to know a best practice example:
#pragma mark -
#pragma mark LoadView Methods
- (void)loadView {
//Calculate Screensize
BOOL statusBarHidden = [[UIApplication sharedApplication] isStatusBarHidden ];
BOOL navigationBarHidden = [self.navigationController isNavigationBarHidden];
BOOL tabBarHidden = [self.tabBarController.tabBar isHidden];
BOOL toolBarHidden = [self.navigationController isToolbarHidden];
CGRect frame = [[UIScreen mainScreen] applicationFrame];
//check if you should rotate the view, e.g. change width and height of the frame
BOOL rotate = NO;
if ( UIInterfaceOrientationIsLandscape( [UIApplication sharedApplication].statusBarOrientation ) ) {
if (frame.size.width < frame.size.height) {
rotate = YES;
}
}
if ( UIInterfaceOrientationIsPortrait( [UIApplication sharedApplication].statusBarOrientation ) ) {
if (frame.size.width > frame.size.height) {
rotate = YES;
}
}
if (rotate) {
CGFloat tmp = frame.size.height;
frame.size.height = frame.size.width;
frame.size.width = tmp;
}
if (statusBarHidden) {
frame.size.height -= [[UIApplication sharedApplication] statusBarFrame].size.height;
}
if (!navigationBarHidden) {
frame.size.height -= self.navigationController.navigationBar.frame.size.height;
}
if (!tabBarHidden) {
frame.size.height -= self.tabBarController.tabBar.frame.size.height;
}
if (!toolBarHidden) {
frame.size.height -= self.navigationController.toolbar.frame.size.height;
}
UIView *v = [[UIView alloc] initWithFrame: frame];
v.backgroundColor = [UIColor whiteColor];
v.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.view = v;
[v release]; //depends on your ARC configuration
}
You are adjusting the height depend on the status bar and navigation bars.. But you have not done anything with respect to the origin of the view.

MPMoviePlayerController view not resizing

I'm working with an MPMoviePlayerController which renders its UIView to the right dimensions on landscape, but when rotating to portrait it is simply not resizing. I think it's parent UIView is the one not resizing. How can I set this up?
I followed the instructions that #Alex Reynolds mentions in UIView autoresizingmask not working for me. This showed me that the view does resize when rotated. I still have the problem that when the UIView for the UIViewController that holds the player is loaded, if the orientation of the device is landscape, they it renders to the right frame, but if the devise is on portrait by the time it is loaded it is not resized to it. With #Alex Reynolds' answer, all I have to do is rotate the device once and it will start resizing properly after that.
It is still bad that it won't resize the first time. Has this happened to anyone before? If so, any input is greatly appreciated.
Have you set the MPMoviePlayerController's view's autoresizingMask appropriately? Is its superview's autoresizesSubviews property set to YES? (and likewise, does this superview also resize when rotating? I like to set colourful background colours for my views during testing to verify that they resize correctly when autorotating.)
If it's still not working after checking those properties, you can always set the movie player's view's frame property manually. The super view's layoutSubviews method is generally the best place to do that, but if it's not a view you've manually subclassed, you can also do it in the view controller.
- (void)viewDidLoad
{
[super viewDidLoad];
[self play];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
-(IBAction)dismiss:(id)sender
{
//[self.view removeFromSuperview];
_moviePlayer =nil;
[self dismissViewControllerAnimated:YES completion:nil];
}
// Do any additional setup after loading the view from its nib.
-(void)play
{
NSURL *url = [NSURL URLWithString:#"stringurlvideo"];
_moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
// [[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(moviePlayBackDidFinish:)
// name:MPMoviePlayerPlaybackDidFinishNotification
// object:_moviePlayer];
// [[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(moviePlayBackDidFull:)
// name:MPMoviePlayerDidEnterFullscreenNotification
// object:_moviePlayer];
// [[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(moviePlayBackDidExit:)
// name:MPMoviePlayerDidExitFullscreenNotification
// object:_moviePlayer];
_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.shouldAutoplay = YES;
if([[UIScreen mainScreen] bounds].size.height==568)
{
[_moviePlayer.view setFrame:CGRectMake(0,200, 320, 200)];
}
else
{
[_moviePlayer.view setFrame:CGRectMake(0,150, 320, 200)];
}
[self.view addSubview:_moviePlayer.view];
//[_moviePlayer.view setCenter:self.view.center];
[_moviePlayer setFullscreen:YES animated:YES];
}
- (void) moviePlayBackDidFull:(NSNotification*)notification
{
}
-(void)moviePlayBackDidExit:(NSNotification*)notification
{
////[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
}
-(void)viewWillAppear:(BOOL)animated
{
/* if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait)
{
[_moviePlayer.view setFrame:CGRectMake(0,200, 320, 200)];
CGRect rect=[bar frame];
rect.size.width=self.view.frame.size.width;
[bar setFrame:rect];
}
else
{
CGRect rect=[bar frame];
rect.size.width=480;
[bar setFrame:rect];
[_moviePlayer.view setFrame:CGRectMake(0,44, 480, 320-44)];
}*/
}
- (void)moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
if ([player
respondsToSelector:#selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
}
- (BOOL)shouldAutorotate
{
return YES;
}
/*- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}*/
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if(toInterfaceOrientation==UIInterfaceOrientationPortrait && toInterfaceOrientation!=UIInterfaceOrientationPortraitUpsideDown )
{
if([[UIScreen mainScreen] bounds].size.height==568)
{
[_moviePlayer.view setFrame:CGRectMake(0,200, 320, 200)];
}
else
{
[_moviePlayer.view setFrame:CGRectMake(0,150, 320, 200)];
}
CGRect rect=[bar frame];
rect.size.width=self.view.frame.size.width;
[bar setFrame:rect];
}
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation ==UIInterfaceOrientationLandscapeRight)
{
CGRect rect=[bar frame];
if([[UIScreen mainScreen] bounds].size.height==568)
{
rect.size.width=568;
}
else{
rect.size.width=480;
}
[bar setFrame:rect];
[_moviePlayer.view setFrame:CGRectMake(0,44, rect.size.width, 320-44)];
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
/* if(fromInterfaceOrientation==UIInterfaceOrientationPortrait && fromInterfaceOrientation!=UIInterfaceOrientationPortraitUpsideDown )
{
CGRect rect=[bar frame];
rect.size.width=568;
[bar setFrame:rect];
[_moviePlayer.view setFrame:CGRectMake(0,44, 480, 320-44)];
}
else
{
[_moviePlayer.view setFrame:CGRectMake(0,200, 320, 200)];
CGRect rect=[bar frame];
rect.size.width=self.view.frame.size.width;
[bar setFrame:rect];
}*/
}
- (void)didRotate:(NSNotification *)notification
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation ==UIInterfaceOrientationLandscapeRight)
{
CGRect rect=[bar frame];
if([[UIScreen mainScreen] bounds].size.height==568)
{
rect.size.width=568;
}
else{
rect.size.width=480;
}
[bar setFrame:rect];
[_moviePlayer.view setFrame:CGRectMake(0,44, rect.size.width, 320-44)];
}
else if(orientation==UIInterfaceOrientationMaskPortrait && orientation!=UIDeviceOrientationPortraitUpsideDown)
{
if([[UIScreen mainScreen] bounds].size.height==568)
{
[_moviePlayer.view setFrame:CGRectMake(0,200, 320, 200)];
}
else
{
[_moviePlayer.view setFrame:CGRectMake(0,150, 320, 200)];
}
CGRect rect=[bar frame];
rect.size.width=self.view.frame.size.width;
[bar setFrame:rect];
}
}

Resources