This is my first post, and maybe this may seem wrong. So, I have to rotate cocos2d on iPad (5.1). I use 2 different videos for each orientation. And there I have 2 problems:
The application starts in portrait mode and plays the video normally. I call (play) the video 5-10 times, when the video ends, I rotate the simulator. The view rotates, BUT when I call (play) the video - it shows a white screen and the following message:
"WARNING: under normal conditions, _fillInQueueWithExtraSpace: ignoreExistingItems: should not be re-entered."
Then, if I rotate the screen again (several times) - and play it in landscape mode - it plays the video well. And vice versa. When I start with landscape mode
The problem with the rotation of the View. When I rotate the view left / right (from the portrait) - I can not rotate the view back. Therefore, I can only rotate clockwise or counterclockwise. How to fix it?
-(id) init { pathToVideoP = [[NSBundle mainBundle] pathForResource:@"video_portrait" ofType:@"mp4"]; pathToVideoL = [[NSBundle mainBundle] pathForResource:@"video_landscape" ofType:@"mp4"]; theMovieP = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:pathToVideoP]]; theMovieL = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:pathToVideoL]]; } -(void) playVideoButtonClicked { movieButton.visible = FALSE; if (sharedManager.isPortrait){ theMovie = theMovieP; } else { theMovie = theMovieL; } [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:[theMovie moviePlayer]]; CGSize size = [[CCDirector sharedDirector] winSize]; [[[CCDirector sharedDirector] openGLView] addSubview:theMovie.view]; player = [self.theMovie moviePlayer]; player.controlStyle = MPMovieControlStyleNone; [theMovie moviePlayer].view.backgroundColor = [UIColor whiteColor]; theMovie.view.frame = CGRectMake(0, 0, size.width, size.height); if (sharedManager.isPortrait) { CGAffineTransform transform = player.view.transform; player.view.transform = transform; } else if (sharedManager.changeOrientation) { CGAffineTransform transform = player.view.transform; transform = CGAffineTransformRotate(transform, (-M_PI/2 )); player.view.transform = transform; } sharedManager.changeOrientation = NO; player.backgroundView.backgroundColor = [UIColor whiteColor]; theMovie.view.backgroundColor = [UIColor whiteColor]; player.view.userInteractionEnabled = NO; player.scalingMode = MPMovieScalingModeNone; [player play]; } -(void) moviePreloadDidFinish:(id)sender { } -(void) movieFinishedCallback:(NSNotification*) aNotification { theMovie = [aNotification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; [player stop]; [theMovie.view removeFromSuperview]; movieButton.visible = TRUE; }
source share