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作为三方库. 功能实现了,暂停播放,进度条什么的,都很顺利的搞定了.后来考虑到当网速过慢时需要给播放按钮一个载入动画,然后就一发不可收拾了. ...
随机推荐
- ASP.NET MVC的请求处理流程
(1)用户打开浏览器,在地址栏输入某个网址URL并回车,浏览器便开始向该URL指向的服务器发送HTTP请求(一般是GET方式).(2)服务器端的网站服务系统(IIS)接收到该请求,先检查自己是否认识该 ...
- mac下git+maven+jenkins自动打包发布
随着springboot+springcloud(dubbo)越来越多人使用,流行的微服务的概念越来越深入人心.分布式部署越来越复杂,给手动发布带来很大工作量.为了方便前期测试和后期线上部署更新,可使 ...
- mongodb exception in initAndListen: 12596 old lock file, terminating解决方法
错误信息如下: exception old lock file, terminating 解决方法 .删除data目录中的.lock文件 .mongod.exe --repair .启动mongod就 ...
- The YubiKey NEO -- Smartcard features
Smartcard features on the YubiKey NEO YubiKeys are a line of small and low-cost hardware security to ...
- Tasker to answer incoming call by pressing power button
nowadays, the smartphone is getting bigger in size, eg. samsung galaxy note and note 2, sorta big in ...
- Java工程师成神之路 转
一.基础篇 1.1 JVM 1.1.1. Java内存模型,Java内存管理,Java堆和栈,垃圾回收 http://www.jcp.org/en/jsr/detail?id=133 http:/ ...
- ASP.NET web.config中<customErrors>节点说明
customErrors>节点用于定义一些自定义错误信息的信息.此节点有Mode和defaultRedirect两个属性,其中defaultRedirect属性是一个可选属性,表示应用程序发生错 ...
- CSS之BFC、IFC、FFC and GFC
CSS之BFC.IFC.FFC and GFC 什么是FC? BFC(Block Formatting Contexts) BFC的布局规则: 如何生成BFC: IFC(Inline Formatti ...
- Android Activity的四种LaunchMode!!!
本文转自: http://marshal.easymorse.com/archives/2950. 写的非常好,分享给大家!!! 在多Activity开发中,有可能是自己应用之间的Activity跳转 ...
- 26个Jquery1.4使用小技巧
1. 禁止右键点击 1. $(document).ready(function(){ 2. $(document).bind("contextmenu&quo ...