如何镜像(翻转)使用 AVPlayer 播放的视频?

How to Mirror(Flip) Video playing using AVPlayer?

我想镜像(翻转)使用 AVPlayer 播放的视频。 喜欢 : MirrorTube :- https://chrome.google.com/webstore/detail/mirrortube/olomckflnlligkboahmaihmeaffjdbfm/related?hl=en

我想实现相同的功能。

我尝试更改 CGAffineTransform,但效果不一样。

提前致谢!

下面是一个如何使用 CGAffineTransform 垂直和水平翻转播放器的示例:

播放器视图:

import AVKit

class PlayerView: UIView {
    var player: AVPlayer? {
        get {
            return playerLayer.player
        }
        set {
            playerLayer.player = newValue
        }
    }

    var playerLayer: AVPlayerLayer {
        return layer as! AVPlayerLayer
    }

    // Override UIView property
    override static var layerClass: AnyClass {
        return AVPlayerLayer.self
    }
}

ViewController 使用 xib/storyboard:

中定义的 playerView
@IBOutlet var playerView: PlayerView!

@IBAction func flipVerticallyBarButtonItemTouched(_ sender: UIBarButtonItem) {
           UIView.animate(withDuration: 0.2) { [unowned self] in
               self.playerView.transform = self.playerView.transform.concatenating(CGAffineTransform(scaleX: 1, y: -1))
           }
       }
@IBAction func flipHorizontallyBarButtonItemTouched(_ sender: UIBarButtonItem) {
           UIView.animate(withDuration: 0.2) { [unowned self] in
            self.playerView.transform = self.playerView.transform.concatenating(CGAffineTransform(scaleX: -1, y: 1))
           }
}