3

I'm playing videos using following code. Videos are hosted on my own server and accessible via url. Videos takes a lot of time to load and play. Typically it takes 15 secs or so to load and start playing for 50 MB file size.

I don't want to reduce video quality further as it is already reduced and reducing it further will make it even more poor quality.

Is there any way to speed up video loading? Any other alternatives/tricks are welcome except hosting on YouTube/other video sharing sites.

if let videoURL = self.videoURL, !videoURL.isEmpty {
    let player = AVPlayer(url: URL(string:videoURL)!)
    let playerController = AVPlayerViewController()
    playerController.player = player
    playerController.videoGravity = AVLayerVideoGravity(rawValue: AVLayerVideoGravity.resizeAspectFill.rawValue)
    self.present(playerController, animated: true) {
        player.play()
    }
}
Raymond
  • 1,108
  • 13
  • 32

0 Answers0