Inline video play in iOS 10

I create a UIWebview that load a web page containing inline video player with m3u8 format. It is important that the video need to pass an authentication from server. In application, it is now using URLProtocol to handle the authentication challenge from server.


It is success to load the video in iOS 11 but failed in iOS 10.


I capture the log in URL Protocol and observe that the video keep in downloading .ts file for video playing in URLProtocol level.


But in iOS 10, there is no log which is asking for .ts file.


Is there any different for the inline video player behaviour between iOS 11 & iOS 10 ?

You’re in the process of painting yourself into a corner here. As time goes by more and more subsystems within iOS are moving outside of your process, and thus become invisible to your

URLProtocol
subclass. For example:
  • Most network requests made by the AV subsystem are done by a system process (

    mediaserverd
    ).
  • UIWebView
    has recently been deprecated, and its replacement,
    WKWebView
    , does all of its network requests out of process.

Frankly, I’m surprised you’ve been able to get this working on any recent version of the system.

The best way to play video that requires custom authentication is via the AVFoundation framework. Specifically, you’ll need an

AVAsset
, and once you have that you set a custom resource loader and then customise that via its delegate (
AVAssetResourceLoader
).

This approach works well but it’s problematic for web views because web views don’t give you access to the underlying

AVAsset
. If you want the web view to play full screen then you can bounce out to native code and do the playback yourself. However, if you need the video to play in line with other web content then I don’t know of any current solution that’s likely to stay viable in the long term.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Inline video play in iOS 10
 
 
Q