/** * jwplayer.html5 namespace * * @author pablo */ (function(jwplayer) { jwplayer.html5 = {}; jwplayer.html5.version = '6.12.0'; // these 'reset' styles must be included before any others var _css = jwplayer.utils.css; var jw_class = '.jwplayer '; var helperstring = [jw_class, 'div', 'span', 'a', 'img', 'ul', 'li', 'video'].join(', ' + jw_class); _css(helperstring + ', .jwclick', { margin: 0, padding: 0, border: 0, color: '#000000', 'font-size': '100%', font: 'inherit', 'vertical-align': 'baseline', 'background-color': 'transparent', 'text-align': 'left', 'direction': 'ltr', 'line-height': 20, '-webkit-tap-highlight-color': 'rgba(255, 255, 255, 0)' }); // reset box-sizing to default for player and all sub-elements // note: if we use pseudo elements we will need to add *:before and *:after _css(jw_class + ',' + jw_class + '*', { 'box-sizing': 'content-box'}); // browsers use border-box as a the default box-sizing for many form elements _css(jw_class + '* button,' + jw_class + '* input,' + jw_class + '* select,' + jw_class + '* textarea', { 'box-sizing': 'border-box'}); _css(jw_class + 'ul', { 'list-style': 'none' }); // these rules allow click and hover events to reach the provider, instead // of being blocked by the controller element // ** note : pointer-events will not work on ie < 11 _css('.jwplayer .jwcontrols', { 'pointer-events': 'none' }); _css('.jwplayer.jw-user-inactive .jwcontrols', { 'pointer-events': 'all' }); var acceptclicks = [ '.jwplayer .jwcontrols .jwdockbuttons', '.jwplayer .jwcontrols .jwcontrolbar', '.jwplayer .jwcontrols .jwskip', '.jwplayer .jwcontrols .jwdisplayicon', // play and replay button '.jwplayer .jwcontrols .jwpreview', // poster image '.jwplayer .jwcontrols .jwlogo' ]; _css(acceptclicks.join(', '), { 'pointer-events' : 'all' }); })(jwplayer); /** * html5-only utilities for the jw player. * * @author pablo * @version 6.0 */ (function(utils) { var document = document; /** * cleans up a css dimension (e.g. '420px') and returns an integer. */ utils.parsedimension = function(dimension) { if (typeof dimension === 'string') { if (dimension === '') { return 0; } else if (dimension.lastindexof('%') > -1) { return dimension; } return parseint(dimension.replace('px', ''), 10); } return dimension; }; /** format the elapsed / remaining text. **/ utils.timeformat = function(sec) { if (sec > 0) { var hrs = math.floor(sec / 3600), mins = math.floor((sec - hrs * 3600) / 60), secs = math.floor(sec % 60); return (hrs ? hrs + ':' : '') + (mins < 10 ? '0' : '') + mins + ':' + (secs < 10 ? '0' : '') + secs; } else { return '00:00'; } }; utils.bounds = function(element) { var bounds = { left: 0, right: 0, width: 0, height: 0, top: 0, bottom: 0 }; if (!element || !document.body.contains(element)) { return bounds; } if (element.getboundingclientrect) { var rect = element.getboundingclientrect(element), scrolloffsety = window.pageyoffset, scrolloffsetx = window.pagexoffset; if (!rect.width && !rect.height && !rect.left && !rect.top) { //element is not visible / no layout return bounds; } bounds.left = rect.left + scrolloffsetx; bounds.right = rect.right + scrolloffsetx; bounds.top = rect.top + scrolloffsety; bounds.bottom = rect.bottom + scrolloffsety; bounds.width = rect.right - rect.left; bounds.height = rect.bottom - rect.top; } else { /*jshint -w084 */ // for the while loop assignment bounds.width = element.offsetwidth | 0; bounds.height = element.offsetheight | 0; do { bounds.left += element.offsetleft | 0; bounds.top += element.offsettop | 0; } while (element = element.offsetparent); bounds.right = bounds.left + bounds.width; bounds.bottom = bounds.top + bounds.height; } return bounds; }; utils.empty = function(element) { if (!element) { return; } while (element.childelementcount > 0) { element.removechild(element.children[0]); } }; })(jwplayer.utils); (function(utils) { /*jshint maxparams:6*/ /** stretching options **/ var _stretching = utils.stretching = { none: 'none', fill: 'fill', uniform: 'uniform', exactfit: 'exactfit' }; utils.scale = function(domelement, xscale, yscale, xoffset, yoffset) { var value = ''; // set defaults xscale = xscale || 1; yscale = yscale || 1; xoffset = xoffset | 0; yoffset = yoffset | 0; if (xscale !== 1 || yscale !== 1) { value = 'scale(' + xscale + ', ' + yscale + ')'; } if (xoffset || yoffset) { if (value) { value += ' '; } value = 'translate(' + xoffset + 'px, ' + yoffset + 'px)'; } utils.transform(domelement, value); }; /** * stretches domelement based on stretching. parentwidth, parentheight, * elementwidth, and elementheight are required as the elements dimensions * change as a result of the stretching. hence, the original dimensions must * always be supplied. * * @param {string} * stretching * @param {domelement} * domelement * @param {number} * parentwidth * @param {number} * parentheight * @param {number} * elementwidth * @param {number} * elementheight */ utils.stretch = function(stretching, domelement, parentwidth, parentheight, elementwidth, elementheight) { if (!domelement) { return false; } if (!parentwidth || !parentheight || !elementwidth || !elementheight) { return false; } stretching = stretching || _stretching.uniform; var xscale = math.ceil(parentwidth / 2) * 2 / elementwidth, yscale = math.ceil(parentheight / 2) * 2 / elementheight, video = (domelement.tagname.tolowercase() === 'video'), scale = false, stretchclass = 'jw' + stretching.tolowercase(); switch (stretching.tolowercase()) { case _stretching.fill: if (xscale > yscale) { yscale = xscale; } else { xscale = yscale; } scale = true; break; case _stretching.none: xscale = yscale = 1; /* falls through */ case _stretching.exactfit: scale = true; break; case _stretching.uniform: /* falls through */ default: if (xscale > yscale) { if (elementwidth * yscale / parentwidth > 0.95) { scale = true; stretchclass = 'jwexactfit'; } else { elementwidth = elementwidth * yscale; elementheight = elementheight * yscale; } } else { if (elementheight * xscale / parentheight > 0.95) { scale = true; stretchclass = 'jwexactfit'; } else { elementwidth = elementwidth * xscale; elementheight = elementheight * xscale; } } if (scale) { xscale = math.ceil(parentwidth / 2) * 2 / elementwidth; yscale = math.ceil(parentheight / 2) * 2 / elementheight; } } if (video) { var style = { left: '', right: '', width: '', height: '' }; if (scale) { if (parentwidth < elementwidth) { style.left = style.right = math.ceil((parentwidth - elementwidth) / 2); } if (parentheight < elementheight) { style.top = style.bottom = math.ceil((parentheight - elementheight) / 2); } style.width = elementwidth; style.height = elementheight; utils.scale(domelement, xscale, yscale, 0, 0); } else { scale = false; utils.transform(domelement); } utils.css.style(domelement, style); } else { domelement.classname = domelement.classname.replace(/\s*jw(none|exactfit|uniform|fill)/g, '') + ' ' + stretchclass; } return scale; }; })(jwplayer.utils); (function(parsers) { /** component that loads and parses an dfxp file. **/ parsers.dfxp = function() { var _seconds = jwplayer.utils.seconds; this.parse = function(data) { var _captions = [{ begin: 0, text: '' }]; data = data.replace(/^\s+/, '').replace(/\s+$/, ''); var list = data.split('

'); var list2 = data.split(''); var newlist = []; var i; for (i = 0; i < list.length; i++) { if (list[i].indexof('= 0) { list[i] = list[i].substr(list[i].indexof('= 0) { list2[i] = list2[i].substr(list2[i].indexof(' 1) { return _captions; } else { throw { message: 'invalid dfxp file:' }; } }; /** parse a single captions entry. **/ function _entry(data) { var entry = {}; try { var idx = data.indexof('begin=\"'); data = data.substr(idx + 7); idx = data.indexof('\" end=\"'); entry.begin = _seconds(data.substr(0, idx)); data = data.substr(idx + 7); idx = data.indexof('\"'); entry.end = _seconds(data.substr(0, idx)); idx = data.indexof('\">'); data = data.substr(idx + 2); entry.text = data; } catch (error) {} return entry; } }; })(jwplayer.parsers); (function(parsers) { /** component that loads and parses an srt file. **/ parsers.srt = function() { /** xmlhttp object. **/ var _utils = jwplayer.utils, _seconds = _utils.seconds; this.parse = function(data, mergebeginend) { // trim whitespace and split the list by returns. var _captions = mergebeginend ? [] : [{ begin: 0, text: '' }]; data = _utils.trim(data); var list = data.split('\r\n\r\n'); if (list.length === 1) { list = data.split('\n\n'); } for (var i = 0; i < list.length; i++) { if (list[i] === 'webvtt') { continue; } // parse each entry var entry = _entry(list[i]); if (entry.text) { _captions.push(entry); // insert empty caption at the end. if (entry.end && !mergebeginend) { _captions.push({ begin: entry.end, text: '' }); delete entry.end; } } } if (_captions.length > 1) { return _captions; } else { throw { message: 'invalid srt file' }; } }; /** parse a single captions entry. **/ function _entry(data) { var entry = {}; var array = data.split('\r\n'); if (array.length === 1) { array = data.split('\n'); } try { // second line contains the start and end. var idx = 1; if (array[0].indexof(' --> ') > 0) { idx = 0; } var index = array[idx].indexof(' --> '); if (index > 0) { entry.begin = _seconds(array[idx].substr(0, index)); entry.end = _seconds(array[idx].substr(index + 5)); } // third line starts the text. if (array[idx + 1]) { entry.text = array[idx + 1]; // arbitrary number of additional lines. for (var i = idx + 2; i < array.length; i++) { entry.text += '
' + array[i]; } } } catch (error) {} return entry; } }; })(jwplayer.parsers); (function(jwplayer) { var noop = jwplayer.utils.noop, _ = jwplayer._, events = jwplayer.events, returnfalse = _.constant(false); var defaultprovider = { // this function is required to determine if a provider can work on a given source supports : returnfalse, // basic playback features play : noop, load : noop, stop : noop, volume : noop, mute : noop, seek : noop, seekdrag : noop, // only for html5 ? resize : noop, remove : noop, // removes from page destroy : noop, // frees memory setvisibility : noop, setfullscreen : returnfalse, getfullscreen : noop, // if setcontainer has been set, this returns the element. // it's value is used to determine if we should remove the