/**
* The Nomensa accessible media player is a flexible multimedia solution for websites and intranets.
* The core player consists of JavaScript wrapper responsible for generating an accessible HTML toolbar
* for interacting with a media player of your choice. We currently provide support for YouTube (default),
* Vimeo and JWPlayer although it should be possible to integrate the player with almost any media player on
* the web (provided a JavaScript api for the player in question is available).
*
* Copyright (C) 2019 Nomensa Ltd
*
* Version 2.1.3
*
* This is a fork of the original project source code available at: https://github.com/alphagov/Accessible-Media-Player
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
**/
var swfobject=function(){var aq="undefined",aD="object",ab="Shockwave Flash",X="ShockwaveFlash.ShockwaveFlash",aE="application/x-shockwave-flash",ac="SWFObjectExprInst",ax="onreadystatechange",af=window,aL=document,aB=navigator,aa=false,Z=[aN],aG=[],ag=[],al=[],aJ,ad,ap,at,ak=false,aU=false,aH,an,aI=true,ah=function(){var a=typeof aL.getElementById!=aq&&typeof aL.getElementsByTagName!=aq&&typeof aL.createElement!=aq,e=aB.userAgent.toLowerCase(),c=aB.platform.toLowerCase(),h=c?/win/.test(c):/win/.test(e),j=c?/mac/.test(c):/mac/.test(e),g=/webkit/.test(e)?parseFloat(e.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,d=!+"\v1",f=[0,0,0],k=null;if(typeof aB.plugins!=aq&&typeof aB.plugins[ab]==aD){k=aB.plugins[ab].description;if(k&&!(typeof aB.mimeTypes!=aq&&aB.mimeTypes[aE]&&!aB.mimeTypes[aE].enabledPlugin)){aa=true;d=false;k=k.replace(/^.*\s+(\S+\s+\S+$)/,"$1");f[0]=parseInt(k.replace(/^(.*)\..*$/,"$1"),10);f[1]=parseInt(k.replace(/^.*\.(.*)\s.*$/,"$1"),10);f[2]=/[a-zA-Z]/.test(k)?parseInt(k.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0;}}else{if(typeof af.ActiveXObject!=aq){try{var i=new ActiveXObject(X);if(i){k=i.GetVariable("$version");if(k){d=true;k=k.split(" ")[1].split(",");f=[parseInt(k[0],10),parseInt(k[1],10),parseInt(k[2],10)];}}}catch(b){}}}return{w3:a,pv:f,wk:g,ie:d,win:h,mac:j};}(),aK=function(){if(!ah.w3){return;}if((typeof aL.readyState!=aq&&aL.readyState=="complete")||(typeof aL.readyState==aq&&(aL.getElementsByTagName("body")[0]||aL.body))){aP();}if(!ak){if(typeof aL.addEventListener!=aq){aL.addEventListener("DOMContentLoaded",aP,false);}if(ah.ie&&ah.win){aL.attachEvent(ax,function(){if(aL.readyState=="complete"){aL.detachEvent(ax,arguments.callee);aP();}});if(af==top){(function(){if(ak){return;}try{aL.documentElement.doScroll("left");}catch(a){setTimeout(arguments.callee,0);return;}aP();})();}}if(ah.wk){(function(){if(ak){return;}if(!/loaded|complete/.test(aL.readyState)){setTimeout(arguments.callee,0);return;}aP();})();}aC(aP);}}();function aP(){if(ak){return;}try{var b=aL.getElementsByTagName("body")[0].appendChild(ar("span"));b.parentNode.removeChild(b);}catch(a){return;}ak=true;var d=Z.length;for(var c=0;c0){for(var h=0;h0){var i=aS(c);if(i){if(ao(aG[h].swfVersion)&&!(ah.wk&&ah.wk<312)){ay(c,true);if(l){a.success=true;a.ref=av(c);l(a);}}else{if(aG[h].expressInstall&&au()){var e={};e.data=aG[h].expressInstall;e.width=i.getAttribute("width")||"0";e.height=i.getAttribute("height")||"0";if(i.getAttribute("class")){e.styleclass=i.getAttribute("class");}if(i.getAttribute("align")){e.align=i.getAttribute("align");}var f={};var d=i.getElementsByTagName("param");var k=d.length;for(var j=0;j';}}a.outerHTML='";ag[ag.length]=e.id;d=aS(e.id);}else{var b=ar(aD);b.setAttribute("type",aE);for(var k in e){if(e[k]!=Object.prototype[k]){if(k.toLowerCase()=="styleclass"){b.setAttribute("class",e[k]);}else{if(k.toLowerCase()!="classid"){b.setAttribute(k,e[k]);}}}}for(var l in g){if(g[l]!=Object.prototype[l]&&l.toLowerCase()!="movie"){aQ(b,l,g[l]);}}a.parentNode.replaceChild(b,a);d=b;}}return d;}function aQ(b,d,c){var a=ar("param");a.setAttribute("name",d);a.setAttribute("value",c);b.appendChild(a);}function aw(a){var b=aS(a);if(b&&b.nodeName=="OBJECT"){if(ah.ie&&ah.win){b.style.display="none";(function(){if(b.readyState==4){aT(a);}else{setTimeout(arguments.callee,10);}})();}else{b.parentNode.removeChild(b);}}}function aT(a){var b=aS(a);if(b){for(var c in b){if(typeof b[c]=="function"){b[c]=null;}}b.parentNode.removeChild(b);}}function aS(a){var c=null;try{c=aL.getElementById(a);}catch(b){}return c;}function ar(a){return aL.createElement(a);}function aM(a,c,b){a.attachEvent(c,b);al[al.length]=[a,c,b];}function ao(a){var b=ah.pv,c=a.split(".");c[0]=parseInt(c[0],10);c[1]=parseInt(c[1],10)||0;c[2]=parseInt(c[2],10)||0;return(b[0]>c[0]||(b[0]==c[0]&&b[1]>c[1])||(b[0]==c[0]&&b[1]==c[1]&&b[2]>=c[2]))?true:false;}function az(b,f,a,c){if(ah.ie&&ah.mac){return;}var e=aL.getElementsByTagName("head")[0];if(!e){return;}var g=(a&&typeof a=="string")?a:"screen";if(c){aH=null;an=null;}if(!aH||an!=g){var d=ar("style");d.setAttribute("type","text/css");d.setAttribute("media",g);aH=e.appendChild(d);if(ah.ie&&ah.win&&typeof aL.styleSheets!=aq&&aL.styleSheets.length>0){aH=aL.styleSheets[aL.styleSheets.length-1];}an=g;}if(ah.ie&&ah.win){if(aH&&typeof aH.addRule==aD){aH.addRule(b,f);}}else{if(aH&&typeof aL.createTextNode!=aq){aH.appendChild(aL.createTextNode(b+" {"+f+"}"));}}}function ay(a,c){if(!aI){return;}var b=c?"visible":"hidden";if(ak&&aS(a)){aS(a).style.visibility=b;}else{az("#"+a,"visibility:"+b);}}function ai(b){var a=/[\\\"<>\.;]/;var c=a.exec(b)!=null;return c&&typeof encodeURIComponent!=aq?encodeURIComponent(b):b;}var aR=function(){if(ah.ie&&ah.win){window.attachEvent("onunload",function(){var a=al.length;for(var b=0;b").attr("id","player-"+this.config.id).addClass("flashReplace").html('This content requires Macromedia Flash Player. You can install or upgrade the Adobe Flash Player here.');var d=$("").addClass("video");var b=this.getURL();setTimeout(function(){swfobject.embedSWF(b,e.attr("id"),g.config.flashWidth,g.config.flashHeight,"9.0.115",null,a,f,h,g.config.swfCallback);if(window.NOMENSA.browser.mozilla&&(parseInt(window.NOMENSA.browser.version,10)>=2)){g.$html.find("object").attr("tabindex","-1");}},0);c.append(d.append(e));return c;},generateVideoPlayer:function(b){if(typeof window.postMessage==="undefined"){return this.generateFlashPlayer(b);}else{var a=$("<"+this.config.flashContainer+" />").attr("id","player-"+this.config.id);var c=$("").addClass("video");b.append(c.append(a));return b;}},getPlayer:function(){return this.player;},is_html5:false,play:function(){this.player.playVideo();this.setSliderTimeout();if(this.config.captionsOn&&this.captions){this.setCaptionTimeout();}},pause:function(){this.player.pauseVideo();this.clearSliderTimeout();if(this.config.captionsOn&&this.captions){this.clearCaptionTimeout();}},ffwd:function(){var b=this.getCurrentTime()+this.config.playerSkip,a=this.getDuration();if(b>a){b=a;}this.seek(b);},rewd:function(){var a=this.getCurrentTime()-this.config.playerSkip;if(a<0){a=0;}this.seek(a);},mute:function(){var a=this.$html.find("button.mute");if(this.player.isMuted()){this.player.unMute();if(a.hasClass("muted")){a.removeClass("muted");}}else{this.player.mute();a.addClass("muted");}},volup:function(){var a=this.player.getVolume();if(a>=100){a=100;}else{a=a+this.config.volumeStep;}this.player.setVolume(a);this.updateVolume(a);},voldwn:function(){var a=this.player.getVolume();if(a<=0){a=0;}else{a=a-this.config.volumeStep;}this.player.setVolume(a);this.updateVolume(a);},getDuration:function(){return this.player.getDuration();},getCurrentTime:function(){return this.player.getCurrentTime();},getBytesLoaded:function(){return this.player.getVideoBytesLoaded();},getBytesTotal:function(){return this.player.getVideoBytesTotal();},seek:function(a){this.player.seekTo(a,true);if(this.config.captionsOn&&this.captions){this.$html.find(".caption").remove();this.clearCaptionTimeout();this.setCaptionTimeout();this.getPreviousCaption();}},cue:function(){this.player.cueVideoById(this.config.media);},toggleCaptions:function(){var a=this;var b=this.$html.find(".captions");if(b.hasClass("captions-off")){b.removeClass("captions-off").addClass("captions-on");a.getPreviousCaption();a.setCaptionTimeout();a.config.captionsOn=true;}else{b.removeClass("captions-on").addClass("captions-off");a.clearCaptionTimeout();a.$html.find(".caption").remove();a.config.captionsOn=false;}}};window.NOMENSA=window.NOMENSA||{};window.NOMENSA.player=window.NOMENSA.player||{};window.NOMENSA.player.MediaplayerDecorator=function(a){var b=a;this.config=b.config;this.player=b.player;this.state=b.state;for(var c in b){if(typeof b[c]==="function"){this[c]=(function(d){return function(){return b[d].apply(this,arguments);};}(c));}}};window.NOMENSA.player.MediaplayerDecorator.prototype.generatePlayerContainer=function(){var a=$("<"+this.config.playerContainer+" />").css(this.config.playerStyles).addClass("player-container");if(window.NOMENSA.browser.msie){a.addClass("player-container-ie player-container-ie-"+window.NOMENSA.browser.version.substring(0,1));}return a;};window.NOMENSA.player.MediaplayerDecorator.prototype.assembleHTML=function(){var a=this.generatePlayerContainer();var c=this.generateVideoPlayer(a);var b=c.append(this.getControls());return b;};window.NOMENSA.player.MediaplayerDecorator.prototype.getURL=function(){return[this.config.url,this.config.id].join("");};window.NOMENSA.player.MediaplayerDecorator.prototype.createButton=function(d,b){var a=0;var e=[d,this.config.id].join("-");var c=$("").append(b).addClass(d).attr({title:d,id:e}).addClass("ui-corner-all ui-state-default").hover(function(){$(this).addClass("ui-state-hover");},function(){$(this).removeClass("ui-state-hover");}).focus(function(){$(this).addClass("ui-state-focus");}).blur(function(){$(this).removeClass("ui-state-focus");}).click(function(f){f.preventDefault();});return c;};window.NOMENSA.player.MediaplayerDecorator.prototype.getFuncControls=function(){var l=this;var j=$("