不用object或者embed标签插入就能完成video的播放,那要感谢html5和css3的强大功能了,详细了解:
1 |
现在我们就step by step的详细指导吧,大家千万不要嫌长哦,不敢兴趣的地方可以直接略过,主要是为了保持文章的完整性O(∩_∩)O:
step1:HTML5 标记
Step 2: 下载 jPlayer插件
插件地址: jplayer.org
然后在head里面引用,当然是基于Jquery的插件
Step 3: Player 标记
html如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <!--container for everything--><div id="jp_container_1" class="jp-video jp-video-360p"> <!--container in which our video will be played--> <div id="jquery_jplayer_1" class="jp-jplayer"></div> <!--main containers for our controls--> <div class="jp-gui"> <div class="jp-interface"> <div class="jp-controls-holder"> </div><!--end jp-controls-holder--> </div><!--end jp-interface--> </div><!--end jp-gui--> <!--unsupported message--> <div class="jp-no-solution"> <span>Update Required</span> Here's a message which will appear if the video isn't supported. A Flash alternative can be used here if you fancy it. </div></div><!--end jp_container_1--> |
Update Required Here’s a message which will appear if the video isn’t supported. A Flash alternative can be used here if you fancy it.
Step 4: Controls 标记
html如下:
1 2 3 4 | <!--play and pause buttons--><a class="jp-play" tabindex="1" href="javascript:;">play</a><a class="jp-pause" tabindex="1" href="javascript:;">pause</a><!--progress bar--> |
1 | <span class="time-sep">/</span> |
1 2 3 4 | <!--mute / unmute toggle--><a class="jp-mute" title="mute" tabindex="2" href="javascript:;">mute</a><a class="jp-unmute" title="unmute" tabindex="2" href="javascript:;">unmute</a><!--volume bar--> |
1 2 3 | <!--full screen toggle--><a class="jp-full-screen" title="full screen" tabindex="3" href="javascript:;">full screen</a><a class="jp-restore-screen" title="restore screen" tabindex="3" href="javascript:;">restore screen</a> |
主要包含:
播放,停止按钮
进度条
时间提醒
静音切换
卷栏
全屏切换
Step 5: 添加视频
jPlayer插件目前支持以下视频格式:
mp3
mp4 (AAC/H.264)
ogg (Vorbis/Theora)
webm (Vorbis/VP8)
wav
使用代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <!--instantiate--><script type="text/javascript">// <![CDATA[$(document).ready(function(){ $("#jquery_jplayer_1").jPlayer({ ready: function () { $(this).jPlayer("setMedia", { m4v: "mi4.m4v", ogv: "mi4.ogv", webmv: "mi4.webm", poster: "mi4.png" }); }, swfPath: "js", supplied: "webmv, ogv, m4v", size: { width: "570px", height: "340px", cssClass: "jp-video-360p" } }); });// ]]></script> |
更多使用方法见:jplayer.org
Step 6: Video 基本样式
css代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,and,address,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video,input,textarea,select{background:transparent;border:0;font-size:100%;margin:0;outline:0;padding:0;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}abbr[title],dfn[title]{border-bottom:1px dotted;cursor:help}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}del{text-decoration:line-through}hr{background:transparent;border:0;clear:both;color:transparent;height:1px;margin:0;padding:0}mark{background-color:#ffffb3;font-style:italic}input,select{vertical-align:middle}ins{background-color:red;color:white;text-decoration:none}ol,ul{list-style:none}table{border-collapse:collapse;border-spacing:0}a{text-decoration:none;} body { margin:0; padding:0; background:url("bg.jpg") repeat;} .jp-video { font-family:"Helvetica Neue", Helvetica, Arial, sans-serif; position:relative; -webkit-box-shadow:0px 0px 20px rgba(0,0,0,.3); -moz-box-shadow:0px 0px 20px rgba(0,0,0,.3); box-shadow:0px 0px 20px rgba(0,0,0,.3);}.jp-video-360p { width:570px; margin: 100px auto;}.jp-video-full { width:480px; height:270px; position:static !important; position:relative}.jp-video-full .jp-jplayer { top: 0; left: 0; position: fixed !important; position: relative; /* Rules for IE6 (full-screen) */ overflow: hidden; z-index:1000;} .jp-video-full .jp-gui { position: fixed !important; position: static; /* Rules for IE6 (full-screen) */ top: 0; left: 0; width:100%; height:100%; z-index:1000;}.jp-video-full .jp-interface { position: absolute !important; position: relative; /* Rules for IE6 (full-screen) */ bottom: 0; left: 0; z-index:1000;} |
Step 7:基本控制样式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | css样式如下:.jp-interface { position: relative; width:100%; height: 35px; background-image: -webkit-linear-gradient(top, rgb(242, 242, 242), rgb(209, 209, 209)); background-image: -moz-linear-gradient(top, rgb(242, 242, 242), rgb(209, 209, 209)); background-image: -o-linear-gradient(top, rgb(242, 242, 242), rgb(209, 209, 209)); background-image: -ms-linear-gradient(top, rgb(242, 242, 242), rgb(209, 209, 209)); background-image: linear-gradient(top, rgb(242, 242, 242), rgb(209, 209, 209)); filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#f2f2f2', EndColorStr='#d1d1d1'); -webkit-box-shadow: inset 0px 1px 0px #f7f7f7, inset 0px -1px 0px #e2e2e2; -moz-box-shadow: inset 0px 1px 0px #f7f7f7, inset 0px -1px 0px #e2e2e2; box-shadow: inset 0px 1px 0px #f7f7f7, inset 0px -1px 0px #e2e2e2;} div.jp-controls-holder { clear: both; width:570px; margin: 0 auto; position: relative; overflow:hidden;} |
Step 8: 停止播放按钮
css样式如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | a.jp-play,a.jp-pause { width:40px; height:35px; float:left; text-indent:-9999px; outline:none;} a.jp-play { background: url("sprite.png") 0 0 no-repeat;} a.jp-pause { background: url("sprite.png") -40px 0 no-repeat; display: none;} .separator { background-image:url("separator.png"); background-repeat:no-repeat; width: 2px; height: 35px; float:left; margin-top: 7px; margin-right: 10px;} |
Step 9: 进度条样式
css样式如下:
1 2 3 4 5 6 7 8 9 10 特别申明:
本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性! 本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担! 如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com
|