Vimeo video player in swift

Add following pod command in pod file

pod 'HCVimeoVideoExtractor'

import following class

import UIKit
import AVKit
import AVFoundation
import HCVimeoVideoExtractor

Add following method for play Vimeo video

func playVimeoVideo() {
       
        if let url = URL(string: "https://vimeo.com/164864490") {
            HCVimeoVideoExtractor.fetchVideoURLFrom(url: url, completion: { ( video:HCVimeoVideo?, error:Error?) -> Void in
                
                if let err = error {
                    
                    print("Error = \(err.localizedDescription)")
                    
                    DispatchQueue.main.async() {
                        self.videoURL = nil
                        
                        let alert = UIAlertController(title: "Error", message: err.localizedDescription, preferredStyle: .alert)
                        alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
                        self.present(alert, animated: true, completion: nil)
                    }
                    return
                }
                
                guard let vid = video else {
                    print("Invalid video object")
                    return
                }
                
                print("Title = \(vid.title), url = \(vid.videoURL), thumbnail = \(vid.thumbnailURL)")
    
                DispatchQueue.main.async() {
                    self.videoURL = vid.videoURL[.Quality540p]
                    if let url = self.videoURL {
                        let player = AVPlayer(url: url)
                        let playerController = AVPlayerViewController()
                        playerController.player = player
                        self.present(playerController, animated: true) {
                            player.play()
                        }
                    }
                    else {
                        let alert = UIAlertController(title: "Error", message: "Invalid video URL", preferredStyle: .alert)
                        alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
                        self.present(alert, animated: true, completion: nil)
                    }
                }
            })
        }
    }