Home > Web Front-end > JS Tutorial > body text

Detailed explanation of jQuery multimedia plug-in jQuery Media Plugin_jquery

WBOY
Release: 2016-05-16 16:25:32
Original
3504 people have browsed it

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:

Copy code The code is as follows:


         codebase="http://www.apple.com/qtactivex/qtplugin.cab"
classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B">
            
            
          
                         attr1="attrValue1" attr2="attrValue2" param1="paramValue1" param2="paramValue2"
pluginspage="
http://www.apple.com/quicktime/download/" >



Specific usage

html markup code

Copy code The code is as follows:
Initialization script:

Copy code The code is as follows:
$('.media').media();

Options

Parameters can be configured through script objects or jQuery Metadata Plugin.

Global default:

Copy code The code is as follows:
$.fn.media.defaults = {
preferMeta: 1, // If true, the tag's meta value takes precedence over the script object
autoplay: 0, // Standardized cross-player settings
bgColor: '#ffffff', // background color
params: {}, // Add to object tag as param element; add to embed tag as attribute
attrs: {}, // Add to object and embed as attributes
flashvars: {}, // Add to flash as flashvars parameter or attribute
flashVersion: '7', // Minimum flash version required
// Default flash video and mp3 player // @see:
http://jeroenwijering.com/?item=Flash_Media_Player flvPlayer: 'mediaplayer.swf',
mp3Player: 'mediaplayer.swf',
// Silverlight options // @see
http://msdn2.microsoft.com/en-us/library/bb412401.aspx silverlight: {
inplaceInstallPrompt: 'true', // Display the installation prompt at the appropriate location
isWindowless: 'true', // Windowless mode
framerate: '24', // Maximum frame rate
version: '0.9', // Silverlight version onError: null, // onError callback function
onLoad: null, // onLoad callback function
initParams: null, // Object initialization parameters
userContext: null // Parameters passed to the load callback function
}
};

We can also pass in some option parameters when executing the initialization script, as shown in the following code:

Copy code The code is as follows:

$('.media').media( { width: 400, height: 300, autoplay: true } );

Another example is the code:

Copy code The code is as follows:

$('.media').media({
width: 450,
height: 250,
autoplay: true,
src: 'myBetterMovie.mov',
attrs: { attr1: 'attrValue1', attr2: 'attrValue2' }, // object/embed attrs
params: { param1: 'paramValue1', param2: 'paramValue2' }, // object params/embed attrs
caption: false // supress caption text
});

'src' option

The

src 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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template