0
我试图让播放器在视频暂停时暂停。我不知道如何去做这件事,无论我把它添加为另一个calayer或动画。当我在导出之前添加calayer时,这是我的代码。所以当动画发生时,我希望视频在出现时暂停,然后在动画停止后继续。如何在播放器中出现视频暂停
let titleLayer = CATextLayer()
titleLayer.backgroundColor = NSColor.clearColor().CGColor
titleLayer.string = "Dummy text"
titleLayer.font = NSFont(name: "Helvetica", size: 28)
titleLayer.shadowOpacity = 0.5
titleLayer.alignmentMode = kCAAlignmentCenter
titleLayer.frame = CGRectMake(0, 50, size.width, size.height/6)
let animation: CABasicAnimation = CABasicAnimation(keyPath: "opacity")
animation.duration = 0
animation.fromValue = Int(1.0)
animation.toValue = Int(0.0)
animation.beginTime = 5
animation.removedOnCompletion = false
animation.fillMode = kCAFillModeForwards
titleLayer.addAnimation(animation, forKey: "animateOpacity")
谢谢你的答案@gravicle。最后一个问题,我将如何使用avexportsession来导出这个问题,以便在quicktime移动播放时显示动画时间的暂停,然后恢复? – spe
@spel你必须为此使用'AVMutableComposition'。这个问题中的代码片段几乎完成了你想要做的事情:http://stackoverflow.com/questions/10887449/black-video-caanimation-and-avfoundation-avassetexportsession – gravicle