title: AVFragmentedAssetMinder not working on iPhone device but works on simulator
body: <p>We have fragmented movie data that comes through WebSecureSocket (wss://). We are writing that into a <strong>temp.mp4</strong> and simultaneously playing the fragments that got written into the file. So, we used <strong>AVFragmentedAsset</strong> and <strong>AVFragmentedAssetMinder</strong> for this. It works as expected in the simulator. But in the device, doesn't update the duration of the asset and doesn't post the <strong>.AVAssetDurationDidChange</strong> notification. Not sure what could be the issue. Already spent 2 days figuring out this but no luck. Can someone help me with this please,</p>
  <p>Implementation..</p>
  <pre class="lang-swift prettyprint-override"><code>public class WssPlayerSource: WebSocketDelegate {
      
      static let ASSET_MINDER = AVFragmentedAssetMinder()
      
      private let socketClient: WebSocketStreamingClient
      private var tempMovieFile:FileHandle? = nil
      private var startedPlay = false
      private var fragmentedAsset: AVFragmentedAsset? = nil
      
      let player = AVPlayer()
      
      init(withUrl url: URL) {
          socketClient = WebSocketStreamingClient(wssUrl: url)
          socketClient.delegate = self
          do {
              self.tempMovieFile = try getTemporaryMovieFileWriter()
          }catch {
              print(&quot;Error opening file&quot;)
          }
          
          NotificationCenter.default.addObserver(self, selector: #selector(onVideoUpdate), name: .AVAssetDurationDidChange, object: nil)
          socketClient.connect()
      }
      
      // Socket delegate
      public func didReceive(event: WebSocketEvent, client: WebSocket) {
          switch event {
          case .binary(let data):
              
              self.tempMovieFile?.write(data)
             
              if !startedPlay {
                  startedPlay = true
                  DispatchQueue.global().async { [weak self] in
                      self?.didReceivedInitialData()
                  }
              }
              break;
          default:
              break;
          }
      }
      
      func didReceivedInitialData() {
          fragmentedAsset = AVFragmentedAsset(url: getTemporaryMovieFile()!)
          fragmentedAsset?.loadValuesAsynchronously(forKeys: [&quot;duration&quot;, &quot;containsFragments&quot;, &quot;canContainFragments&quot;], completionHandler: {
              WssPlayerSource.ASSET_MINDER.mindingInterval = 1
              WssPlayerSource.ASSET_MINDER.addFragmentedAsset(self.fragmentedAsset!)
              
              self.player.replaceCurrentItem(with: AVPlayerItem(asset: self.fragmentedAsset!))
              self.player.play()
          })
      }
      
      @objc
      func onVideoUpdate() {
          print(&quot;Video duration updated..&quot;)
          // This is not called in device.. but in simulator it works as expected
      }
      
      func stop() {
          socketClient.forceDisconnect()
          NotificationCenter.default.removeObserver(self)
          if let asset = self.fragmentedAsset {
              WssPlayerSource.ASSET_MINDER.addFragmentedAsset(asset)
          }
      }
  }
  </code></pre>
  <p>And</p>
  <pre class="lang-swift prettyprint-override"><code>class ViewController: UIViewController {
      
      @IBOutlet var playerView:PlayerView!
      
      private static let SOCKET_URL = &quot;wss://...&quot;
      
      private var playerSource:WssPlayerSource? = nil
      private var playerLayer:AVPlayerLayer? = nil
      
      override func viewDidLoad() {
          super.viewDidLoad()
          
          self.playerSource =  WssPlayerSource(withUrl: URL(string: ViewController.SOCKET_URL)!)
          self.playerLayer = AVPlayerLayer(player: self.playerSource!.player)
          self.playerLayer?.videoGravity = .resize
          self.playerView.layer.addSublayer(self.playerLayer!)
      }
  }
  </code></pre>