首页 > 其他 > 详细

单页面单视频全屏播放

时间:2020-11-07 12:32:50      阅读:42      评论:0      收藏:0      [点我收藏+]

在实际当中经常有这样的需要,要求把一个大的视频在线看,微信又发不过去,只能做一个兼容微信和电脑的页面,点开就能看,也方便分享。

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <title>单视频播放页面</title>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        html , body{
            width: 100%;
            height: 100%;
            background-color: #000;
        }
        #box{
            width: 100%;
            height: 100%;
            position: relative;
        }
        #box video{
            margin: 0 auto;
            position: absolute;
            top: 0;
            left: 0;
        }
    </style>
</head>
<body>
    <div id="box">
        <video id="video" style="width: 100%" controls x5-playsinline webkit-playsinline playsinline x-webkit-airplay autoplay loop>
            <source src="视频文件路径.mp4" type="video/mp4">
        </video>
    </div>
<script type="text/javascript">
    var v = document.getElementById(video);
    var b = document.getElementById(box);
    var w = window.innerWidth;
    var h = window.innerHeight;
    if(w>h){
        v.style.maxHeight = h+"px";
        v.style.height = h+"px";
    }else{
        v.style.maxWidth = w+"px";
        v.style.Width = w+"px";
        //竖屏
        v.style.marginTop = (h-v.scrollHeight)/2-40+"px"
    }
</script>
</body>
</html>

 

单页面单视频全屏播放

原文:https://www.cnblogs.com/dwj192/p/13940487.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!