mediacms/static/js/media.js

1 line
159 KiB
JavaScript
Raw Normal View History

!function(){"use strict";var e={7251:function(e,t,n){var i=n(2667),a=(n(5101),n(5466)),o=(n(6116),n(9518)),r=n(3074),l=n.n(r),s=n(365),u=n(920),c=n.n(u),d=n(2276),p=n(2787),m=n(4426),f=n(3811);function h(e){var t=null,n=e.split(".");if(n.length)switch(n=n[n.length-1]){case"webm":t="audio/webm";break;case"flac":t="audio/flac";break;case"wave":t="audio/wave";break;case"wav":t="audio/wav";break;case"ogg":case"ogg":t="audio/ogg";break;case"mp3":case"mpeg":t="audio/mpeg"}return t}n(2322),n(9268);var y=n(9688),b=n(5793),g=n(6983),v=n(9450);function _(e){return(_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function E(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e,t){return!t||"object"!==_(t)&&"function"!=typeof t?C(e):t}function C(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function P(e){return(P=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}new v.Z;var S=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&w(e,t)}(l,e);var t,n,i,o,r=(i=l,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=P(i);if(o){var n=P(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return k(this,e)});function l(e){var t;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),t=r.call(this,e);var n=d.Z.get("media-data");t.AudioPlayerData={},t.audioStartedPlaying=!1;var i=(0,y.U)(n.original_media_url,s.Z._currentValue.url);t.videoSources=[{src:i,type:h(i)}],t.videoPoster=n.poster_url,t.videoPoster=t.videoPoster?t.videoPoster:n.thumbnail_url,t.videoPoster=t.videoPoster?(0,y.U)(t.videoPoster,s.Z._currentValue.url):"",t.updatePlayerVolume=t.updatePlayerVolume.bind(C(t)),t.onAudioEnd=t.onAudioEnd.bind(C(t)),t.onAudioRestart=t.onAudioRestart.bind(C(t)),m.Z.on("switched_media_auto_play",t.onUpdateMediaAutoPlay.bind(C(t))),t.wrapperClick=t.wrapperClick.bind(C(t));var a=new v.Z;return a.update(d.Z.get("media-data").duration),t.durationISO8601=a.ISO8601(),t}return t=l,(n=[{key:"componentDidMount",value:function(){this.videoSources.length||console.warn("Audio DEBUG:","Audio file doesn't exist"),this.recommendedMedia=d.Z.get("media-data").related_media.length?new g.Z(d.Z.get("media-data").related_media,this.refs.AudioElem.parentNode,this.props.inEmbed):null,this.upNextLoaderView=!this.props.inEmbed&&d.Z.get("media-data").related_media.length?new b.Z(d.Z.get("media-data").related_media[0]):null,document.hasFocus()||"visible"===document.visibilityState?this.initPlayerInstance():(this.initPlayerInstance=this.initPlayerInstance.bind(this),window.addEventListener("focus",this.initPlayerInstance),document.addEventListener("visibilitychange",this.initPlayerInstance))}},{key:"componentWillUnmount",value:function(){this.recommendedMedia&&(this.AudioPlayerData.instance.player.off("fullscreenchange",this.recommendedMedia.onResize),m.Z.removeListener("window_resize",this.recommendedMedia.onResize),p.Z.removeListener("changed_viewer_mode",this.recommendedMedia.onResize),this.recommendedMedia.destroy()),videojs(this.refs.AudioElem).dispose(),this.AudioPlayerData.instance=null,delete this.AudioPlayerData.instance}},{key:"initPlayerInstance",value:function(){window.removeEventListener("focus",this.initPlayerInstance)