AVFragmentedAssetMinder not working on iPhone device but works on simulator

Hi,

We have fragmented movie data that comes through WebSecureSocket (wss://). We are writing that into a temp.mp4 and simultaneously playing the fragments that got written into the file. So, we used AVFragmentedAsset and AVFragmentedAssetMinder for this. It works as expected in the simulator. But in the device, it doesn't update the duration of the asset and doesn't post .AVAssetDurationDidChange notification. Not sure what could be the issue. Already spent 2 days figuring out this but no luck. Can someone help me on this please,

This is the code.

// WSS listener
func onDataReceived(data:Data) {
    tempMovieFile.write(data)

    if !startedPlay {
        // called only at the begining
        startedPlay = true
        DispatchQueue.global().async {
            sleep(2) 
            streamDelegate?.didReceivedInitialData()
        }
    }
}

And

protocol StreamDataDelegate {
  func didReceiveInitialData();
}

class PlayerController: StreamDataDelegate {
   
  static let ASSET_MINDER = AVFragmentedAssetMinder()
   
  let player = AVPlayer()
   
  var fragmentedAsset:AVFragmentedAsset? = nil
   
  init(){
    NotificationCenter.default.addObserver(self, selector: #selector(onVideoUpdate), name: .AVAssetDurationDidChange, object: nil)
  }
   
  func didReceiveInitialData() {
    // URL --> same file where movie data is currently being written
    self.fragmentedAsset = AVFragmentedAsset(url: getTemporaryMovieFile()!)
    self.fragmentedAsset?.loadValuesAsynchronously(forKeys: ["duration", "containsFragments", "canContainFragments"]) {
      PlayerController.ASSET_MINDER.mindingInterval = 1
      PlayerController.ASSET_MINDER.addFragmentedAsset(self.fragmentedAsset!)
      self.player.replaceCurrentItem(with: AVPlayerItem(asset: self.fragmentedAsset!))
      self.player.play()
    }
  }
   
  @objc
  func onVideoUpdate() {
    // This is not called in device.. but in simulator it works as expected
  }
}

If it works on one platform but not another, please file a bug report using the feedback assistant.

is this issue resolved for you? If you have any solution please post that here @Suryavel_TR. Thanks in Advance

If anyone have solution for this issue please comment

@Suryavel_TR @Ghantasala_Rajiv888 did you guys manage to solve this issue? I'm in the same situation.

AVFragmentedAssetMinder not working on iPhone device but works on simulator
 
 
Q