vimeo / PlayerKit

MIT License
154 stars 54 forks source link

Play a video #107

Open bogdanpralea opened 4 years ago

bogdanpralea commented 4 years ago

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

Thanks!

kunwar231 commented 4 years ago

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

CroperMR commented 4 years ago

Has anyone figured it out?

bogdanpralea commented 4 years ago
    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)")
        }
    }
kunwar231 commented 4 years ago

i figure you require a paid account even for testing.