<video id="videoALL"
src="video/01.mp4"
poster="images/1.jpg" /*视频封面*/
preload="auto"
webkit-playsinline="true" /*这个属性是ios 10中设置可以
让视频在小窗内播放,也就是不是全屏播放*/
playsinline="true" /*IOS微信浏览器支持小窗内播放*/
x-webkit-airplay="allow"
x5-video-player-type="h5" /*启用H5播放器,是wechat安卓版特性*/
x5-video-player-fullscreen="true" /*全屏设置,
设置为 true 是防止横屏*/>
x5-video-orientation="portraint" /*播放器支付的方向,
landscape横屏,portraint竖屏,默认值为竖屏*/
style="object-fit:fill"></video> <p id="videobox">
<video
id="videoALL"
src="mp4.mp4"
poster="1.jpg"
preload="auto"
webkit-playsinline="true"
playsinline="true"
x-webkit-airplay="allow"
x5-video-player-type="h5"
x5-video-player-fullscreen="true"
x5-video-orientation="portraint"
style="object-fit:fill">
</video>
<p id="btn" onclick="playcontr()"></p></p><p id="videoend"><p id="againbtn" onclick="playcontr()"></p></p> *{
padding: 0;
margin: 0;
}
#videobox{position: absolute;width: 100%;height: 100%;background-color: green;background-image: url(1.jpg);background-size: 100% 100%;background-position: top;overflow: hidden;}
#videoALL{
height: auto;
position: absolute;
width: 100%;
top: 0;
left: 0;
object-fit: fill;
display: block;
background-size: cover;
overflow: hidden;}
#btn,#againbtn{width: 81px;height: 75px;position: absolute;top: 50%;left:50%;margin-top: -37.5px;margin-left: -40.5px;background-image: url(btn.png);background-size: 100% 100%;}
#videoend{position: absolute;background-color: pink;display: none;background-image: url(2.jpg);background-size: cover;background-position: top;} <script>var videoALL = document.getElementById('videoALL'),
videobox = document.getElementById('videobox'),
btn = document.getElementById('btn'),
videoend = document.getElementById('videoend');var clientWidth = document.documentElement.clientWidth;var clientHeight = document.documentElement.clientHeight;
videoALL.style.width = clientWidth + 'px';
videoALL.style.height = 'auto';
document.addEventListener('touchmove', function(e){e.preventDefault()}, false);function stylep(pId){
pId.style.width = clientWidth + 'px';
pId.style.height = clientHeight +200+ 'px';
}
stylep(videobox);
stylep(videoend);var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 function playcontr(){ if (isAndroid) {
videoALL.style.width = window.screen.width + 'px';
videoALL.style.height = window.screen.height + 'px';
}
videobox.style.display = "block";
videoALL.play();
btn.style.display = "none";
videoend.style.display = "none";
};
videoALL.addEventListener('pause',function(){
videoALL.style.width = clientWidth + 'px';
btn.style.display = "block";
})
videoALL.addEventListener("ended",function(){
videoALL.pause();
videobox.style.display = "none";
videoend.style.display = "block";
});</script> 以上就是详细分析H5微信播放全屏问题的示例代码的详细内容,更多请关注Gxl网其它相关文章!
查看更多关于详细分析H5微信播放全屏问题的示例代码的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did65364