HTML5:视频控制
2016-06-17 16:32
441 查看
一:HTML5属性控制视频
属性解读
二:DOM属性控制视频
<span style="font-size:14px;"><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div style="text-align: center;">
<button onclick="playPause()">播放</button>
<button onclick="makeBig()">放大</button>
<button onclick="makeNormal()">原样</button>
<button onclick="makeSmall()">变小</button>
<br/>
<video id="viedo1" width="420px" style="margin-top: 15px;">
<source src="img/test.mp4" type="video/mp4"/>
</video>
</div>
<script type="text/javascript">
var myViedo = document.getElementById('viedo1');
function playPause(){
if(myViedo.paused)
myViedo.play();
}
function makeBig(){
myViedo.width=560;
}
function makeNormal(){
myViedo.width=420;
}
function makeSmall(){
myViedo.width=320;
}
</script>
</body>
</html></span>
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <video src="img/test.mp4" width="300px" height="200px" loop="3" autoplay="autoplay" controls="controls"></video> </body> </html>
属性解读
属性 | 值 | 描述 |
---|---|---|
autoplay | autoplay | 如果出现该属性,则视频在就绪后马上播放。 |
controls | controls | 如果出现该属性,则向用户显示控件,比如播放按钮。 |
pixels | pixels | 设置视频播放器的高度。 |
loop | loop | 如果出现该属性,则当媒介文件完成播放后再次开始播放。 |
preload | preload | 如果出现该属性,则视频在页面加载时进行加载,并预备播放。 如果使用 "autoplay",则忽略该属性。 |
src | url | 要播放的视频的 URL。 |
width | pixels | 设置视频播放器的宽度。 |
<span style="font-size:14px;"><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div style="text-align: center;">
<button onclick="playPause()">播放</button>
<button onclick="makeBig()">放大</button>
<button onclick="makeNormal()">原样</button>
<button onclick="makeSmall()">变小</button>
<br/>
<video id="viedo1" width="420px" style="margin-top: 15px;">
<source src="img/test.mp4" type="video/mp4"/>
</video>
</div>
<script type="text/javascript">
var myViedo = document.getElementById('viedo1');
function playPause(){
if(myViedo.paused)
myViedo.play();
}
function makeBig(){
myViedo.width=560;
}
function makeNormal(){
myViedo.width=420;
}
function makeSmall(){
myViedo.width=320;
}
</script>
</body>
</html></span>
相关文章推荐
- HTML5 离线web应用
- html5_ajax无刷新文件上传
- 安卓h5混合编程概述
- H5调用本地摄像头
- 调用HTML5的Canvas API绘制图形的快速入门指南
- ccah-500 第48题 Choose three reasons why should you run the HDFS balancer periodically
- ccah-500 第47题 What is the purpose of ZooKeeper in such a configuration
- Html5 postmessage 子父窗口传值
- ccah-500 第45题 You want to minimize the chance of data loss in your cluster. What should you do
- 利用html5的FileReader对象实现图片预览,利用FormData对象结合struts2实现无刷新文件上传(多参数)
- 最有范儿的H5制作工具—应用之星之表单控件详解
- ccah-500 第42题 want to set and enforce a block size of 128MB for all new files written to the cluster
- HTML5桌面通知:notification
- HTML5 data-* 自定义属性
- swiper的基础使用(二)
- Html5实现的简易视频播放器
- HTML5实现的音乐播放器
- Html5画图
- HTML5学习---新新手怎样在云主机上部署html5项目
- 吐槽H5框架开发