Got the message “WARNING: under normal conditions,

2019-04-10 07:05发布

问题:

It's my first post, and may be it may seem incorrect. So, I've to make rotation in cocos2d on iPad (5.1) I use 2 different videos to each orientation. And there I have 2 problems:

  1. The app starts in portrait mode, and plays video normally. I call (play) the video 5-10 times, when video finishs I rotate simulator. The view rotates, BUT when I call (play) video - it shows white screen and the next message:

    "WARNING: under normal conditions, _fillInQueueWithExtraSpace:ignoreExistingItems: should not be re-entered."

    Then If I rotate screen again (several times) - and play it in landscape mode - it plays video well. Also vice versa. When I start from landscape mode

  2. The View rotating problem. When I rotate view to the left/right landscape (from portrait) - can't rotate view backward. So I can rotate only in clockwise or counter clockwise. 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;
}

回答1:

Add this line of code After creating Player Object. player = [self.theMovie moviePlayer]; player.controlStyle = MPMovieControlStyleNone;

It's necessary in below version of iOS 6.0. May be it's helpful.

[player prepareToPlay];