2

I'm getting a very strange issue related to AVPlayer, that the video get freezes and the time and the player progress is continuous to move.

Previously my code is in swift 4 and this issue didn't exist at that time. I have updated the code to support swift 5 and currently using xcode-11.3 and this issue occur.

These logs are getting printing:

  • maxSFB long exceeds maximum allowed value
  • Error deserializing ICS info
  • Error decoding packets

please check screenshots for the same

Error Log 1 Error Log 2

//Variables
var avPlayerViewController: AVPlayerViewController?
fileprivate var avPlayer: AVPlayer?
weak var delegate: OBVideoPlayerDelegate?
var urlString: String = ""

       func setup() {

          let resourceLoaderManager = VIResourceLoaderManager()
          self.resourceLoaderManager = resourceLoaderManager

          playerItem = resourceLoaderManager.playerItem(with: url)

          playerItem?.canUseNetworkResourcesForLiveStreamingWhilePaused = true
          avPlayer = AVPlayer(playerItem: playerItem)
          avPlayerViewController = AVPlayerViewController()

          avPlayerViewController?.player = avPlayer
          avPlayerViewController?.view.frame = self.bounds
      avPlayerViewController?.videoGravity = AVLayerVideoGravity.resizeAspectFill

        avPlayerViewController?.addObserver(self, forKeyPath: OBVideoPlayerView.kVideoBoundKey, options: NSKeyValueObservingOptions.new, context: nil)

        //Play
        self.play()

        periodicTimeObserverReference = avPlayer?.addPeriodicTimeObserver(forInterval: CMTimeMakeWithSeconds(1, preferredTimescale: 1), queue: DispatchQueue.main) { (CMTime) -> Void in
            self.handlePlayerStatus()
        }
        NotificationCenter.default.addObserver(self, selector: #selector(self.playerDidFinishPlaying(note:)), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: avPlayer?.currentItem)
        playerItem?.addObserver(self, forKeyPath: "status", options: .init(rawValue: 0), context: nil)
        playerItem?.addObserver(self, forKeyPath: "playbackLikelyToKeepUp", options: [.initial, .new], context: nil)

}

//Play video
func play() {
    self.delegate?.videoWillStartPlaying?(playerView: self)
    avPlayer?.playImmediately(atRate: 1.0)
}

@objc func playAgain() {
    avPlayer?.playImmediately(atRate: 1.0)
}

//Pause video
func pause() {
    self.delegate?.videoWillPause?()
    avPlayer?.pause()

}

Also please check the video getting stuck in this error video link: https://drive.google.com/file/d/15Y17GmX4kebE385x0u_2rBqcL4GPhtJF/view?usp=sharing

Parv Bhasker
  • 1,773
  • 1
  • 20
  • 39

0 Answers0