Minimize Stalling Streaming Video from Google Cloud

99 views Asked by At

Problem

Hi everyone. I am streaming video from google cloud storage in my app using AVKit/AVFoundation. Below you can see that I have set av.player?.automaticallyWaitsToMinimizeStalling = true but my video is still stalling often. I know this question will be quite broad because I am a beginner when it comes to streaming video. I do not want to download the videos because it will take to much space in the app.

Question

How can I prevent stalling of the video without downloading?

My Thoughts

  1. It may be an issue with Google Cloud, so I am open to trying something else
  2. Maybe there is a better way to perform the networking request
  3. Maybe I am not using AVKit/AVFoundation as best as I can

My Code

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        
        let av = AVPlayerViewController()
        let urlString = Utilities.shared.lessons![scrollViewIndex].videos[indexPath.row].videoURL
        
        if let url = URL(string: urlString) {
            
            let player = AVPlayer(url: url)
            av.player = player
            av.player?.automaticallyWaitsToMinimizeStalling = true
            self.present(av, animated: true) {
                
                av.player!.play()
                
            }
        }
    }

urlString is the URL provided by Google Cloud Storage for the video

*Edit* Video Specs

enter image description here

*Edit* Networking Info From Xcode

enter image description here

0

There are 0 answers