我正在尝试将视频同步到在iPad上使用openGL绘制的动画,有两件事我不知道该怎么办:
答案 0 :(得分:3)
不确定它是否有效但不使用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]];
然后创建AVSynchronizedLayer
图层并将其与playerLayer
:
AVSynchronizedLayer *syncLayer = [AVSynchronizedLayer synchronizedLayerWithPlayerItem:playerItem];
[syncLayer addSublayer:yourGlView.layer];
[playerView.layer addSublayer:playerLayer];
[playerView.layer addSublayer:syncLayer];
[self.view addSubview:playerView];
...