Skip to main content

AVPlayer

captureSession.addOutput(videoOutput!)
cameraPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
cameraPreviewLayer?.connection?.videoOrientation = AVCaptureVideoOrientation(rawValue: UIDevice.current.orientation.rawValue) ?? .portrait
    
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
        coordinator.animate(alongsideTransition: nil) { _ in UIView.setAnimationsEnabled(true) }
        UIView.setAnimationsEnabled(false)
        super.viewWillTransition(to: size, with: coordinator)

        Logger.Log("VIEW WILL TRANSITION")
        if let videoOrientation = AVCaptureVideoOrientation(rawValue: UIDevice.current.orientation.rawValue) {
            Logger.Log("videoOrientation updated")
            cameraPreviewLayer?.connection?.videoOrientation = videoOrientation
        }

        cameraPreviewLayer?.frame.size = size
    }
    
if let _ = link {
            let player = AVPlayer(url: link!)
            self.player = player
            self.player?.play()

        }
    
func playLink(){
        if let _ = link {
            let player = AVPlayer(url: link!)
            self.player = player
            self.player?.play()

        }

        let videoAssetTrack = self.player?.currentItem?.asset.tracks(withMediaType: .video).first
        let videoTransform = videoAssetTrack?.preferredTransform

        Logger.Log("videoTransform = (videoTransform)")
    }