ios WeChat comes with a browser, WeChat applet webrtc or video can not be automatically played (black screen) solution

default-user-image.png

Because the iOS version of WeChat browser just supports webrtc, there is only one news on March 10th that with the update of ios, the WeChat browser using wkwebview also supports webrtc, and there is no other useful information.

Later, I saw a website that uses webrtc to support the ios version of WeChat browser, and found that the mystery turned out to be the following code

 1   2   3
 document .addEventListener( "WeixinJSBridgeReady" , function () {   document .getElementById( "remoteVideo" ).play();   }, false );

After adding it, the test is OK, and you don’t have to work overtime.

It is worth noting that the WeixinJSBridgeReady event will be triggered immediately after the page is loaded. Therefore, the above code is best written in the function body of window.onload=>(){}, so the video tag should also be written in the html page in advance , don’t wait for the webrtc channel to be established before dynamically creating video.

By the way, paste the attributes used by my video tag

 1   2
 < video preload = "auto" autoplay = "autoplay" x-webkit-airplay = "true" playsinline = "true" webkit-playsinline =

This article is reprinted from https://blog.p2hp.com/archives/8538
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment