正常在瀏覽器好好的視頻,在微信內(nèi)置瀏覽器中點擊播放全屏消恍,樣式也不一樣既峡,自動播放失效。罪魁禍?zhǔn)资俏⑿虐裿ideo標(biāo)簽都成微信規(guī)則的了匀归。下面方式可以解決視頻播放全屏以及不能自動播放的問題坑资。
<video id="videoPlay" class="video" autoplay="autoplay" playsinline="true" preload="auto" poster="" height="100%" style="text-align: -webkit-center; margin: 0 auto;" controls="">
<source src="move.mp4" type="video/mp4" >
</video>
(function () {
//觸屏即加載音樂
// document.addEventListener('touchstart', function() {undefined
// document.getElementById('media').play()
// }
//進入微信頁面即加載
// document.addEventListener('WeixinJSBridgeReady', function() {undefined
// document.getElementById('videoPlay').play()
// })
var voice = document.getElementById('videoPlay');
if(typeof WeixinJSBrdgeReady=="object" && typeof WeixinJSBridge.invoke == "function"){
voice.play()
}else{
if (document.addEventListener) {
document.addEventListener("WeixinJSBridgeReady", function () {
voice.play();
}, false);
} else if (document.attachEvent) {
document.attachEvent("WeixinJSBridgeReady", function () {
voice.play();
});
document.attachEvent("onWeixinJSBridgeReady", function () {
voice.play();
});
}
}
})