gpt4 book ai didi

ios - GPUImageMovie : how to show the first frame of the video after playback is completed?

转载 作者:行者123 更新时间:2023-11-28 15:36:14 24 4
gpt4 key购买 nike

这是我设置播放的方式:

movie = GPUImageMovie(url: url)
movie.playAtActualSpeed = true
movie.delegate = self
movie.addTarget(self)
movie.startProcessing()

播放完成后,GPUImageView 显示视频文件的最后一帧。怎么改成第一帧?

最佳答案

我们可以使用 AVPlayerItem 并让 AVPlayer 为我们处理播放:

func configure(url: URL) {
// player is AVPlayer instance declated as property
let playerItem = AVPlayerItem(url: url)
player.replaceCurrentItem(with: playerItem)
NotificationCenter.default.addObserver(self, selector: #selector(playerDidFinishPlaying(_:)), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: playerItem)

movie = GPUImageMovie(playerItem: playerItem)
movie.playAtActualSpeed = true
movie.addTarget(self)
movie.startProcessing()
}

func playerDidFinishPlaying(_ notification: Notification) {
guard player.currentItem == notification.object as? AVPlayerItem else { return }
player.seek(to: kCMTimeZero)
}

关于ios - GPUImageMovie : how to show the first frame of the video after playback is completed?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44235661/

24 4 0