不确定它是否有效,但MPMoviePlayerController您可以使用AVPlayer并使用AVSynchronizedLayer来将您的 OpenGL 层时序与 的层时序同步,而不是使用它AVPlayerLayer。
您可以像这样创建视频播放器:
NSURL *videoURL = [NSURL fileURLWithPath:@"your_url"];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:videoURL options:nil];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset];
UIView *playerView = [[UIView alloc] initWithFrame:frame];
AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
[playerLayer setFrame:[[playerView layer] bounds]];
Run Code Online (Sandbox Code Playgroud)
然后创建一个AVSynchronizedLayer图层并将其与playerLayer:
AVSynchronizedLayer *syncLayer = [AVSynchronizedLayer synchronizedLayerWithPlayerItem:playerItem];
[syncLayer addSublayer:yourGlView.layer];
[playerView.layer addSublayer:playerLayer];
[playerView.layer addSublayer:syncLayer];
[self.view addSubview:playerView];
...
Run Code Online (Sandbox Code Playgroud)