我正在尝试通过GLKView
播放视频,但有时黑色背景会闪烁
设置glkViewController.paused = YES
并没有帮助。我还尝试了各种组合,包括在GLKView
之上添加内容或在MPMoviePlayerController
的backgroundView属性中添加子视图,这些子视图也可能闪烁或根本不显示
所以,这是初始化代码的一部分
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:surl];
[moviePlayer setControlStyle:MPMovieControlStyleNone];
[moviePlayer setFullscreen:YES];
[moviePlayer setScalingMode:MPMovieScalingModeFill];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:)
name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
[glkViewController.view addSubview:[moviePlayer view]];
这就是电影加载完成后的称呼
auto screenRect = [[UIScreen mainScreen] bounds].size;
float movieFrameWidth = screenRect.width;
float movieFrameHeight = screenRect.height;
[[moviePlayer view] setFrame:CGRectMake(0, 0, movieFrameWidth, movieFrameHeight)];
[[moviePlayer view] setBounds:CGRectMake(0, 0, movieFrameHeight, movieFrameWidth)];
[[moviePlayer view] setCenter:CGPointMake(movieFrameWidth / 2.0, movieFrameHeight / 2.0)];
//Removing rotation didnt' help as well help as well
[[moviePlayer view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
[moviePlayer play];