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.

  • <
    •  
       
       
       
    • Watch this space!
    •  
  • >

current release 2.9.2

now includes Zepto.js support

fork it on Github

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

  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3. $("#jquery_jplayer_1").jPlayer({
  4. ready: function () {
  5. $(this).jPlayer("setMedia", {
  6. m4a: "/media/mysound.mp4",
  7. oga: "/media/mysound.ogg"
  8. });
  9. },
  10. swfPath: "/js",
  11. supplied: "m4a, oga"
  12. });
  13. });
  14. </script>
  15. <div id="jquery_jplayer_1"></div>
  16. <div id="jp_container_1">
  17. <a href="#" class="jp-play">Play</a>
  18. <a href="#" class="jp-pause">Pause</a>
  19. </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部件

  1. <link rel="stylesheet" href="css/jplayer.blue.monday.css" type="text/css" media="all" />
  2. <link rel="stylesheet" href="css/main.css" type="text/css" media="all" />
  3. <script src="js/jquery.min.js" type="text/javascript"></script>
  4. <script src="js/jquery.jplayer.min.js" type="text/javascript"></script>
  5. <script src="js/main.js" type="text/javascript"></script>
  6. <div class="example">
  7. <div>
  8. <div class="players">
  9. <h2>Audio player</h2>
  10. <div class="jp-audio">
  11. <div class="jp-type-single">
  12. <div id="jquery_jplayer_1" class="jp-jplayer"></div>
  13. <div id="jp_interface_1" class="jp-interface">
  14. <ul class="jp-controls">
  15. <li><a href="#" class="jp-play" tabindex="1">play</a></li>
  16. <li><a href="#" class="jp-pause" tabindex="1">pause</a></li>
  17. <li><a href="#" class="jp-stop" tabindex="1">stop</a></li>
  18. <li><a href="#" class="jp-mute" tabindex="1">mute</a></li>
  19. <li><a href="#" class="jp-unmute" tabindex="1">unmute</a></li>
  20. </ul>
  21. <div class="jp-progress">
  22. <div class="jp-seek-bar">
  23. <div class="jp-play-bar"></div>
  24. </div>
  25. </div>
  26. <div class="jp-volume-bar">
  27. <div class="jp-volume-bar-value"></div>
  28. </div>
  29. <div class="jp-current-time"></div>
  30. <div class="jp-duration"></div>
  31. </div>
  32. <div id="jp_playlist_1" class="jp-playlist">
  33. <ul>
  34. <li>Audio track</li>
  35. </ul>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="players">
  41. <h2>Video player</h2>
  42. <div class="jp-video jp-video-270p">
  43. <div class="jp-type-single">
  44. <div id="jquery_jplayer_2" class="jp-jplayer"></div>
  45. <div id="jp_interface_2" class="jp-interface">
  46. <div class="jp-video-play"></div>
  47. <ul class="jp-controls">
  48. <li><a href="#" class="jp-play" tabindex="1">play</a></li>
  49. <li><a href="#" class="jp-pause" tabindex="1">pause</a></li>
  50. <li><a href="#" class="jp-stop" tabindex="1">stop</a></li>
  51. <li><a href="#" class="jp-mute" tabindex="1">mute</a></li>
  52. <li><a href="#" class="jp-unmute" tabindex="1">unmute</a></li>
  53. </ul>
  54. <div class="jp-progress">
  55. <div class="jp-seek-bar">
  56. <div class="jp-play-bar"></div>
  57. </div>
  58. </div>
  59. <div class="jp-volume-bar">
  60. <div class="jp-volume-bar-value"></div>
  61. </div>
  62. <div class="jp-current-time"></div>
  63. <div class="jp-duration"></div>
  64. </div>
  65. <div id="jp_playlist_2" class="jp-playlist">
  66. <ul>
  67. <li>Tokyo weather</li>
  68. </ul>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>

在上同画出2播放器 - 音频和视频,它们两个的代码类似.

2. CSS

需要用到的CSS样式

  1. body{background:#eee;font-family:Verdana, Helvetica, Arial, sans-serif;margin:0;padding:0}
  2. .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}
  3. .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

  1. $(document).ready(function(){
  2. $("#jquery_jplayer_1").jPlayer({
  3. ready: function () {
  4. $(this).jPlayer("setMedia", {
  5. mp3: "media/track.mp3",
  6. }).jPlayer("play"); // auto play
  7. },
  8. ended: function (event) {
  9. $(this).jPlayer("play");
  10. },
  11. swfPath: "swf",
  12. supplied: "mp3"
  13. })
  14. .bind($.jPlayer.event.play, function() { // pause other instances of player when current one play
  15. $(this).jPlayer("pauseOthers");
  16. });
  17. $("#jquery_jplayer_2").jPlayer({
  18. ready: function () {
  19. $(this).jPlayer("setMedia", {
  20. m4v: "media/tokyo.m4v",
  21. ogv: "media/tokyo.ogv",
  22. poster: "media/poster.jpg"
  23. });
  24. },
  25. ended: function (event) {
  26. $("#jquery_jplayer_2").jPlayer("play", 0);
  27. },
  28. swfPath: "js",
  29. supplied: "m4v, ogv",
  30. cssSelectorAncestor: "#jp_interface_2"
  31. })
  32. .bind($.jPlayer.event.play, function() { // pause other instances of player when current one play
  33. $(this).jPlayer("pauseOthers");
  34. });
  35. });

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

在线DEMO例子

The jQuery HTML5 Audio / Video Library (jQuery jPlayer插件给你的站点增加视频和音频功能)的更多相关文章

  1. [jPlayer] HTML5 Audio & Video for jQuery

    ---------------------------------------------------------------------------------------------------- ...

  2. HTML5 Audio/Video 标签,属性,方法,事件汇总

    HTML5 Audio/Video 标签,属性,方法,事件汇总 (转) 2011-06-28 13:16:48   <audio> 标签属性:src:音乐的URLpreload:预加载au ...

  3. HTML5 Audio/Video 标签,属性,方法,事件汇总 (转)

    HTML5 Audio/Video 标签,属性,方法,事件   <audio> 标签属性:src:音乐的URLpreload:预加载autoplay:自动播放loop:循环播放contro ...

  4. [转帖]HTML5 Audio/Video 标签,属性,方法,事件汇总

    HTML5 Audio/Video 标签,属性,方法,事件汇总 <audio>标签属性: src:音乐的URL preload:预加载 autoplay:自动播放 loop:循环播放 co ...

  5. 基于HTML5 audio元素播放声音jQuery小插件

    by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=1609 一.前面的些唠 ...

  6. HTML5 Audio & Video 属性解析

    一.HTML 音频/视频 方法 play() play() 方法开始播放当前的音频或视频. var myVideo=document.getElementById("video1" ...

  7. [转载]HTML5 Audio/Video 标签,属性,方法,事件汇总

    <audio> 标签属性: src:音乐的URL preload:预加载 autoplay:自动播放 loop:循环播放 controls:浏览器自带的控制条 <audio id=& ...

  8. 【转载】HTML5 Audio/Video 标签,属性,方法,事件汇总

    <audio> 标签属性: src:音乐的URL preload:预加载 autoplay:自动播放 loop:循环播放 controls:浏览器自带的控制条 Html代码  <au ...

  9. html5 audio/video 的那些坑

    当我最近项目用到audio的时候,我们用到了jPlayer作为三方库. 功能实现了,暂停播放,进度条什么的,都很顺利的搞定了.后来考虑到当网速过慢时需要给播放按钮一个载入动画,然后就一发不可收拾了. ...

随机推荐

  1. hdu 1847 博弈基础题 SG函数 或者规律2种方法

    Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  2. C++ 模板的编译 以及 类模板内部的实例化

    在C++中.编译器在看到模板的定义的时候.并不马上产生代码,仅仅有在看到用到模板时,比方调用了模板函数 或者 定义了类模板的 对象的时候.编译器才产生特定类型的代码. 一般而言,在调用函数的时候,仅仅 ...

  3. java变量深入理解

    4,变量:其实就是内存中的一个存储空间,用于存储常量数据. 作用:方便于运算.因为有些数据不确定.所以确定该数据的名词和存储空间. 特点:变量空间可以重复使用. 什么时候定义变量?只要是数据不确定的时 ...

  4. [转]关于适配iphone5,Invalid Launch Image的退信

    关于适配iphone5,Invalid Launch Image的退信 本人xcode 4.3,所开发客户端新版本准备提交,应用中做了关于iphone5的适配,然后打包提交.在提交审核的时候被拒,收到 ...

  5. 使用 SVWebViewController 推出浏览器控制器

    SVWebViewController 简单翻译 https://github.com/samvermette/SVWebViewController SVWebViewController is a ...

  6. [Swift] Swift3.0--GCD

    reference to : http://www.jianshu.com/p/4c983388dca6 估计现在好多人在为这一块头疼,所以先来点干货. //最常用模板 //全局队列异步执行 Disp ...

  7. MySql_34道经典Sql试题

    MySql_34道经典Sql试题   版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/xiaouncle/article/details/799390 ...

  8. 【屌丝程序的口才逆袭演讲稿50篇】第十三篇:爱迪生欺骗了我们!【张振华.Jack】

    演讲稿主题:<爱迪生欺骗了我们>                      --作者:张振华Jack.摘抄<马云为雅虎员工的演讲稿:爱迪生欺骗了我们> 非常多人都记得爱迪生说的 ...

  9. 我所遭遇过的游戏中间件--Kynapse

    我所遭遇过的游戏中间件--Kynapse Autodesk Kynapse游戏中间件是一款面向游戏开发.非玩家控制角色实时模拟的领先的人工智能解决方案.Kynapse具有先进的路径查找功能,比如三维路 ...

  10. ubuntu 12.04 安装无线网卡驱动

    安装ubuntu 12.04后,无线网卡不可用,采用以下方式解决: 1.在终端中运行如下命令,重新安装b43相关的全部驱动和firmware: sudo apt-get install bcmwl-k ...