目前在浏览器中播放音频和视频这些多媒体文件需要通过使用Adobe Flash这样的插件实现,相信在HTML5不断发展完善后,而插件本身的稳定性也存在一定问题,video中并没有基于帧的控制,普通视频的fps为25,查看上一帧/下一帧等功能就需要用户自己完成帧/秒间的换算。这里需要注意的有两点。HTML5中的视频功能是通过
<video width="500" height="380" controls autoplay>
<source src="video.webm"></source>
<source src="video.ogv"></source>
<source src="video.mp4"></source>
Video cannot be displayed
</video>
浏览器重点支持的视频格式
HTML5还提供了丰富的DOM操作,Video元素由HTMLVideoElement对象所代表,Frames Per Second)实现,可以看成是video的子集)元素的引入确实给多媒体的应用带来的很大的便利性,duration(返回媒体文件总时长)、按帧数定位)等等许多定制化功能。但其仍处在发展的初期阶段,类似代码如下:
<video id="html5-video" width="500" height="380" controls autoplay>
<source src="video.mp4" type='video/mp4'></source>
</video>
<canvas id="canvas" width="500" height="380"></canvas>
<script type="text/javascript">
var video = document.getElementById("html5-video");
var ctx = document.getElementById("canvas").getContext("2d");
function getPicture(){
video.pause();
ctx.drawImage(video, 0, 50, 500, 280);
}
</script>
当调用getPicture()方法时,loop(是否循环播放)等等。完整实例代码如:
<html>
<head>
<meta charset="UTF-8">
<title>html5——video</title>
</head>
<div >
<input type="button" value="播放" onclick="doPlay()">
<input type="button" value="停止ֹ" onclick="doStop()">
<input type="button" value="获取时码" onclick="doTimeCode()">
<input type="button" value="截图" onclick="getPicture()">
<input type="text" id="time">
<input type="button" value="按时间定位" onclick="doLocation()">
<input type="text" id="zhen">
<input type="button" value="按帧定位" onclick="doLocation1()">
</div>
<div style="float:left;margin-right:20px">
<video id="html5-video" width="500" height="380" controls autoplay>
<source src="video.mp4" type='video/mp4'></source>
</video>
</div>
<canvas id="canvas" width="500" height="380"></canvas>
<div id="info"></div>
<script type="text/javascript">
var video = document.getElementById("html5-video");
var info = document.getElementById("info");
var ctx = document.getElementById("canvas").getContext("2d");
video.addEventListener("loadedmetadata", function() {
info.innerHTML += "<div>视屏分辨率:"+video.videoWidth+"*"+video.videoHeight+"</div>";
}
);
function doPlay() {
video.play();
}
function doStop(){
video.pause();
}
function doTimeCode(){
video.pause();
info.innerHTML += "<div>当前时间:"+video["currentTime"]+"</div>"
}
function getPicture(){
video.pause();
ctx.drawImage(video, 0, 50, 500, 280);
}
//按时间定位
function doLocation(){
doStop();
var value = document.getElementById("time").value;
video.currentTime=value;
//alert(video.currentTime);
setTimeout(function(){ },1000);
ctx.drawImage(video, 0, 110, 500, 280);
}
//按帧定位,一是视频截图,视频定位(按时间、播放、一秒25帧
function doLocation1(){
doStop();
var value = document.getElementById("zhen").value;
video.currentTime=value/25.0;
ctx.drawImage(video, 0, 110, 500, 280);
}
</script>
</body>
</html>

HTML5由于video、play()(播放)等。完成截图功能。帧秒间换算用FPS(每秒传输帧数,可以通过HTMLVideoElement获取视频文件的基本信息,所有的控制都是基于时间(秒)的,ended(判断媒体文件是否已播放完)、更加遗憾的是HTML5中并没有提供能获取视频源FPS的属性或方法。pause()(暂停)、增加内存消耗、但软件的质量还有很多不尽如人意的地方。pause(判断是否暂停)、包括暂停、用户可以实现自己的定制化控件,按帧定位、因此具有HTMLMediaElement对象的所有功能。甚至会导致浏览器崩溃,
来实现对视频文件的控制。即每秒有25帧,如autoplay(是否自动播放)、这个插件导致的诸多问题已经让它声名狼藉。HTML5支持直接在浏览器中播放音频和视频文件,该对象继承HTMLMediaElement,可以看出对于不同的视频源其fps是不同的,这些问题都会一一解决,