')
.parent()
.css({
position:'fixed',
// top:'0px',
width:'1px',
height:'1px',
display:'inline-block',
background:'transparent',
'z-index':99999
})
// Hands over mouse events to original input for css styles
.on('mouseover mouseout mousedown mouseup', function(evt) {
if(currentTarget){
$('#' + currentTarget).trigger(evt.type);
}
})
.appendTo('body');
swfobject.embedSWF(o.filereader, o.id, '100%', '100%', '10', o.expressInstall, {debugMode: o.debugMode ? true : ''}, {'wmode':'transparent','allowScriptAccess':'sameDomain'}, {}, function(e) {
self.swfObject = e.ref;
$(self.swfObject)
.css({
display: 'block',
outline: 0
})
.attr('tabindex', 0);
self.ready = e.success && typeof e.ref.add === "function";
if (self.ready) {
readyCallbacks.fire();
}
});
}
},
swfObject: null,
container: null,
// Inputs Registry
inputs: {},
// Readers Registry
readers: {},
// Receives FileInput events
onFileInputEvent: function(evt) {
if (this.debugMode) console.info('FileInput Event ', evt.type, evt);
if (evt.target in this.inputs) {
var el = this.inputs[evt.target];
evt.target = el[0];
if( evt.type === 'change') {
webshims.data(evt.target, 'fileList', new FileList(evt.files));
}
el.trigger(evt);
}
window.focus();
},
// Receives FileReader ProgressEvents
onFileReaderEvent: function(evt) {
if (this.debugMode) console.info('FileReader Event ', evt.type, evt, evt.target in this.readers);
if (evt.target in this.readers) {
var reader = this.readers[evt.target];
evt.target = reader;
reader._handleFlashEvent.call(reader, evt);
}
},
// Receives flash FileReader Error Events
onFileReaderError: function(error) {
if (this.debugMode) console.log(error);
},
onSWFReady: function() {
this.container.css({position: 'absolute'});
this.ready = typeof this.swfObject.add === "function";
if (this.ready) {
readyCallbacks.fire();
}
return true;
}
};
/**
* Add FileReader to the window object
*/
window.FileReader = function () {
// states
this.EMPTY = 0;
this.LOADING = 1;
this.DONE = 2;
this.readyState = 0;
// File or Blob data
this.result = null;
this.error = null;
// event handler attributes
this.onloadstart = null;
this.onprogress = null;
this.onload = null;
this.onabort = null;
this.onerror = null;
this.onloadend = null;
// Event Listeners handling using JQuery Callbacks
this._callbacks = {
loadstart : $.Callbacks( "unique" ),
progress : $.Callbacks( "unique" ),
abort : $.Callbacks( "unique" ),
error : $.Callbacks( "unique" ),
load : $.Callbacks( "unique" ),
loadend : $.Callbacks( "unique" )
};
// Custom properties
this._id = null;
};
window.FileReader.prototype = {
// async read methods
readAsBinaryString: function (file) {
this._start(file);
FileAPIProxy.swfObject.read(file.input, file.name, 'readAsBinaryString');
},
readAsText: function (file, encoding) {
this._start(file);
FileAPIProxy.swfObject.read(file.input, file.name, 'readAsText');
},
readAsDataURL: function (file) {
this._start(file);
FileAPIProxy.swfObject.read(file.input, file.name, 'readAsDataURL');
},
readAsArrayBuffer: function(file){
throw("Whoops FileReader.readAsArrayBuffer is unimplemented");
},
abort: function () {
this.result = null;
if (this.readyState === this.EMPTY || this.readyState === this.DONE) return;
FileAPIProxy.swfObject.abort(this._id);
},
// Event Target interface
addEventListener: function (type, listener) {
if (type in this._callbacks) this._callbacks[type].add(listener);
},
removeEventListener: function (type, listener) {
if (type in this._callbacks) this._callbacks[type].remove(listener);
},
dispatchEvent: function (event) {
event.target = this;
if (event.type in this._callbacks) {
var fn = this['on' + event.type];
if ($.isFunction(fn)) fn(event);
this._callbacks[event.type].fire(event);
}
return true;
},
// Custom private methods
// Registers FileReader instance for flash callbacks
_register: function(file) {
this._id = file.input + '.' + file.name;
FileAPIProxy.readers[this._id] = this;
},
_start: function(file) {
this._register(file);
if (this.readyState === this.LOADING) throw {type: 'InvalidStateError', code: 11, message: 'The object is in an invalid state.'};
},
_handleFlashEvent: function(evt) {
switch (evt.type) {
case 'loadstart':
this.readyState = this.LOADING;
break;
case 'loadend':
this.readyState = this.DONE;
break;
case 'load':
this.readyState = this.DONE;
this.result = FileAPIProxy.swfObject.result(this._id);
break;
case 'error':
this.result = null;
this.error = {
name: 'NotReadableError',
message: 'The File cannot be read!'
};
}
this.dispatchEvent(new FileReaderEvent(evt));
}
};
/**
* FileReader ProgressEvent implenting Event interface
*/
window.FileReaderEvent = function (e) {
this.initEvent(e);
};
window.FileReaderEvent.prototype = {
initEvent: function (event) {
$.extend(this, {
type: null,
target: null,
currentTarget: null,
eventPhase: 2,
bubbles: false,
cancelable: false,
defaultPrevented: false,
isTrusted: false,
timeStamp: new Date().getTime()
}, event);
},
stopPropagation: function (){
},
stopImmediatePropagation: function (){
},
preventDefault: function (){
}
};
/**
* FileList interface (Object with item function)
*/
window.FileList = function(array) {
if (array) {
for (var i = 0; i < array.length; i++) {
this[i] = array[i];
}
this.length = array.length;
} else {
this.length = 0;
}
};
window.FileList.prototype = {
item: function(index) {
return (index in this) ? this[index] : null;
}
};
})();
webshims.defineNodeNameProperty('input', 'files', {
prop: {
writeable: false,
get: function(){
if(this.type != 'file'){return null;}
if(!$(this).is('.ws-filereader')){
webshims.error("please add the 'ws-filereader' class to your input[type='file'] to implement files-property");
}
return webshims.data(this, 'fileList') || webshims.data(this, 'fileList', new FileList());
}
}
}
);
webshims.defineNodeNamesBooleanProperty('input', 'multiple');
//webshims
$.fn.fileReader.defaults.filereader = webshims.cfg.basePath +'swf/filereader.swf';
var wait = ['DOM'];
if(webshims.modules["form-core"].loaded){
wait.push('forms');
}
webshims.ready(wait, function(){
webshims.addReady(function(context, contextElem){
$('input[type="file"].ws-filereader', context).fileReader();
});
});
});
(function(Modernizr, webshims){
"use strict";
var $ = webshims.$;
var hasNative = Modernizr.audio && Modernizr.video;
var supportsLoop = false;
var bugs = webshims.bugs;
var swfType = 'mediaelement-jaris';
var loadSwf = function(){
webshims.ready(swfType, function(){
if(!webshims.mediaelement.createSWF){
webshims.mediaelement.loadSwf = true;
webshims.reTest([swfType], hasNative);
}
});
};
var wsCfg = webshims.cfg;
var options = wsCfg.mediaelement;
var hasFullTrackSupport;
var hasSwf;
if(!options){
webshims.error("mediaelement wasn't implemented but loaded");
return;
}
if(hasNative){
var videoElem = document.createElement('video');
Modernizr.videoBuffered = ('buffered' in videoElem);
supportsLoop = ('loop' in videoElem);
webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
if(!Modernizr.videoBuffered ){
webshims.addPolyfill('mediaelement-native-fix', {
d: ['dom-support']
});
webshims.loader.loadList(['mediaelement-native-fix']);
}
if(!options.preferFlash){
var noSwitch = {
1: 1,
2: 1
};
var switchOptions = function(e){
var media, error, parent;
if(!options.preferFlash &&
($(e.target).is('audio, video') || ((parent = e.target.parentNode) && $('source:last', parent)[0] == e.target)) &&
(media = $(e.target).closest('audio, video')) && !noSwitch[(error = media.prop('error'))]
){
if(error == null){
webshims.warn("There was an unspecified error on a mediaelement");
return;
}
$(function(){
if(hasSwf && !options.preferFlash){
loadSwf();
webshims.ready('WINDOWLOAD '+swfType, function(){
setTimeout(function(){
if(!options.preferFlash && webshims.mediaelement.createSWF && !media.is('.nonnative-api-active')){
options.preferFlash = true;
document.removeEventListener('error', switchOptions, true);
$('audio, video').each(function(){
webshims.mediaelement.selectSource(this);
});
webshims.error("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src+" Mediaerror: "+ media.prop('error'));
}
}, 9);
});
} else{
document.removeEventListener('error', switchOptions, true);
}
});
}
};
document.addEventListener('error', switchOptions, true);
$('audio, video').each(function(){
var error = $.prop(this, 'error');
if(error && !noSwitch[error]){
switchOptions({target: this});
return false;
}
});
}
}
if(Modernizr.track && !bugs.track){
(function(){
if(!bugs.track){
bugs.track = typeof $('
')[0].readyState != 'number';
}
if(!bugs.track){
try {
new TextTrackCue(2, 3, '');
} catch(e){
bugs.track = true;
}
}
})();
}
hasFullTrackSupport = Modernizr.track && !bugs.track;
webshims.register('mediaelement-core', function($, webshims, window, document, undefined, options){
hasSwf = swfmini.hasFlashPlayerVersion('9.0.115');
$('html').addClass(hasSwf ? 'swf' : 'no-swf');
var mediaelement = webshims.mediaelement;
mediaelement.parseRtmp = function(data){
var src = data.src.split('://');
var paths = src[1].split('/');
var i, len, found;
data.server = src[0]+'://'+paths[0]+'/';
data.streamId = [];
for(i = 1, len = paths.length; i < len; i++){
if(!found && paths[i].indexOf(':') !== -1){
paths[i] = paths[i].split(':')[1];
found = true;
}
if(!found){
data.server += paths[i]+'/';
} else {
data.streamId.push(paths[i]);
}
}
if(!data.streamId.length){
webshims.error('Could not parse rtmp url');
}
data.streamId = data.streamId.join('/');
};
var getSrcObj = function(elem, nodeName){
elem = $(elem);
var src = {src: elem.attr('src') || '', elem: elem, srcProp: elem.prop('src')};
var tmp;
if(!src.src){return src;}
tmp = elem.attr('data-server');
if(tmp != null){
src.server = tmp;
}
tmp = elem.attr('type');
if(tmp){
src.type = tmp;
src.container = $.trim(tmp.split(';')[0]);
} else {
if(!nodeName){
nodeName = elem[0].nodeName.toLowerCase();
if(nodeName == 'source'){
nodeName = (elem.closest('video, audio')[0] || {nodeName: 'video'}).nodeName.toLowerCase();
}
}
if(src.server){
src.type = nodeName+'/rtmp';
src.container = nodeName+'/rtmp';
} else {
tmp = mediaelement.getTypeForSrc( src.src, nodeName, src );
if(tmp){
src.type = tmp;
src.container = tmp;
}
}
}
tmp = elem.attr('media');
if(tmp){
src.media = tmp;
}
if(src.type == 'audio/rtmp' || src.type == 'video/rtmp'){
if(src.server){
src.streamId = src.src;
} else {
mediaelement.parseRtmp(src);
}
}
return src;
};
var hasYt = !hasSwf && ('postMessage' in window) && hasNative;
var loadTrackUi = function(){
if(loadTrackUi.loaded){return;}
loadTrackUi.loaded = true;
if(!options.noAutoTrack){
webshims.ready('WINDOWLOAD', function(){
loadThird();
webshims.loader.loadList(['track-ui']);
});
}
};
// var loadMediaGroup = function(){
// if(!loadMediaGroup.loaded){
// loadMediaGroup.loaded = true;
// webshims.ready(window.MediaController ? 'WINDOWLOAD' : 'DOM', function(){
// webshims.loader.loadList(['mediagroup']);
// });
// }
// };
var loadYt = (function(){
var loaded;
return function(){
if(loaded || !hasYt){return;}
loaded = true;
webshims.loader.loadScript("https://www.youtube.com/player_api");
$(function(){
webshims._polyfill(["mediaelement-yt"]);
});
};
})();
var loadThird = function(){
if(hasSwf){
loadSwf();
} else {
loadYt();
}
};
webshims.addPolyfill('mediaelement-yt', {
test: !hasYt,
d: ['dom-support']
});
// webshims.addModule('mediagroup', {
// d: ['mediaelement', 'dom-support']
// });
mediaelement.mimeTypes = {
audio: {
//ogm shouldn´t be used!
'audio/ogg': ['ogg','oga', 'ogm'],
'audio/ogg;codecs="opus"': 'opus',
'audio/mpeg': ['mp2','mp3','mpga','mpega'],
'audio/mp4': ['mp4','mpg4', 'm4r', 'm4a', 'm4p', 'm4b', 'aac'],
'audio/wav': ['wav'],
'audio/3gpp': ['3gp','3gpp'],
'audio/webm': ['webm'],
'audio/fla': ['flv', 'f4a', 'fla'],
'application/x-mpegURL': ['m3u8', 'm3u']
},
video: {
//ogm shouldn´t be used!
'video/ogg': ['ogg','ogv', 'ogm'],
'video/mpeg': ['mpg','mpeg','mpe'],
'video/mp4': ['mp4','mpg4', 'm4v'],
'video/quicktime': ['mov','qt'],
'video/x-msvideo': ['avi'],
'video/x-ms-asf': ['asf', 'asx'],
'video/flv': ['flv', 'f4v'],
'video/3gpp': ['3gp','3gpp'],
'video/webm': ['webm'],
'application/x-mpegURL': ['m3u8', 'm3u'],
'video/MP2T': ['ts']
}
}
;
mediaelement.mimeTypes.source = $.extend({}, mediaelement.mimeTypes.audio, mediaelement.mimeTypes.video);
mediaelement.getTypeForSrc = function(src, nodeName, data){
if(src.indexOf('youtube.com/watch?') != -1 || src.indexOf('youtube.com/v/') != -1){
return 'video/youtube';
}
if(src.indexOf('rtmp') === 0){
return nodeName+'/rtmp';
}
src = src.split('?')[0].split('.');
src = src[src.length - 1];
var mt;
$.each(mediaelement.mimeTypes[nodeName], function(mimeType, exts){
if(exts.indexOf(src) !== -1){
mt = mimeType;
return false;
}
});
return mt;
};
mediaelement.srces = function(mediaElem, srces){
mediaElem = $(mediaElem);
if(!srces){
srces = [];
var nodeName = mediaElem[0].nodeName.toLowerCase();
var src = getSrcObj(mediaElem, nodeName);
if(!src.src){
$('source', mediaElem).each(function(){
src = getSrcObj(this, nodeName);
if(src.src){srces.push(src);}
});
} else {
srces.push(src);
}
return srces;
} else {
mediaElem.removeAttr('src').removeAttr('type').find('source').remove();
if(!$.isArray(srces)){
srces = [srces];
}
srces.forEach(function(src){
if(typeof src == 'string'){
src = {src: src};
}
mediaElem.append($(document.createElement('source')).attr(src));
});
}
};
$.fn.loadMediaSrc = function(srces, poster){
return this.each(function(){
if(poster !== undefined){
$(this).removeAttr('poster');
if(poster){
$.attr(this, 'poster', poster);
}
}
mediaelement.srces(this, srces);
$(this).mediaLoad();
});
};
mediaelement.swfMimeTypes = ['video/3gpp', 'video/x-msvideo', 'video/quicktime', 'video/x-m4v', 'video/mp4', 'video/m4p', 'video/x-flv', 'video/flv', 'audio/mpeg', 'audio/aac', 'audio/mp4', 'audio/x-m4a', 'audio/m4a', 'audio/mp3', 'audio/x-fla', 'audio/fla', 'youtube/flv', 'video/jarisplayer', 'jarisplayer/jarisplayer', 'video/youtube', 'video/rtmp', 'audio/rtmp'];
mediaelement.canThirdPlaySrces = function(mediaElem, srces){
var ret = '';
if(hasSwf || hasYt){
mediaElem = $(mediaElem);
srces = srces || mediaelement.srces(mediaElem);
$.each(srces, function(i, src){
if(src.container && src.src && ((hasSwf && mediaelement.swfMimeTypes.indexOf(src.container) != -1) || (hasYt && src.container == 'video/youtube'))){
ret = src;
return false;
}
});
}
return ret;
};
var nativeCanPlayType = {};
mediaelement.canNativePlaySrces = function(mediaElem, srces){
var ret = '';
if(hasNative){
mediaElem = $(mediaElem);
var nodeName = (mediaElem[0].nodeName || '').toLowerCase();
var nativeCanPlay = (nativeCanPlayType[nodeName] || {prop: {_supvalue: false}}).prop._supvalue || mediaElem[0].canPlayType;
if(!nativeCanPlay){return ret;}
srces = srces || mediaelement.srces(mediaElem);
$.each(srces, function(i, src){
if(src.type && nativeCanPlay.call(mediaElem[0], src.type) ){
ret = src;
return false;
}
});
}
return ret;
};
var emptyType = (/^\s*application\/octet\-stream\s*$/i);
var getRemoveEmptyType = function(){
var ret = emptyType.test($.attr(this, 'type') || '');
if(ret){
$(this).removeAttr('type');
}
return ret;
};
mediaelement.setError = function(elem, message){
if($('source', elem).filter(getRemoveEmptyType).length){
webshims.error('"application/octet-stream" is a useless mimetype for audio/video. Please change this attribute.');
try {
$(elem).mediaLoad();
} catch(er){}
} else {
if(!message){
message = "can't play sources";
}
$(elem).pause().data('mediaerror', message);
webshims.error('mediaelementError: '+ message);
setTimeout(function(){
if($(elem).data('mediaerror')){
$(elem).trigger('mediaerror');
}
}, 1);
}
};
var handleThird = (function(){
var requested;
return function( mediaElem, ret, data ){
webshims.ready(hasSwf ? swfType : 'mediaelement-yt', function(){
if(mediaelement.createSWF){
mediaelement.createSWF( mediaElem, ret, data );
} else if(!requested) {
requested = true;
loadThird();
//readd to ready
handleThird( mediaElem, ret, data );
}
});
if(!requested && hasYt && !mediaelement.createSWF){
loadYt();
}
};
})();
var stepSources = function(elem, data, useSwf, _srces, _noLoop){
var ret;
if(useSwf || (useSwf !== false && data && data.isActive == 'third')){
ret = mediaelement.canThirdPlaySrces(elem, _srces);
if(!ret){
if(_noLoop){
mediaelement.setError(elem, false);
} else {
stepSources(elem, data, false, _srces, true);
}
} else {
handleThird(elem, ret, data);
}
} else {
ret = mediaelement.canNativePlaySrces(elem, _srces);
if(!ret){
if(_noLoop){
mediaelement.setError(elem, false);
if(data && data.isActive == 'third') {
mediaelement.setActive(elem, 'html5', data);
}
} else {
stepSources(elem, data, true, _srces, true);
}
} else if(data && data.isActive == 'third') {
mediaelement.setActive(elem, 'html5', data);
}
}
};
var stopParent = /^(?:embed|object|datalist)$/i;
var selectSource = function(elem, data){
var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
var _srces = mediaelement.srces(elem);
var parent = elem.parentNode;
clearTimeout(baseData.loadTimer);
$.data(elem, 'mediaerror', false);
if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;}
data = data || webshims.data(elem, 'mediaelement');
if(mediaelement.sortMedia){
_srces.sort(mediaelement.sortMedia);
}
stepSources(elem, data, options.preferFlash || undefined, _srces);
};
mediaelement.selectSource = selectSource;
$(document).on('ended', function(e){
var data = webshims.data(e.target, 'mediaelement');
if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;}
setTimeout(function(){
if( $.prop(e.target, 'paused') || !$.prop(e.target, 'loop') ){return;}
$(e.target).prop('currentTime', 0).play();
}, 1);
});
var handleMedia = false;
var initMediaElements = function(){
var testFixMedia = function(){
if(webshims.implement(this, 'mediaelement')){
selectSource(this);
//fixes for FF 12 and IE9/10 || does not hurt, if run in other browsers
if(hasNative && (!supportsLoop || ('ActiveXObject' in window))){
var bufferTimer;
var lastBuffered;
var elem = this;
var getBufferedString = function(){
var buffered = $.prop(elem, 'buffered');
if(!buffered){return;}
var bufferString = "";
for(var i = 0, len = buffered.length; i < len;i++){
bufferString += buffered.end(i);
}
return bufferString;
};
var testBuffer = function(){
var buffered = getBufferedString();
if(buffered != lastBuffered){
lastBuffered = buffered;
webshims.info('needed to trigger progress manually');
$(elem).triggerHandler('progress');
}
};
$(this)
.on({
'play loadstart progress': function(e){
if(e.type == 'progress'){
lastBuffered = getBufferedString();
}
clearTimeout(bufferTimer);
bufferTimer = setTimeout(testBuffer, 400);
},
'emptied stalled mediaerror abort suspend': function(e){
if(e.type == 'emptied'){
lastBuffered = false;
}
clearTimeout(bufferTimer);
}
})
;
if('ActiveXObject' in window && $.prop(this, 'paused') && !$.prop(this, 'readyState') && $(this).is('audio[preload="none"][controls]:not([autoplay],.nonnative-api-active)')){
$(this).prop('preload', 'metadata').mediaLoad();
}
}
}
};
webshims.ready('dom-support', function(){
handleMedia = true;
if(!supportsLoop){
webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
}
['audio', 'video'].forEach(function(nodeName){
var supLoad, supController;
supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
prop: {
value: function(){
var data = webshims.data(this, 'mediaelement');
selectSource(this, data);
if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
supLoad.prop._supvalue.apply(this, arguments);
}
}
}
});
nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
prop: {
value: function(type){
var ret = '';
if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
if(ret == 'no'){
ret = '';
}
}
if(!ret && hasSwf){
type = $.trim((type || '').split(';')[0]);
if(mediaelement.swfMimeTypes.indexOf(type) != -1){
ret = 'maybe';
}
}
return ret;
}
}
});
// supController = webshims.defineNodeNameProperty(nodeName, 'controller', {
// prop: {
// get: function(type){
// if(!loadMediaGroup.loaded){
// loadMediaGroup();
// }
// if(mediaelement.controller){
// return mediaelement.controller[nodeName].get.apply(this, arguments);
// }
// return supController.prop._supget && supController.prop._supget.apply(this, arguments);
// },
// set: function(){
// var that = this;
// var args = arguments;
// if(!loadMediaGroup.loaded){
// loadMediaGroup();
// }
// if(mediaelement.controller){
// return mediaelement.controller[nodeName].set.apply(that, args);
// } else {
// webshims.ready('mediagroup', function(){
// mediaelement.controller[nodeName].set.apply(that, args);
// });
// }
// return supController.prop._supset && supController.prop._supset.apply(this, arguments);
// }
// }
// });
// webshims.ready('mediagroup', function(){
// mediaelement.controller[nodeName].sup = supController;
// });
});
// webshims.onNodeNamesPropertyModify(['audio', 'video'], ['mediaGroup'], {
// set: function(){
// var that = this;
// var args = arguments;
// if(!loadMediaGroup.loaded){
// loadMediaGroup();
// }
// if(mediaelement.mediagroup){
// mediaelement.mediagroup.set.apply(that, args);
// } else {
// webshims.ready('mediagroup', function(){
// mediaelement.mediagroup.set.apply(that, args);
// });
// }
// },
// initAttr: true
// });
webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
set: function(){
var elem = this;
var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
clearTimeout(baseData.loadTimer);
baseData.loadTimer = setTimeout(function(){
selectSource(elem);
elem = null;
}, 9);
}
});
webshims.addReady(function(context, insertedElement){
var media = $('video, audio', context)
.add(insertedElement.filter('video, audio'))
.each(testFixMedia)
;
if(!loadTrackUi.loaded && $('track', media).length){
loadTrackUi();
}
// if(!loadMediaGroup.loaded && this.getAttribute('mediagroup')){
// loadMediaGroup();
// }
media = null;
});
});
if(hasNative && !handleMedia){
webshims.addReady(function(context, insertedElement){
if(!handleMedia){
$('video, audio', context)
.add(insertedElement.filter('video, audio'))
.each(function(){
if(!mediaelement.canNativePlaySrces(this)){
loadThird();
handleMedia = true;
return false;
}
})
;
}
});
}
};
if(hasFullTrackSupport){
webshims.defineProperty(TextTrack.prototype, 'shimActiveCues', {
get: function(){
return this._shimActiveCues || this.activeCues;
}
});
}
//set native implementation ready, before swf api is retested
if(hasNative){
webshims.isReady('mediaelement-core', true);
initMediaElements();
webshims.ready('WINDOWLOAD mediaelement', loadThird);
} else {
webshims.ready(swfType, initMediaElements);
}
webshims.ready('track', loadTrackUi);
});
})(Modernizr, webshims);
webshims.register('mediaelement-jaris', function($, webshims, window, document, undefined, options){
"use strict";
var mediaelement = webshims.mediaelement;
var swfmini = window.swfmini;
var hasNative = Modernizr.audio && Modernizr.video;
var hasFlash = swfmini.hasFlashPlayerVersion('9.0.115');
var loadedSwf = 0;
var needsLoadPreload = 'ActiveXObject' in window && hasNative;
var getProps = {
paused: true,
ended: false,
currentSrc: '',
duration: window.NaN,
readyState: 0,
networkState: 0,
videoHeight: 0,
videoWidth: 0,
error: null,
buffered: {
start: function(index){
if(index){
webshims.error('buffered index size error');
return;
}
return 0;
},
end: function(index){
if(index){
webshims.error('buffered index size error');
return;
}
return 0;
},
length: 0
}
};
var getPropKeys = Object.keys(getProps);
var getSetProps = {
currentTime: 0,
volume: 1,
muted: false
};
var getSetPropKeys = Object.keys(getSetProps);
var playerStateObj = $.extend({
isActive: 'html5',
activating: 'html5',
wasSwfReady: false,
_bufferedEnd: 0,
_bufferedStart: 0,
currentTime: 0,
_ppFlag: undefined,
_calledMeta: false,
lastDuration: 0
}, getProps, getSetProps);
var idRep = /^jarisplayer-/;
var getSwfDataFromID = function(id){
var elem = document.getElementById(id.replace(idRep, ''));
if(!elem){return;}
var data = webshims.data(elem, 'mediaelement');
return data.isActive == 'third' ? data : null;
};
var getSwfDataFromElem = function(elem){
try {
(elem.nodeName);
} catch(er){
return null;
}
var data = webshims.data(elem, 'mediaelement');
return (data && data.isActive== 'third') ? data : null;
};
var trigger = function(elem, evt){
evt = $.Event(evt);
evt.preventDefault();
$.event.trigger(evt, undefined, elem);
};
var playerSwfPath = options.playerPath || webshims.cfg.basePath + "swf/" + (options.playerName || 'JarisFLVPlayer.swf');
webshims.extendUNDEFProp(options.params, {
allowscriptaccess: 'always',
allowfullscreen: 'true',
wmode: 'transparent',
allowNetworking: 'all'
});
webshims.extendUNDEFProp(options.vars, {
controltype: '1',
jsapi: '1'
});
webshims.extendUNDEFProp(options.attrs, {
bgcolor: '#000000'
});
var setReadyState = function(readyState, data){
if(readyState < 3){
clearTimeout(data._canplaythroughTimer);
}
if(readyState >= 3 && data.readyState < 3){
data.readyState = readyState;
trigger(data._elem, 'canplay');
if(!data.paused){
trigger(data._elem, 'playing');
}
clearTimeout(data._canplaythroughTimer);
data._canplaythroughTimer = setTimeout(function(){
setReadyState(4, data);
}, 4000);
}
if(readyState >= 4 && data.readyState < 4){
data.readyState = readyState;
trigger(data._elem, 'canplaythrough');
}
data.readyState = readyState;
};
mediaelement.jarisEvent = {};
var localConnectionTimer;
var onEvent = {
onPlayPause: function(jaris, data, override){
var playing, type;
if(override == null){
try {
playing = data.api.api_get("isPlaying");
} catch(e){}
} else {
playing = override;
}
if(playing == data.paused){
data.paused = !playing;
type = data.paused ? 'pause' : 'play';
data._ppFlag = true;
trigger(data._elem, type);
if(data.readyState < 3){
setReadyState(3, data);
}
if(!data.paused){
trigger(data._elem, 'playing');
}
}
},
onNotBuffering: function(jaris, data){
setReadyState(3, data);
},
onDataInitialized: function(jaris, data){
var oldDur = data.duration;
var durDelta;
data.duration = jaris.duration;
if(oldDur == data.duration || isNaN(data.duration)){return;}
if(data._calledMeta && ((durDelta = Math.abs(data.lastDuration - data.duration)) < 2)){return;}
data.videoHeight = jaris.height;
data.videoWidth = jaris.width;
if(!data.networkState){
data.networkState = 2;
}
if(data.readyState < 1){
setReadyState(1, data);
}
clearTimeout(data._durationChangeTimer);
if(data._calledMeta && data.duration){
data._durationChangeTimer = setTimeout(function(){
data.lastDuration = data.duration;
trigger(data._elem, 'durationchange');
}, durDelta > 50 ? 0 : durDelta > 9 ? 9 : 99);
} else {
data.lastDuration = data.duration;
if(data.duration){
trigger(data._elem, 'durationchange');
}
if(!data._calledMeta){
trigger(data._elem, 'loadedmetadata');
}
}
data._calledMeta = true;
},
onBuffering: function(jaris, data){
if(data.ended){
data.ended = false;
}
setReadyState(1, data);
trigger(data._elem, 'waiting');
},
onTimeUpdate: function(jaris, data){
if(data.ended){
data.ended = false;
}
if(data.readyState < 3){
setReadyState(3, data);
trigger(data._elem, 'playing');
}
trigger(data._elem, 'timeupdate');
},
onProgress: function(jaris, data){
if(data.ended){
data.ended = false;
}
if(!data.duration || isNaN(data.duration)){
return;
}
var percentage = jaris.loaded / jaris.total;
if(percentage > 0.02 && percentage < 0.2){
setReadyState(3, data);
} else if(percentage > 0.2){
if(percentage > 0.99){
data.networkState = 1;
}
setReadyState(4, data);
}
if(data._bufferedEnd && (data._bufferedEnd > percentage)){
data._bufferedStart = data.currentTime || 0;
}
data._bufferedEnd = percentage;
data.buffered.length = 1;
$.event.trigger('progress', undefined, data._elem, true);
},
onPlaybackFinished: function(jaris, data){
if(data.readyState < 4){
setReadyState(4, data);
}
data.ended = true;
trigger(data._elem, 'ended');
},
onVolumeChange: function(jaris, data){
if(data.volume != jaris.volume || data.muted != jaris.mute){
data.volume = jaris.volume;
data.muted = jaris.mute;
trigger(data._elem, 'volumechange');
}
},
ready: (function(){
var testAPI = function(data){
var passed = true;
try {
data.api.api_get('volume');
} catch(er){
passed = false;
}
return passed;
};
return function(jaris, data){
var i = 0;
var doneFn = function(){
if(i > 9){
data.tryedReframeing = 0;
return;
}
i++;
data.tryedReframeing++;
if(testAPI(data)){
data.wasSwfReady = true;
data.tryedReframeing = 0;
startAutoPlay(data);
workActionQueue(data);
} else if(data.tryedReframeing < 6) {
if(data.tryedReframeing < 3){
data.reframeTimer = setTimeout(doneFn, 9);
data.shadowElem.css({overflow: 'visible'});
setTimeout(function(){
data.shadowElem.css({overflow: 'hidden'});
}, 1);
} else {
data.shadowElem.css({overflow: 'hidden'});
$(data._elem).mediaLoad();
}
} else {
clearTimeout(data.reframeTimer);
webshims.error("reframing error");
}
};
if(!data || !data.api){return;}
if(!data.tryedReframeing){
data.tryedReframeing = 0;
}
clearTimeout(localConnectionTimer);
clearTimeout(data.reframeTimer);
data.shadowElem.removeClass('flashblocker-assumed');
if(!i){
doneFn();
} else {
data.reframeTimer = setTimeout(doneFn, 9);
}
};
})()
};
onEvent.onMute = onEvent.onVolumeChange;
var workActionQueue = function(data){
var actionLen = data.actionQueue.length;
var i = 0;
var operation;
if(actionLen && data.isActive == 'third'){
while(data.actionQueue.length && actionLen > i){
i++;
operation = data.actionQueue.shift();
try{
data.api[operation.fn].apply(data.api, operation.args);
} catch(er){
webshims.warn(er);
}
}
}
if(data.actionQueue.length){
data.actionQueue = [];
}
};
var startAutoPlay = function(data){
if(!data){return;}
if( (data._ppFlag === undefined && ($.prop(data._elem, 'autoplay')) || !data.paused)){
setTimeout(function(){
if(data.isActive == 'third' && (data._ppFlag === undefined || !data.paused)){
try {
$(data._elem).play();
data._ppFlag = true;
} catch(er){}
}
}, 1);
}
if(data.muted){
$.prop(data._elem, 'muted', true);
}
if(data.volume != 1){
$.prop(data._elem, 'volume', data.volume);
}
};
var addMediaToStopEvents = $.noop;
if(hasNative){
var stopEvents = {
play: 1,
playing: 1
};
var hideEvtArray = ['play', 'pause', 'playing', 'canplay', 'progress', 'waiting', 'ended', 'loadedmetadata', 'durationchange', 'emptied'];
var hidevents = hideEvtArray.map(function(evt){
return evt +'.webshimspolyfill';
}).join(' ');
var hidePlayerEvents = function(event){
var data = webshims.data(event.target, 'mediaelement');
if(!data){return;}
var isNativeHTML5 = ( event.originalEvent && event.originalEvent.type === event.type );
if( isNativeHTML5 == (data.activating == 'third') ){
event.stopImmediatePropagation();
if(stopEvents[event.type]){
if(data.isActive != data.activating){
$(event.target).pause();
} else if(isNativeHTML5){
($.prop(event.target, 'pause')._supvalue || $.noop).apply(event.target);
}
}
}
};
addMediaToStopEvents = function(elem){
$(elem)
.off(hidevents)
.on(hidevents, hidePlayerEvents)
;
hideEvtArray.forEach(function(evt){
webshims.moveToFirstEvent(elem, evt);
});
};
addMediaToStopEvents(document);
}
mediaelement.setActive = function(elem, type, data){
if(!data){
data = webshims.data(elem, 'mediaelement');
}
if(!data || data.isActive == type){return;}
if(type != 'html5' && type != 'third'){
webshims.warn('wrong type for mediaelement activating: '+ type);
}
var shadowData = webshims.data(elem, 'shadowData');
data.activating = type;
$(elem).pause();
data.isActive = type;
if(type == 'third'){
shadowData.shadowElement = shadowData.shadowFocusElement = data.shadowElem[0];
$(elem).addClass('swf-api-active nonnative-api-active').hide().getShadowElement().show();
} else {
$(elem).removeClass('swf-api-active nonnative-api-active').show().getShadowElement().hide();
shadowData.shadowElement = shadowData.shadowFocusElement = false;
}
$(elem).trigger('mediaelementapichange');
};
var resetSwfProps = (function(){
var resetProtoProps = ['_calledMeta', 'lastDuration', '_bufferedEnd', '_bufferedStart', '_ppFlag', 'currentSrc', 'currentTime', 'duration', 'ended', 'networkState', 'paused', 'videoHeight', 'videoWidth'];
var len = resetProtoProps.length;
return function(data){
if(!data){return;}
var lenI = len;
var networkState = data.networkState;
setReadyState(0, data);
clearTimeout(data._durationChangeTimer);
while(--lenI > -1){
delete data[resetProtoProps[lenI]];
}
data.actionQueue = [];
data.buffered.length = 0;
if(networkState){
trigger(data._elem, 'emptied');
}
};
})();
var transformDimension = (function(){
var dimCache = {};
var getRealDims = function(data){
var ret, poster, img;
if(dimCache[data.currentSrc]){
ret = dimCache[data.currentSrc];
} else if(data.videoHeight && data.videoWidth){
dimCache[data.currentSrc] = {
width: data.videoWidth,
height: data.videoHeight
};
ret = dimCache[data.currentSrc];
} else if((poster = $.attr(data._elem, 'poster'))){
ret = dimCache[poster];
if(!ret){
img = document.createElement('img');
img.onload = function(){
dimCache[poster] = {
width: this.width,
height: this.height
};
if(dimCache[poster].height && dimCache[poster].width){
setElementDimension(data, $.prop(data._elem, 'controls'));
} else {
delete dimCache[poster];
}
};
img.src = poster;
if(img.complete){
img.onload();
}
}
}
return ret || {width: 300, height: data._elemNodeName == 'video' ? 150 : 50};
};
return function(data){
var realDims, ratio;
var ret = data.elemDimensions;
if(ret.width == 'auto' || ret.height == 'auto'){
ret = $.extend({}, data.elemDimensions);
realDims = getRealDims(data);
ratio = realDims.width / realDims.height;
if(ret.width == 'auto' && ret.height == 'auto'){
ret = realDims;
} else if(ret.width == 'auto'){
data.shadowElem.css({height: ret.height});
ret.width = data.shadowElem.height() * ratio;
} else {
data.shadowElem.css({width: ret.width});
ret.height = data.shadowElem.width() / ratio;
}
}
return ret;
};
})();
var setElementDimension = function(data, hasControls){
var dims;
var elem = data._elem;
var box = data.shadowElem;
$(elem)[hasControls ? 'addClass' : 'removeClass']('webshims-controls');
if(data.isActive == 'third'){
if(data._elemNodeName == 'audio' && !hasControls){
box.css({width: 0, height: 0});
} else {
data.elemDimensions = {
width: elem.style.width || $.attr(elem, 'width') || $(elem).width(),
height: elem.style.height || $.attr(elem, 'height') || $(elem).height()
};
dims = transformDimension(data);
dims.minWidth = elem.style.minWidth;
dims.minHeight = elem.style.minHeight;
box.css(dims);
}
}
};
var bufferSrc = (function(){
var preloads = {
'': 1,
'auto': 1
};
return function(elem){
var preload = $.attr(elem, 'preload');
if(preload == null || preload == 'none' || $.prop(elem, 'autoplay')){
return false;
}
preload = $.prop(elem, 'preload');
return !!(preloads[preload] || (preload == 'metadata' && $(elem).is('.preload-in-doubt, video:not([poster])')));
};
})();
var regs = {
A: /&/g,
a: /&/g,
e: /\=/g,
q: /\?/g
},
replaceVar = function(val){
return (val.replace) ? val.replace(regs.A, '%26').replace(regs.a, '%26').replace(regs.e, '%3D').replace(regs.q, '%3F') : val;
};
if('matchMedia' in window){
var allowMediaSorting = false;
try {
allowMediaSorting = window.matchMedia('only all').matches;
} catch(er){}
if(allowMediaSorting){
mediaelement.sortMedia = function(src1, src2){
try {
src1 = !src1.media || matchMedia( src1.media ).matches;
src2 = !src2.media || matchMedia( src2.media ).matches;
} catch(er){
return 0;
}
return src1 == src2 ?
0 :
src1 ? -1
: 1;
};
}
}
mediaelement.createSWF = function( elem, canPlaySrc, data ){
if(!hasFlash){
setTimeout(function(){
$(elem).mediaLoad(); //<- this should produce a mediaerror
}, 1);
return;
}
if(loadedSwf < 1){
loadedSwf = 1;
} else {
loadedSwf++;
}
if(!data){
data = webshims.data(elem, 'mediaelement');
}
if($.attr(elem, 'height') || $.attr(elem, 'width')){
webshims.warn("width or height content attributes used. Webshims prefers the usage of CSS (computed styles or inline styles) to detect size of a video/audio. It's really more powerfull.");
}
var isRtmp = canPlaySrc.type == 'audio/rtmp' || canPlaySrc.type == 'video/rtmp';
var vars = $.extend({}, options.vars, {
poster: replaceVar($.attr(elem, 'poster') && $.prop(elem, 'poster') || ''),
source: replaceVar(canPlaySrc.streamId || canPlaySrc.srcProp),
server: replaceVar(canPlaySrc.server || '')
});
var elemVars = $(elem).data('vars') || {};
var hasControls = $.prop(elem, 'controls');
var elemId = 'jarisplayer-'+ webshims.getID(elem);
var params = $.extend(
{},
options.params,
$(elem).data('params')
);
var elemNodeName = elem.nodeName.toLowerCase();
var attrs = $.extend(
{},
options.attrs,
{
name: elemId,
id: elemId
},
$(elem).data('attrs')
);
var setDimension = function(){
if(data.isActive == 'third'){
setElementDimension(data, $.prop(elem, 'controls'));
}
};
var box;
if(data && data.swfCreated){
mediaelement.setActive(elem, 'third', data);
data.currentSrc = canPlaySrc.srcProp;
data.shadowElem.html('
');
data.api = false;
data.actionQueue = [];
box = data.shadowElem;
resetSwfProps(data);
} else {
box = $('
')
.css({
position: 'relative',
overflow: 'hidden'
})
;
data = webshims.data(elem, 'mediaelement', webshims.objectCreate(playerStateObj, {
actionQueue: {
value: []
},
shadowElem: {
value: box
},
_elemNodeName: {
value: elemNodeName
},
_elem: {
value: elem
},
currentSrc: {
value: canPlaySrc.srcProp
},
swfCreated: {
value: true
},
id: {
value: elemId.replace(/-/g, '')
},
buffered: {
value: {
start: function(index){
if(index >= data.buffered.length){
webshims.error('buffered index size error');
return;
}
return 0;
},
end: function(index){
if(index >= data.buffered.length){
webshims.error('buffered index size error');
return;
}
return ( (data.duration - data._bufferedStart) * data._bufferedEnd) + data._bufferedStart;
},
length: 0
}
}
}));
box.insertBefore(elem);
if(hasNative){
$.extend(data, {volume: $.prop(elem, 'volume'), muted: $.prop(elem, 'muted'), paused: $.prop(elem, 'paused')});
}
webshims.addShadowDom(elem, box);
if(!webshims.data(elem, 'mediaelement')){
webshims.data(elem, 'mediaelement', data);
}
addMediaToStopEvents(elem);
mediaelement.setActive(elem, 'third', data);
setElementDimension(data, hasControls);
$(elem)
.on({
'updatemediaelementdimensions loadedmetadata emptied': setDimension,
'remove': function(e){
if(!e.originalEvent && mediaelement.jarisEvent[data.id] && mediaelement.jarisEvent[data.id].elem == elem){
delete mediaelement.jarisEvent[data.id];
clearTimeout(localConnectionTimer);
clearTimeout(data.flashBlock);
}
}
})
.onWSOff('updateshadowdom', setDimension)
;
}
if(!mediaelement.jarisEvent[data.id] || mediaelement.jarisEvent[data.id].elem != elem){
mediaelement.jarisEvent[data.id] = function(jaris){
if(jaris.type == 'ready'){
var onReady = function(){
if(data.api){
if(bufferSrc(elem)){
data.api.api_preload();
}
onEvent.ready(jaris, data);
}
};
if(data.api){
onReady();
} else {
setTimeout(onReady, 9);
}
} else {
data.currentTime = jaris.position;
if(data.api){
if(!data._calledMeta && isNaN(jaris.duration) && data.duration != jaris.duration && isNaN(data.duration)){
onEvent.onDataInitialized(jaris, data);
}
if(!data._ppFlag && jaris.type != 'onPlayPause'){
onEvent.onPlayPause(jaris, data);
}
if(onEvent[jaris.type]){
onEvent[jaris.type](jaris, data);
}
}
data.duration = jaris.duration;
}
};
mediaelement.jarisEvent[data.id].elem = elem;
}
$.extend(vars,
{
id: elemId,
evtId: data.id,
controls: ''+hasControls,
autostart: 'false',
nodename: elemNodeName
},
elemVars
);
if(isRtmp){
vars.streamtype = 'rtmp';
} else if(canPlaySrc.type == 'audio/mpeg' || canPlaySrc.type == 'audio/mp3'){
vars.type = 'audio';
vars.streamtype = 'file';
} else if(canPlaySrc.type == 'video/youtube'){
vars.streamtype = 'youtube';
}
options.changeSWF(vars, elem, canPlaySrc, data, 'embed');
clearTimeout(data.flashBlock);
swfmini.embedSWF(playerSwfPath, elemId, "100%", "100%", "9.0.115", false, vars, params, attrs, function(swfData){
if(swfData.success){
var fBlocker = function(){
if((!swfData.ref.parentNode && box[0].parentNode) || swfData.ref.style.display == "none"){
box.addClass('flashblocker-assumed');
$(elem).trigger('flashblocker');
webshims.warn("flashblocker assumed");
}
$(swfData.ref).css({'minHeight': '2px', 'minWidth': '2px', display: 'block'});
};
data.api = swfData.ref;
if(!hasControls){
$(swfData.ref).attr('tabindex', '-1').css('outline', 'none');
}
data.flashBlock = setTimeout(fBlocker, 99);
if(!localConnectionTimer){
clearTimeout(localConnectionTimer);
localConnectionTimer = setTimeout(function(){
fBlocker();
var flash = $(swfData.ref);
if(flash[0].offsetWidth > 1 && flash[0].offsetHeight > 1 && location.protocol.indexOf('file:') === 0){
webshims.error("Add your local development-directory to the local-trusted security sandbox: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html");
} else if(flash[0].offsetWidth < 2 || flash[0].offsetHeight < 2) {
webshims.warn("JS-SWF connection can't be established on hidden or unconnected flash objects");
}
flash = null;
}, 8000);
}
}
});
};
var queueSwfMethod = function(elem, fn, args, data){
data = data || getSwfDataFromElem(elem);
if(data){
if(data.api && data.api[fn]){
data.api[fn].apply(data.api, args || []);
} else {
//todo add to queue
data.actionQueue.push({fn: fn, args: args});
if(data.actionQueue.length > 10){
setTimeout(function(){
if(data.actionQueue.length > 5){
data.actionQueue.shift();
}
}, 99);
}
}
return data;
}
return false;
};
['audio', 'video'].forEach(function(nodeName){
var descs = {};
var mediaSup;
var createGetProp = function(key){
if(nodeName == 'audio' && (key == 'videoHeight' || key == 'videoWidth')){return;}
descs[key] = {
get: function(){
var data = getSwfDataFromElem(this);
if(data){
return data[key];
} else if(hasNative && mediaSup[key].prop._supget) {
return mediaSup[key].prop._supget.apply(this);
} else {
return playerStateObj[key];
}
},
writeable: false
};
};
var createGetSetProp = function(key, setFn){
createGetProp(key);
delete descs[key].writeable;
descs[key].set = setFn;
};
createGetSetProp('volume', function(v){
var data = getSwfDataFromElem(this);
if(data){
v *= 1;
if(!isNaN(v)){
if(v < 0 || v > 1){
webshims.error('volume greater or less than allowed '+ (v / 100));
}
queueSwfMethod(this, 'api_volume', [v], data);
if(data.volume != v){
data.volume = v;
trigger(data._elem, 'volumechange');
}
data = null;
}
} else if(mediaSup.volume.prop._supset) {
return mediaSup.volume.prop._supset.apply(this, arguments);
}
});
createGetSetProp('muted', function(m){
var data = getSwfDataFromElem(this);
if(data){
m = !!m;
queueSwfMethod(this, 'api_muted', [m], data);
if(data.muted != m){
data.muted = m;
trigger(data._elem, 'volumechange');
}
data = null;
} else if(mediaSup.muted.prop._supset) {
return mediaSup.muted.prop._supset.apply(this, arguments);
}
});
createGetSetProp('currentTime', function(t){
var data = getSwfDataFromElem(this);
if(data){
t *= 1;
if (!isNaN(t)) {
queueSwfMethod(this, 'api_seek', [t], data);
}
} else if(mediaSup.currentTime.prop._supset) {
return mediaSup.currentTime.prop._supset.apply(this, arguments);
}
});
['play', 'pause'].forEach(function(fn){
descs[fn] = {
value: function(){
var data = getSwfDataFromElem(this);
if(data){
if(data.stopPlayPause){
clearTimeout(data.stopPlayPause);
}
queueSwfMethod(this, fn == 'play' ? 'api_play' : 'api_pause', [], data);
data._ppFlag = true;
if(data.paused != (fn != 'play')){
data.paused = fn != 'play';
trigger(data._elem, fn);
}
} else if(mediaSup[fn].prop._supvalue) {
return mediaSup[fn].prop._supvalue.apply(this, arguments);
}
}
};
});
getPropKeys.forEach(createGetProp);
webshims.onNodeNamesPropertyModify(nodeName, 'controls', function(val, boolProp){
var data = getSwfDataFromElem(this);
$(this)[boolProp ? 'addClass' : 'removeClass']('webshims-controls');
if(data){
if(nodeName == 'audio'){
setElementDimension(data, boolProp);
}
queueSwfMethod(this, 'api_controls', [boolProp], data);
}
});
webshims.onNodeNamesPropertyModify(nodeName, 'preload', function(val){
var data, baseData, elem;
if(bufferSrc(this)){
data = getSwfDataFromElem(this);
if(data){
queueSwfMethod(this, 'api_preload', [], data);
} else if(needsLoadPreload && this.paused && !this.error && !$.data(this, 'mediaerror') && !this.readyState && !this.networkState && !this.autoplay && $(this).is(':not(.nonnative-api-active)')){
elem = this;
baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
clearTimeout(baseData.loadTimer);
baseData.loadTimer = setTimeout(function(){
$(elem).mediaLoad();
}, 9);
}
}
});
mediaSup = webshims.defineNodeNameProperties(nodeName, descs, 'prop');
});
if(hasFlash && $.cleanData){
var oldClean = $.cleanData;
var flashNames = {
object: 1,
OBJECT: 1
};
$.cleanData = function(elems){
var i, len, prop;
if(elems && (len = elems.length) && loadedSwf){
for(i = 0; i < len; i++){
if(flashNames[elems[i].nodeName] && 'api_pause' in elems[i]){
loadedSwf--;
try {
elems[i].api_pause();
} catch(er){}
}
}
}
return oldClean.apply(this, arguments);
};
}
if(!hasNative){
['poster', 'src'].forEach(function(prop){
webshims.defineNodeNamesProperty(prop == 'src' ? ['audio', 'video', 'source'] : ['video'], prop, {
//attr: {},
reflect: true,
propType: 'src'
});
});
webshims.defineNodeNamesProperty(['audio', 'video'], 'preload', {
reflect: true,
propType: 'enumarated',
defaultValue: '',
limitedTo: ['', 'auto', 'metadata', 'none']
});
webshims.reflectProperties('source', ['type', 'media']);
['autoplay', 'controls'].forEach(function(name){
webshims.defineNodeNamesBooleanProperty(['audio', 'video'], name);
});
webshims.defineNodeNamesProperties(['audio', 'video'], {
HAVE_CURRENT_DATA: {
value: 2
},
HAVE_ENOUGH_DATA: {
value: 4
},
HAVE_FUTURE_DATA: {
value: 3
},
HAVE_METADATA: {
value: 1
},
HAVE_NOTHING: {
value: 0
},
NETWORK_EMPTY: {
value: 0
},
NETWORK_IDLE: {
value: 1
},
NETWORK_LOADING: {
value: 2
},
NETWORK_NO_SOURCE: {
value: 3
}
}, 'prop');
} else if(!('media' in document.createElement('source'))){
webshims.reflectProperties('source', ['media']);
}
});