|
JCE MediaBox includes support for popular video websites such as Youtube, Daily Motion, Vimeo, Google Video and Metacafe and support for additional sites and media types can be added by creating a simple add-on script.
A sample script for TwtiPic and TwitVid is included in the package, in plugins/system/jcemediabox/addons/twitter.js
An add-on script is a call to a JCE MediaBox function which adds a simple identification function for the media type and site url to JCE MediaBox.The identification function is used to determine whether the url in the popup href is supported, and to return a modified url if necessary and list of parameters for the popup.
An identification script is added using the JCEMediaBox.Popup.setAddons function, with 2 required variables, media type and an object containing 1 or more identification functions. At the moment, 3 types are supported, flash, image and html.
Example:
JCEMediaBox.Popup.setAddons('flash', {
/**
* Twitvid - http://www.twitvid.com
* @param {String} v URL
*/
twitvid: function(v) {
if (/twitvid(.+)\/(.+)/.test(v)) {
var s = 'http://www.twitvid.com/player/';
return {
width: 425,
height: 344,
type: 'flash',
'allowFullScreen' : true,
'allowscriptaccess' : 'always',
'allowNetworking' : 'all',
'wmode': 'transparent',
'src': v.replace(/(.+)twitvid([^\/]+)\/(.+)/, function(a, b, c, d){
return s + d;
})
};
}
}
});
The first variable is the media type, in this case flash, and the second is an object containg the twitvid function. When executed, this function is passed the popup link href to test, and is required to return an object containing a width, height, type and src value. Other included values will be used as attributes of the object element.
Once a script is created, save it with a simple name, such as twitter.js, and place it in the plugins/system/jcemediabox/addons/ folder.
|