jQuery Media Plugin is a web media player plug-in based on jQuery. It supports most online multimedia players and multimedia formats, such as: Flash, Windows Media Player, Real Player, Quicktime, MP3, Silverlight, PDF. It automatically replaces the a tag with a div based on the current script configuration, and generates object, embed or even iframe code. As for whether to generate object or embed, jQuery Media will automatically determine based on the current platform, so the compatibility is excellent. The following code is the result generated by jQuery Media:
Specific usage
html markup code
Parameters can be configured through script objects or jQuery Metadata Plugin.
Global default:
We can also pass in some option parameters when executing the initialization script, as shown in the following code:
Another example is the code:
'src' option
Thesrc option specifies the address of the media file. It has no global default value. If the value of the specified src option is not shown, jQuery Media Plugin will use the value of the href or src attribute instead.
Players and formats
jQuery Media Plugin defaults to the player and format as shown in the following table:
Player |
File format |
Quicktime |
aif,aiff,aac,au,bmp,gsm,mov,mid, midi,mpg,mpeg,mp4,m4a,psd,qt,qtif, qif,qti,snd,tif,tiff,wav, 3g2,3pg |
Flash |
flv, mp3, swf |
Windows Media Player |
asx, asf, avi, wma, wmv |
Real Player |
ra, ram, rm, rpm, rv, smi, smil |
Silverlight |
xaml |
iframe |
html, pdf |
The above table shows that the mp3 format is automatically mapped to the flash player. $.fn.media.defaults.mp3Player in the global configuration specifies that MP3 media is played by the mediaplayer.swf file. The swf file is a small mp3 and flash video player, which can be downloaded from here: http://www.longtailvideo.com/players/jw-flv-player/
SWFObject
This script is very common and is used to embed Flash content into web pages. You don’t need to consider the Flash embedding methods of different platforms. But this file is not required. If it is loaded, jQuery Media Plugin will use it, otherwise jQuery Media Plugin will generate object/embed tags in its own default way. For more information, please refer to: http://code.google.com/p/swfobject/
iframe Player
By default, PDF and HTML formats are mapped to iframes. They will be displayed in an iframe rather than an object/embed tag.
Add or modify format association
This operation can be implemented by the mapFormat method of the plug-in, such as
$.fn.media.mapFormat('mp3','quicktime');
Available players are: uicktime, flash, realplayer, winmedia, silverlight and iframe. Make sure the player can play the file format associated with it.
Download
Download the jquery.media.js file directly, or download the historical version on Github
Note:
This plug-in will convert into