js+video实现视频播放


<html>
	<head>
		<meta charset="utf-8" />
		<title>视频案例title>
	head>
	<body>
		<video width="" height="" autoplay controls loop="loop" poster="img/lbt3_img1.jpg">
			<source src="video/iceage4.mp4" type="video/mp4">source>
			<source src="video/street.wmv" type="video/ogg">source>
			<source src="video/iceage4.webm" type="video/webm">source>
			当前浏览器不支持 video直接播放,点击这里下载视频: <a href="myvideo.webm">下载视频a>
		video>
		<button id="play">播放button>
		<button id="ponse">暂停/继续button>
		<button id="meter">静音button>
		<button id="load">重播button>
		<script type="text/javascript">
			var play = document.getElementById("play");
			var ponse = document.getElementById("ponse");
			var meter = document.getElementById("meter");
			var load = document.getElementById("load");
			var video1 = document.getElementsByTagName("video")[0];
			play.onclick = function () {
				video1.play();
			}
			ponse.onclick = function () {
				if (video1.paused) {
					video1.play();
				} else{
					video1.pause();
				}
			}
			load.onclick = function () {
				video1.load();
				video1.autoplay=true;
			}
			meter.onclick = function () {
				if (video1.muted) {
					video1.muted=false;
				}else{
					video1.muted=true;
				}
			}
		script>
	body>
html>

你可能感兴趣的:(每天记录一个小技巧,js)