我目前正在使用AVPlayer和AVPlayerLayer來播放一些視頻。在播放視頻時,我在視頻中每隔30秒註冊一次時間更新。這用於繪製視頻中該點處加速度的圖形,並與視頻一起更新。該圖正在使用視頻中的CMTime,因此,如果我跳到視頻的其他部分,該圖就會立即表示視頻中的該時間點,而無需額外的工作。AVPlayerLayer - 重新編程車輪?
任何人,據我所知,如果我想獲得類似於MediaPlayer框架提供的界面,我將不得不自己這樣做。
我想知道的是,有沒有辦法使用我的AVPlayer與MediaPlayer框架? (不是我能看到的。)或者,有沒有辦法通過MediaPlayer框架註冊增量時間更新。
我的代碼,如果有人有興趣,如下:
[moviePlayer addPeriodicTimeObserverForInterval: CMTimeMake(1, 30) queue: dispatch_queue_create("eventQueue", NULL) usingBlock: ^(CMTime time) {
loopCount = (int)(CMTimeGetSeconds(time) * 30);
if(loopCount < [dataPointArray count]) {
dispatch_sync(dispatch_get_main_queue(), ^{
[graphLayer setNeedsDisplay];
});
}
}];
謝謝!
Woa。這個答案比問題晚了近一年,並且仍然被接受了!布拉沃。 – Almo 2012-05-15 17:37:12