iphone - how to provide only one view with landscape for MPMoviePlayerController in IOS6 -
i had spend 2 hours finding correct code fix orientation problem movieplayer code. need particular view shown in landscape.
in appdelegate set orientation , in rootviewcontroller set portrait , in movieplayer view landscape not luck. can give me comment on how fix issues please ?
- (nsuinteger)application:(uiapplication*)application supportedinterfaceorientationsforwindow:(uiwindow*)window { return uiinterfaceorientationmaskall; }
my rootviewcontroller
- (bool)shouldautorotate { return no; } - (nsuinteger)supportedinterfaceorientations { return uiinterfaceorientationmaskportrait; } -(void)prepareintrovideo { nsurl *url = [nsurl fileurlwithpath:[[nsbundle mainbundle]pathforresource:@"designthinking_pt1" oftype:@"mp4"]]; self.playercontroller = [[mpmovieplayercontroller alloc] initwithcontenturl:url]; [self.playercontroller.view setframe:cgrectmake(0, -20, 320, 480)]; self.playercontroller.moviesourcetype = mpmoviesourcetypefile; self.playercontroller.scalingmode = mpmoviescalingmodeaspectfill; self.playercontroller.fullscreen = no; self.playercontroller.controlstyle = mpmoviecontrolstylefullscreen; //playercontroller.controlstyle = mpmoviecontrolstylefullscreen; self.playercontroller.view.userinteractionenabled =yes; self.playercontroller.view.backgroundcolor = [uicolor blackcolor]; self.playercontroller.shouldautoplay = no; //playercontroller.repeatmode = yes; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(movieplaybackcomplete:) name:mpmovieplayerplaybackdidfinishnotification object:self.playercontroller]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(applicationdidenterbackground) name: uiapplicationdidenterbackgroundnotification object:[uiapplication sharedapplication]]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(applicationwillenterforeground) name:uiapplicationwillenterforegroundnotification object:[uiapplication sharedapplication]]; [self.playercontroller preparetoplay]; [self.view addsubview:self.playercontroller.view]; [self.playercontroller setfullscreen:yes animated:yes]; //[self.playercontroller stop]; [self.view sendsubviewtoback:self.playercontroller.view]; } - (bool)shouldautorotate { return yes; } - (nsuinteger)supportedinterfaceorientations { return uiinterfaceorientationlandscapeleft; }
you can check example... https://dl.dropboxusercontent.com/u/19438780/testrotate.zip
i have 2 controllers navigation controller - portrait; "subclassed" nav controller (here "rotation" code portrait)
the 3th controller landscape - must presented modal if want rotate - put rotation code accordingly .
Comments
Post a Comment