ios - MPMoviePlayer fullscreen playback orientation change -
i developing ios application viewcontroller has 2 subviews a) mpmoviecontroller , b) pageviewcontroller. if player not in full screen mode , change orientation subviews alignment ok (i handle orientation change , make new cgrects subviews). when switch video mode full screen, rotate landscape , zoom out, pageviewcontrollers view gone out of screen. here 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]; }
Comments
Post a Comment