3 Replies
      Latest reply on Feb 11, 2020 2:18 PM by eskimo
      keepsimple Level 1 Level 1 (0 points)



        I was posting a follow-up question to an old thread at here. But I am not sure if anyone would see it. Hence I took the liberty to post a separate thread. Thanks for understanding.


        I am using a custom protocol (Cronet network stack from Chromium) to play back video using AVPlayer.  The code called [NSURLProtocol registerClass] to register its custom protocol and it works well in Xcode 11.3 iOS simulator testing.  But the same code does not work on real device (iPhone, iOS 13). 


        The old thread I referred above seems to suggest that AVPlayer would never "see" the registered custom protocol, but I am wondering why it worked in simulator. And is it still true in recent iOS versions that AVPlayer would use a separate process (mediaserverd ?)  to play back the video hence ignoring the custom protocol?


        btw, I also tried to use AVAssetResourceLoaderDelegate to hijack the URL loading for AVPlayer, but did not work either in real device.




        • Re: NSURLProtocol registerClass works in simulator but not device for AVPlayer
          eskimo Apple Staff Apple Staff (13,095 points)

          I don’t think the situation here has changed since 2017.  If you want to load video using a custom protocol, you must use AVAssetResourceLoaderDelegate.  Fortunately, it seems that you’re starting with an AVPlayer, which means you have access to the AVAsset, so this shouldn’t be a problem.

          As to why AVAssetResourceLoaderDelegate is not working for you, that’s an entirely different kettle of fish.  I’m not an expert on that API — because it’s more of an AVFoundation thing that a networking thing — so my advice is that you ask for help with it over in Media > AVFoundation (Video and Camera).  If that doesn’t pan out, you can open a DTS tech support incident and talk to one of DTS’s AVFoundation specialists.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"