title: AVAsset not working with local file
body: <p>I'm downloading and caching (using <a href="https://github.com/vdugnist/DVAssetLoaderDelegate" rel="nofollow noreferrer">https://github.com/vdugnist/DVAssetLoaderDelegate</a>) videos in my app. When the app starts, I check for a downloaded file, and if it exists, I initialize the asset with the local file, otherwise, I initialize it with the remote URL. Then, when the download completes, I write the video file in the cache directory. I've checked the written file and it exists, and is a valid file (I've navigated the simulator's file system and found the file. It's there.).</p>
  
  <p>When I launch the app the next time, I check for the existing file (it's successfully found), I initialize the player with that, but it never loads. I'm not getting any errors, but the buffer never gets any time ranges, video doesn't play, nothing is called etc.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>asset = [self resolvedAssetWithURL:url];
  playerItem = [AVPlayerItem playerItemWithAsset:asset];
  player = [AVPlayer playerWithPlayerItem:playerItem];
  </code></pre>
  
  <p>Where:</p>
  
  <pre><code>-(AVAsset*)resolvedAssetWithURL:(NSURL*)url{
      NSURL *localURL = [self localURLForCachedRemoteURL:url];
      if(localURL){
  #if DEBUG
          NSLog(@"Using cached copy for video at %@", url.absoluteString);
  #endif
          videoIsLocal = YES;
          return [AVURLAsset URLAssetWithURL:localURL options:nil];
      }else{
          return [self assetWithoutCacheForURL:url];
      }
  }
  </code></pre>
  
  <p>Where:</p>
  
  <pre><code>-(NSURL*)localURLForCachedRemoteURL:(NSURL*)remoteURL{
      NSString *cachedPath = [Cache cachedVideoDataRelativePathForURLPath:remoteURL.absoluteString];
      if(cachedPath){
          if([TUStorage fileExistsAtRelativePath:cachedPath]){
              return [NSURL fileURLWithPath:[TUStorage absolutePathForRelativePath:cachedPath]];
          }else{
              NSLog(@"Remote URL %@ has been cached at %@ but local copy was not found. Removing cache.", remoteURL.absoluteString, cachedPath);
              [Cache removeCachedVideoDataForURLPath:remoteURL.absoluteString];
              return nil;
          }
      }else{
          return nil;
      }
  }
  </code></pre>
  
  <p>I've got some custom methods there but you get the idea. The file is there and playable (it's the same data with the actual playing video when I load remotely with no issues).</p>
  
  <p>I've took care of:</p>
  
  <ul>
  <li>Resolving to the correct path (the path leading to the cache directory is randomized every time, I've handled that).</li>
  <li>Using <code>fileURLWithPath:</code> instead of the regular URL initializer when loading the local asset, as seen in the code.</li>
  </ul>
  
  <p>What am I doing wrong? (I am on iOS 11.2.6)</p>