GPUImageMovie:播放完成后如何显示视频的第一帧?

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

以下是我设置播放的方式:

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)
}