The jQuery HTML5 Audio / Video Library (jQuery jPlayer插件给你的站点增加视频和音频功能)
http://jplayer.org/
The jQuery HTML5 Audio / Video Library
jPlayer is the completely free and open source (MIT) media library written in JavaScript. A jQueryplugin, (and now a Zepto plugin,) jPlayer allows you to rapidly weave cross platform audio and video into your web pages. jPlayer's comprehensive API allows you to create innovative media solutions while support and encouragement is provided by jPlayer's active and growing community.
current release 2.9.2
now includes Zepto.js support


Choose jPlayer
- easy to get started, deploy in minutes
- totally customizable and skinnable using HTML and CSS
- lightweight - only 14KB minified and Gzipped
- free and open source, no licensing restrictions
- active and growing community providing support
- free plugins available for popular platforms
- extensive platform support - multi-codec, cross-browser and cross-platform
- comprehensive documentation and getting started guide
- consistent API and interface in all browsers, HTML5 or Adobe® Flash™
- extensible architecture

- <script type="text/javascript">
- $(document).ready(function(){
- $("#jquery_jplayer_1").jPlayer({
- ready: function () {
- $(this).jPlayer("setMedia", {
- m4a: "/media/mysound.mp4",
- oga: "/media/mysound.ogg"
- });
- },
- swfPath: "/js",
- supplied: "m4a, oga"
- });
- });
- </script>
- <div id="jquery_jplayer_1"></div>
- <div id="jp_container_1">
- <a href="#" class="jp-play">Play</a>
- <a href="#" class="jp-pause">Pause</a>
- </div>
Platforms and Browsers
- Windows: Chrome, Firefox, Internet Explorer, Safari, Opera
- Windows (legacy): IE6, IE7, IE8, IE9, IE10, IE11
- OSX: Safari, Firefox, Chrome, Opera
- iOS: Mobile Safari: iPad, iPhone, iPod Touch
- Android: Android 2.3 Browser
- Blackberry: OS 7 Phone Browser, PlayBook Browser


Media Support
- HTML5: mp3, mp4 (AAC/H.264), ogg (Vorbis/Theora), webm (Vorbis/VP8), wav
- Flash: mp3, mp4 (AAC/H.264), rtmp, flv
For cross-browser support, a format must be supplied that works in both HTML5 and Flash.
Optional additional formats may be supplied to increase cross-browser HTML5 support.
//----------------------------------------------------------
这个是一个非常好的jQuery新插件(jPlayer), 包括很多功能 : 它允许你播放多媒体文件, 暂停,音量调整,它拥有视频和音频播放功能会用到的所有功能控掉,同样他允许你改变它的所有样式(styles),因为他的全部外观都是在一个css文件 里面。另外,它同样支持HTML5 和支持所有主流的浏览器。它目前支持的格式有: mp3, ogg, m4a, m4v, ogv, wav等等。
简短的介绍以后,我们开始详细编码过程:
1. HTML
首先开始HTML部件
- <link rel="stylesheet" href="css/jplayer.blue.monday.css" type="text/css" media="all" />
- <link rel="stylesheet" href="css/main.css" type="text/css" media="all" />
- <script src="js/jquery.min.js" type="text/javascript"></script>
- <script src="js/jquery.jplayer.min.js" type="text/javascript"></script>
- <script src="js/main.js" type="text/javascript"></script>
- <div class="example">
- <div>
- <div class="players">
- <h2>Audio player</h2>
- <div class="jp-audio">
- <div class="jp-type-single">
- <div id="jquery_jplayer_1" class="jp-jplayer"></div>
- <div id="jp_interface_1" class="jp-interface">
- <ul class="jp-controls">
- <li><a href="#" class="jp-play" tabindex="1">play</a></li>
- <li><a href="#" class="jp-pause" tabindex="1">pause</a></li>
- <li><a href="#" class="jp-stop" tabindex="1">stop</a></li>
- <li><a href="#" class="jp-mute" tabindex="1">mute</a></li>
- <li><a href="#" class="jp-unmute" tabindex="1">unmute</a></li>
- </ul>
- <div class="jp-progress">
- <div class="jp-seek-bar">
- <div class="jp-play-bar"></div>
- </div>
- </div>
- <div class="jp-volume-bar">
- <div class="jp-volume-bar-value"></div>
- </div>
- <div class="jp-current-time"></div>
- <div class="jp-duration"></div>
- </div>
- <div id="jp_playlist_1" class="jp-playlist">
- <ul>
- <li>Audio track</li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- <div class="players">
- <h2>Video player</h2>
- <div class="jp-video jp-video-270p">
- <div class="jp-type-single">
- <div id="jquery_jplayer_2" class="jp-jplayer"></div>
- <div id="jp_interface_2" class="jp-interface">
- <div class="jp-video-play"></div>
- <ul class="jp-controls">
- <li><a href="#" class="jp-play" tabindex="1">play</a></li>
- <li><a href="#" class="jp-pause" tabindex="1">pause</a></li>
- <li><a href="#" class="jp-stop" tabindex="1">stop</a></li>
- <li><a href="#" class="jp-mute" tabindex="1">mute</a></li>
- <li><a href="#" class="jp-unmute" tabindex="1">unmute</a></li>
- </ul>
- <div class="jp-progress">
- <div class="jp-seek-bar">
- <div class="jp-play-bar"></div>
- </div>
- </div>
- <div class="jp-volume-bar">
- <div class="jp-volume-bar-value"></div>
- </div>
- <div class="jp-current-time"></div>
- <div class="jp-duration"></div>
- </div>
- <div id="jp_playlist_2" class="jp-playlist">
- <ul>
- <li>Tokyo weather</li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
在上同画出2播放器 - 音频和视频,它们两个的代码类似.
2. CSS
需要用到的CSS样式
- body{background:#eee;font-family:Verdana, Helvetica, Arial, sans-serif;margin:0;padding:0}
- .example{background:#FFF;width:1000px;height:500px;font-size:80%;border:1px #000 solid;margin:0.5em 10% 0.5em;padding:1em 2em 2em;-moz-border-radius:3px;-webkit-border-radius:3px}
- .example .players{float:left;margin:10px}
其它css文件(相关的图片文件):
css/jplayer.blue.monday.css, css/jplayer.blue.monday.jpg, css/jplayer.blue.monday.video.play.png, css/jplayer.blue.monday.video.play.hover.png and css/pbar-ani.gif这些全部包括在源码包里面.
3. JS这里是全部需要用到的js文件在这个例子中.
js/main.js
- $(document).ready(function(){
- $("#jquery_jplayer_1").jPlayer({
- ready: function () {
- $(this).jPlayer("setMedia", {
- mp3: "media/track.mp3",
- }).jPlayer("play"); // auto play
- },
- ended: function (event) {
- $(this).jPlayer("play");
- },
- swfPath: "swf",
- supplied: "mp3"
- })
- .bind($.jPlayer.event.play, function() { // pause other instances of player when current one play
- $(this).jPlayer("pauseOthers");
- });
- $("#jquery_jplayer_2").jPlayer({
- ready: function () {
- $(this).jPlayer("setMedia", {
- m4v: "media/tokyo.m4v",
- ogv: "media/tokyo.ogv",
- poster: "media/poster.jpg"
- });
- },
- ended: function (event) {
- $("#jquery_jplayer_2").jPlayer("play", 0);
- },
- swfPath: "js",
- supplied: "m4v, ogv",
- cssSelectorAncestor: "#jp_interface_2"
- })
- .bind($.jPlayer.event.play, function() { // pause other instances of player when current one play
- $(this).jPlayer("pauseOthers");
- });
- });
js/jquery.min.js and js/jquery.jplayer.min.js这几个是公共的文件 - jQuery库与播放插件js文件.
4. SWF
使用flash swf文件: 例子中的主播放器.
swf/Jplayer.swf
到这里差不多全部完成. 所有测试的多媒体播放文件都放置在‘media’ 下面.
音频文件 - track.mp3,
视频文件: tokyo.m4v + tokyo.ogv,
缩略图(poster): poster.jpg
如果你有遇到一个奇怪的问题和 ogg文件(oga, ogv, ogg) 不能使有,请尝试在你的 .htaccess 里面增加:
AddType audio/ogg .oga
AddType video/ogg .ogv .ogg
The jQuery HTML5 Audio / Video Library (jQuery jPlayer插件给你的站点增加视频和音频功能)的更多相关文章
- [jPlayer] HTML5 Audio & Video for jQuery
---------------------------------------------------------------------------------------------------- ...
- HTML5 Audio/Video 标签,属性,方法,事件汇总
HTML5 Audio/Video 标签,属性,方法,事件汇总 (转) 2011-06-28 13:16:48 <audio> 标签属性:src:音乐的URLpreload:预加载au ...
- HTML5 Audio/Video 标签,属性,方法,事件汇总 (转)
HTML5 Audio/Video 标签,属性,方法,事件 <audio> 标签属性:src:音乐的URLpreload:预加载autoplay:自动播放loop:循环播放contro ...
- [转帖]HTML5 Audio/Video 标签,属性,方法,事件汇总
HTML5 Audio/Video 标签,属性,方法,事件汇总 <audio>标签属性: src:音乐的URL preload:预加载 autoplay:自动播放 loop:循环播放 co ...
- 基于HTML5 audio元素播放声音jQuery小插件
by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=1609 一.前面的些唠 ...
- HTML5 Audio & Video 属性解析
一.HTML 音频/视频 方法 play() play() 方法开始播放当前的音频或视频. var myVideo=document.getElementById("video1" ...
- [转载]HTML5 Audio/Video 标签,属性,方法,事件汇总
<audio> 标签属性: src:音乐的URL preload:预加载 autoplay:自动播放 loop:循环播放 controls:浏览器自带的控制条 <audio id=& ...
- 【转载】HTML5 Audio/Video 标签,属性,方法,事件汇总
<audio> 标签属性: src:音乐的URL preload:预加载 autoplay:自动播放 loop:循环播放 controls:浏览器自带的控制条 Html代码 <au ...
- html5 audio/video 的那些坑
当我最近项目用到audio的时候,我们用到了jPlayer作为三方库. 功能实现了,暂停播放,进度条什么的,都很顺利的搞定了.后来考虑到当网速过慢时需要给播放按钮一个载入动画,然后就一发不可收拾了. ...
随机推荐
- hihocoder1322希尔伯特曲线(163周)
hihocoder1322 : 希尔伯特曲线(163周) 题目链接 思路: 看图,对每个Hn迭代到H(n-1) 直到迭代到1就ok,判断在哪个区间就好了.一定一定要注意数据的范围!! ac代码: // ...
- PHP获取数组中奇偶数
获取PHP数组中的奇偶数,可通过数组过滤函数array_filter(),看定义:该函数把输入数组中的每个键值传给回调函数.如果回调函数返回 true,则把输入数组中的当前键值返回结果数组中.数组键名 ...
- LM358资料及引脚图
LM358里面包括有两个高增益.独立的.内部频率补偿的双运放,适用于电压范围很宽的单电源,而且也适用于双电源工作方式,它的应用范围包括传感放大器.直流增益模块和其他所有可用单电源供电的使用运放的地方使 ...
- ajax访问遇到Session失效问题
最近由于一个项目,模块切换为ajax请求数据,当Session失效后,ajax请 求后没有返回值,只有响应的html:<html><script type='text/javascr ...
- 模拟出ios中流行的黑色背景底
[activityIndicatorView setBackgroundColor:[UIColor colorWithRed: green: blue: alpha:0.4]]; 用上面的语法,可以 ...
- [Mongo] 解决mongoose不支持条件操作符 $gt$gte:$lte$ne $in $all $not
reference : http://blog.sina.com.cn/s/blog_4df23d840100u25x.html 找到mongoose的安装目录 /usr/local/lib/node ...
- 简明python教程 --C++程序员的视角(五):面向对象的编程
面向对象的编程 在大多数时候你可以使用过程性编程,但是有些时候当你想要编写大型程序或是寻求一个更加合适的解决方案的时候,你就得使用面向对象的编程技术. 对象可以使用普通的属于对象的变量存储数据.属于一 ...
- 【BZOJ】【3437】小P的牧场
DP/斜率优化 斜率优化基本题……等等,好像就没啥变化啊= = 嗯目测这题跟仓库建设差不多?写题的时候倒是没想这么多……直接推了公式. $$f[i]=min\{f[j]+cal(j,i)+a[i]\} ...
- 【BZOJ】【1014】【JLOI2008】火星人prefix
Splay/二分/Hash 看了网上的题目关键字(都不用点进去看……我也是醉了)了解到做法= =那就上呗,前面做了好几道Splay的题就是为了练手搞这个的. Hash判断字符串是否相同应该很好理解吧? ...
- 我所遭遇过的游戏中间件---HumanIK
我所遭遇过的游戏中间件---HumanIK Autodesk HumanIK游戏中间件,为游戏创建更加可信.真实的角色动画.该中间件的全身逆向运动(FBIK)系统支持角色真实地与所在环境及其它角色进行 ...