在glkview上绘制时,MPMoviePlayerController的背景UIView闪烁

时间:2019-05-14 13:46:30

标签: ios objective-c glkit

我正在尝试通过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];

0 个答案:

没有答案