自制是视频播放器
现在HTML5新增了很多视频制作方面的属性,比如控制音量(volume)的,视频进度(duration)的还有全屏(webkitRequestFullScreen)的,等等,很多很多,这就使得当对默认的视频播放器样式 不满意时,自己也可以做一个替换默认样式。
- 自制播放器样式效果如下:
录的比较仓促,媒体文件就一个视频,可以自己选择
引用的外部文件主要有一些字体文件,jquery包,还有一个兼容HTML5的包
代码如下:
head部分
<!-- 引入两个字体包 -->
<link rel="stylesheet" href="font/mobilephone/iconfont.css">
<link rel="stylesheet" href="css/font-awesome.css">
<script src="lib/jquery/jquery-3.4.1.min.js"></script>
<!-- IE低版本浏览器兼容HTML5 -->
<!--if lte ie 8>
<script src="https://cdn.bootcss.com/html5shiv/r29/html5.js"></script>
<![endif]-->
<style>
.wrap {
position: relative;
width: 800px;
height: 500px;
margin: 50px auto;
border: 1px solid #000;
background: url(images/loading.gif) no-repeat #000 center;
background-size: auto 100%;
overflow: hidden;
}
video {
height: 100%;
margin: 0 auto;
display: none;
}
.bar {
position: absolute;
left: 0px;
bottom: 0px;
width: 800px;
height: 50px;
background: rgba(0,0,0,0.5);
display: none;
}
.play_btn {
position: absolute;
left: 15px;
top: 20px;
display: block;
height: 30px;
width: 30px;
font-size: 30px;
text-align: center;
line-height: 20px;
color: #fff;
cursor: pointer;
}
.play_btn:hover {
color: #0d0;
}
.strip {
position: absolute;
left: 0px;
top: 0px;
height: 3px;
width: 800px;
background: rgba(255,255,255,0.2);
overflow: hidden;
cursor: pointer;
}
.inner_strip {
width: 0%;
height: 100%;
background: #0d0;
}
.play_time {
position: absolute;
left: 65px;
height: 50px;
font: 400 12px/60px "microsoft yahei";
text-align: center;
color: #fff;
}
.speed {
position: absolute;
left: 200px;
top: 10px;
height: 40px;
font: 500 14px/40px "microsoft yehei";
color: #fff;
cursor: pointer;
}
.speed:hover {
color: #0d0;