📜 ⬆️ ⬇️

jPlayer - plugin for playing audio and video

image I already wrote about the script audio.js , which allows you to play audio files using the capabilities of html5 and flash. The post was well received, so now I want to tell you about jPlayer - jQuery plugin for playing audio and video.

Format support:


Supports the following browsers:

Powered by jQuery 1.3.2+

Some code examples.
')
Connect to page:
<head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"> </script> <script type="text/javascript" src="js/jquery.jplayer.min.js"> </script> <script> $(document).ready(function() { /*   */ }); </script> </head> <body> <div id="jpId"></div> </body> 

Play mp3:
 $(document).ready(function() { $("#jpId").jPlayer( { ready: function () { $(this).jPlayer("setMedia", { mp3: "../mp3/elvis.mp3" }); } }); }); 

Variety of formats:
 $(document).ready(function() { $("#jpId").jPlayer( { ready: function () { $(this).jPlayer("setMedia", { m4a: "mp3/elvis.m4a", oga: "ogg/elvis.ogg" }); }, supplied: "m4a, oga", swfPath: "/jPlayer/js" }); }); 

Now the video:
 $(function() { $("#jpId").jPlayer( { ready: function () { $(this).jPlayer("setMedia", { m4v: "http://www.myDomain.com/myVideo.m4v" }).jPlayer("play"); }, supplied: "m4v", swfPath: "jPlayer/js" }); }); 

An example with different video formats:
 $(function() { // executed when $(document).ready() $("#jpId").jPlayer( { ready: function () { $(this).jPlayer("setMedia", { m4v: "/media/myVideo.m4v", ogv: "/media/myVideo.ogv" }).jPlayer("play"); //   }, solution: "flash, html", supplied: "m4v, ogv", swfPath: "/scripts" }); }); 

But never write like this:
 $(document).ready(function() { $("#jpId").jPlayer( { ready: function () { $(this).jPlayer("setMedia", { mp3: "elvis.mp3" }); } }); $("#jpId").jPlayer("play"); //        }); 

A demo can be found here .

Source: https://habr.com/ru/post/112776/


All Articles