how to record uiview as Video with Audio iOS swift

Viewed 924

in my app, i am playing video in AVView now i am doing some transition by view in that view now i want to record that view as Video, also i need Audio also, so how can i do this?

i tried this library but its getting stuck video multiple times

https://github.com/wess/Glimpse

i did enough R&D but i am not getting any possible solution.

here is my code:

{
    guard let path = Bundle.main.path(forResource: "video2", ofType: "mov") else {
        return
    }
    let videoURL = NSURL(fileURLWithPath: path)

    // Create an AVPlayer, passing it the local video url path
    let player = AVPlayer(url: videoURL as URL)
    let controller = AVPlayerViewController()
    controller.player = player

    present(controller, animated: true) {
        player.play()

        self.createImageView()

        controller.view.addSubview(self.viewForImage)

        self.zoomAnimationCount = 0
          self.zoomInAnimation()

        DispatchQueue.main.async {
            self.glimpse!.startRecording(controller.view, onCompletion: { fileOuputURL in
                print("DONE WITH OUTPUT: \(fileOuputURL?.absoluteString ?? "")")
            })

        DispatchQueue.main.asyncAfter(deadline: .now() + 20.0, execute: {
            self.glimpse!.stop()
        })
        }




    }
}

please let me know how can i do it?

0 Answers
Related