What to do when AVPlayer stalls and/or pauses with no information as to why

I'm using AVPlayer and sometimes the player randomly pauses. I'm observing \.timeControlStatus but the only response I get .paused with no info as to why it's paused.

I'm also observing \.isPlaybackLikelyToKeepUp\.isPlaybackBufferEmpty, and \.isPlaybackBufferFull but nothing fires for those. However using Notification.Name.AVPlayerItemPlaybackStalled I do get a print statement that says "stalled". 

I have no idea what to do because the player is justing sitting there and I get no information as to what the problem.
  1. How can I find out the exact reason why the player is stalled?

  2. How do I resume automatic play after the player is paused?

code is in attachment


I don't know how to edit my question but I forgot to add that I also have this set:
Code Block
playerItem?.preferredForwardBufferDuration = TimeInterval(1.0)

Are you streaming video, or is it from your camera/local files?
@shanecowherd I'm streaming from Firebase.
@shanecowherd

The video is 20 secs, after 5 sec it pauses indefinitely, I added this code inside the AVPlayerItemPlaybackStalled selector method and it prints: isPlaybackBufferFull -False, isPlaybackBufferEmpty -True, isPlaybackLikelyToKeepUp -False.

What's odd is I have play button, when it pauses it appears, when I press it the video plays fine (assuming it doesn't pause again) so the buffer must be full. The thing is the KVO observers give no indication that the buffer is full. Basically if I showed an activity indicator instead of a play button the activity indicator would spin forever. Once the buffer is full there should be some sort of response but there isn't. As you can see from the code in the question, I added all the KVO and Notifications.


Code Block
@objc func playerItemPlaybackStalled(_ notification: Notification) {
 guard let playerItem = notification.object as? AVPlayerItem else { return }
        if playerItem.isPlaybackBufferFull {
            print("isPlaybackBufferFull -True")
        } else {
            print("isPlaybackBufferFull -False")
        }
        if playerItem.isPlaybackBufferEmpty {
            print("isPlaybackBufferEmpty -True")
        } else {
            print("isPlaybackBufferEmpty -False")
        }
        if playerItem.isPlaybackLikelyToKeepUp {
            print("isPlaybackLikelyToKeepUp -True")
        } else {
            print("isPlaybackLikelyToKeepUp -False")
        }
}

This is what I came up with as a solution https://stackoverflow.com/a/62512805/4833705
https://developer.apple.com/documentation/avfoundation/avplayer/1643482-automaticallywaitstominimizestal

set that to true instead. It’s doing exactly what the docs say it would do when false.
What to do when AVPlayer stalls and/or pauses with no information as to why
 
 
Q