第十二课--H5Video(视频)

92 阅读1分钟
直到现在,仍然不存在一项旨在网页上显示视频的标准。
今天,大多数视频是通过插件(比如 Flash)来显示的。然而,并非所有浏览器都拥有同样的插件。
HTML5 规定了一种通过 video 元素来包含视频的标准方法。

视频格式
格式     MIME-type
MP4        video/mp4
WebM   video/webm
Ogg        video/ogg
<video width="320" height="240" controls>
  <source src="demo.mp4" type="video/mp4">
</video>
看案例
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Video(视频)</title>
</head>
<body>
 <video width="320" height="240" controls>
  <source src="5c176fd52220b.mp4" type="video/mp4">
</video>

<div style="text-align:center">
  <button onclick="playPause()">播放/暂停</button>
  <button onclick="makeBig()">放大</button>
  <button onclick="makeSmall()">缩小</button>
  <button onclick="makeNormal()">普通</button>
  <br>
  <video id="video1" width="420">
    <source src="5c176fd52220b.mp4" type="video/mp4">
  </video>
</div>
</body>
</html>
<script>
var myVideo=document.getElementById("video1");

function playPause()
{
	if (myVideo.paused)
	  myVideo.play();
	else
	  myVideo.pause();
}

	function makeBig()
{
	myVideo.width=560;
}

	function makeSmall()
{
	myVideo.width=320;
}

	function makeNormal()
{
	myVideo.width=420;
}
</script>