objective c - iOS 5 and above: enable landscape mode in MPMoviePlayerController -


i have application entirely in portrait mode. (ios 5 , above) have video played using mpmovieplayercontroller, in video want when user rotates iphone, video should go landscape mode(in fullscreen). when video ends , again video should go portrait mode. code:

    -(void)playvideo:(nsurl*)videourl {       movieplayercontroller = [[mpmovieplayercontroller alloc] initwithcontenturl:videourl];     [movieplayercontroller.view setframe:cgrectmake(6, 69, 309, 196)];     [self.view addsubview:movieplayercontroller.view];     //    movieplayercontroller.fullscreen = yes;       movieplayercontroller.controlstyle = mpmoviecontrolstylenone;     [self.view bringsubviewtofront:self.shareview];     [self.view bringsubviewtofront:self.qualityview];      [movieplayercontroller play];      // register receive notification when movie has finished playing.     [[nsnotificationcenter defaultcenter] addobserver:self                                              selector:@selector(movieplaybackdidfinish:)                                                  name:mpmovieplayerplaybackdidfinishnotification                                                object:movieplayercontroller];  } 

rest of app, want in portrait only. how achieve this?

first need set support interface orientation portrait landscape

as shows here

now in every uiviewcontroller need override these methods -

for ios 5 -

- (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation {     return (interfaceorientation == uiinterfaceorientationportrait); }  - (bool)shouldautorotate {     return no; } 

for ios 6

- (nsuinteger)supportedinterfaceorientations {     return uiinterfaceorientationmaskportrait; } 

in uiviewcontroller going add mpmovieplayercontroller override -

- (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation {     return yes; }  - (bool)shouldautorotate {     return yes; }  - (nsuinteger)supportedinterfaceorientations {     return uiinterfaceorientationmaskallbutupsidedown; } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -