jQuery HTML5 視頻播放控制核心代碼:
<video class="pause" controls poster="images/vedio.jpg" width="663" height="373">
<source src="video/Defone3.8_1.mp4" type="video/mp4">
您的浏覽器不支持html5!
</video>
<script type="text/javascript">
$('video').click(function() {
if ($(this).hasClass('pause') ) {
$("video").trigger("play");
$(this).removeClass('pause');
$(this).addClass('play');
} else {
$("video").trigger("pause");
$(this).removeClass('play');
$(this).addClass('pause');
}
});
</script>
如果想正式用戶播放環境,建議大家使用jplayer之類的工具
<script type="text/javascript" src="../../lib/jquery.min.js"></script>
<script type="text/javascript" src="../../dist/jplayer/jquery.jplayer.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function (event) {
$(this).jPlayer("setMedia", {
title: "Bubble",
m4a: "http://jplayer.org/audio/m4a/Miaow-07-Bubble.m4a",
oga: "http://jplayer.org/audio/ogg/Miaow-07-Bubble.ogg"
});
},
swfPath: "../../dist/jplayer",
supplied: "m4a, oga",
wmode: "window",
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: true,
remainingDuration: true,
toggleDuration: true
});
});
//]]>
</script>
下載地址:http://www.jb51.net/jiaoben/32245.html
jPlayer是一個JavaScript寫的完全免費和開源 (MIT) 的jQuery多媒體庫插件 (現在也是一個Zepto插件) jPlayer可以讓你迅速編寫一個跨平台的支持音頻和視頻播放的網頁. jPlayer的豐富API可以讓你創建一個個性化多媒體應用,因此也獲得越來越多的社區成員的支持和鼓勵。