PlayerKit icon indicating copy to clipboard operation
PlayerKit copied to clipboard

Play a video

Open bogdanpralea opened this issue 4 years ago • 4 comments

How do you play a video after getting the videos using VimeoNetworking?

Thanks!

bogdanpralea avatar May 21 '20 09:05 bogdanpralea

please provide some help here. I fetched a VIMVideo object using VimeoNetworking, and used uri variable of the object to create an avasset. But that doesnt plays the video either

kunwar231 avatar Jul 27 '20 07:07 kunwar231

Has anyone figured it out?

CroperMR avatar Sep 06 '20 19:09 CroperMR

    let videoRequest = Request<VIMVideo>(path: "/videos/419068453")
   let _ = VimeoClient.defaultClient.request(videoRequest) { result in
        switch result {
        case .success(let response):
             let video: VIMVideo = response.model
             if let file = video.files?.last as? VIMVideoFile {
                                let player = AVPlayer(url: URL(string: file.link!)!)
                let vc = AVPlayerViewController()
                vc.player = player

                self.present(vc, animated: true) {
                    vc.player?.play()
                }
            }
        case .failure(let error):
            print("error retrieving video: \(error)")
        }
    }

bogdanpralea avatar Sep 07 '20 06:09 bogdanpralea

i figure you require a paid account even for testing.

kunwar231 avatar Sep 07 '20 06:09 kunwar231