12

ios 微信自带浏览器 微信小程序 webrtc 或视频不能自动播放(黑屏)的解决方法

 1 year ago
source link: https://blog.p2hp.com/archives/8538
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

ios 微信自带浏览器 微信小程序 webrtc 或视频不能自动播放(黑屏)的解决方法

为iOS版微信浏览器刚刚支持webrtc的缘故,只有一则3月10多日的新闻说随着ios的更新,采用wkwebview的微信浏览器也已经支持webrtc,再没有其它有用的资料。

后来看了一个使用webrtc支持ios版微信浏览器的网站,发现玄机竟然是下面的代码

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

加上去以后,测试OK,可以不用加班了

值得注意的是,WeixinJSBridgeReady这个事件会在页面加载后马上触发,因此,上面的这个代码最好写在window.onload=>(){}函数体中,所以video标签也要提前写在html网页中,不要等webrtc通道建立后再去动态创建video。

顺便贴一下我的video标签使用的属性

<video preload="auto" autoplay="autoplay" x-webkit-airplay="true" playsinline ="true" webkit-playsinline ="true" x5-video-player-type="h5" x5-video-player-fullscreen="true" x5-video-orientation="portraint">
</video>




About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK