Autoplay MediaStream in WKWebView without user interaction

I'm noticing a very unreliable behavior when trying to autoplay a MediaStream object streamed over WebRTC in WKWebView.

It seems to be almost random whether the video element plays or shows the play-icon. I'm allowing autoplay in the configuration using the following statement:

Code Block
if #available(iOS 10.0, *) {
config.mediaTypesRequiringUserActionForPlayback = []
} else {
config.requiresUserActionForMediaPlayback = false
}


This blog post states that in order to autoplay a MediaStream object one of the following criteria should be met:
  • MediaStream-backed media will autoplay if the web page is already capturing.

  • MediaStream-backed media will autoplay if the web page is already playing audio. A user gesture will still be required to initiate audio playback.

However, as of writing, WKWebView does not support getUserMedia so capturing before playing won't be possible.

Is there any way to get reliable behavior playing a MediaStream object without user interaction in WKWebView?
Are you setting the configuration properties before you create the WebView?
Autoplay MediaStream in WKWebView without user interaction
 
 
Q