UNPKG

@jwplayer/jwplayer-react

Version:

A react component that creates an instance of JW Player

2 lines 11.6 kB
/*! For license information please see jwplayer-react.js.LICENSE.txt */ (()=>{var e={262:e=>{e.exports=new Set(["hlsjsProgressive","__abSendDomainToFeeds","_abZoomThumbnail","advertising","aboutlink","abouttext","aestoken","allowFullscreen","analytics","androidhls","aspectratio","autoPause","autostart","base","captions","cast","controls","defaultBandwidthEstimate","description","displaydescription","displayHeading","displayPlaybackLabel","displaytitle","drm","duration","enableDefaultCaptions","events","file","forceLocalizationDefaults","fwassetid","floating","ga","generateSEOMetadata","height","hlsjsConfig","hlsjsdefault","horizontalVolumeSlider","image","intl","key","listbar","liveSyncDuration","liveTimeout","localization","logo","mediaid","mute","nextUpDisplay","nextupoffset","pad","ph","pid","pipIcon","playbackRateControls","playbackRates","playlist","playlistIndex","plugins","preload","qualityLabel","qualityLabels","recommendations","related","renderCaptionsNatively","repeat","safarihlsjs","sdkplatform","selectedBitrate","setTimeEvents","skin","sharing","sources","stagevideo","streamtype","stretching","title","tracks","type","variations","volume","width","withCredentials","doNotTrack","doNotTrackCookies","images"])},418:e=>{"use strict";var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,o){for(var a,i,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u<arguments.length;u++){for(var l in a=Object(arguments[u]))r.call(a,l)&&(s[l]=a[l]);if(t){i=t(a);for(var c=0;c<i.length;c++)n.call(a,i[c])&&(s[i[c]]=a[i[c]])}}return s}},251:(e,t,r)=>{"use strict";r(418);var n=r(294),o=60103;if("function"==typeof Symbol&&Symbol.for){var a=Symbol.for;o=a("react.element"),a("react.fragment")}var i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s=Object.prototype.hasOwnProperty,u={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,r){var n,a={},l=null,c=null;for(n in void 0!==r&&(l=""+r),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(c=t.ref),t)s.call(t,n)&&!u.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===a[n]&&(a[n]=t[n]);return{$$typeof:o,type:e,key:l,ref:c,props:a,_owner:i.current}}},408:(e,t,r)=>{"use strict";var n=r(418),o=60103,a=60106;t.Fragment=60107,t.StrictMode=60108,t.Profiler=60114;var i=60109,s=60110,u=60112;t.Suspense=60113;var l=60115,c=60116;if("function"==typeof Symbol&&Symbol.for){var f=Symbol.for;o=f("react.element"),a=f("react.portal"),t.Fragment=f("react.fragment"),t.StrictMode=f("react.strict_mode"),t.Profiler=f("react.profiler"),i=f("react.provider"),s=f("react.context"),u=f("react.forward_ref"),t.Suspense=f("react.suspense"),l=f("react.memo"),c=f("react.lazy")}var p="function"==typeof Symbol&&Symbol.iterator;function d(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r<arguments.length;r++)t+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h={};function v(e,t,r){this.props=e,this.context=t,this.refs=h,this.updater=r||y}function m(){}function b(e,t,r){this.props=e,this.context=t,this.refs=h,this.updater=r||y}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error(d(85));this.updater.enqueueSetState(this,e,t,"setState")},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},m.prototype=v.prototype;var _=b.prototype=new m;_.constructor=b,n(_,v.prototype),_.isPureReactComponent=!0;var w={current:null},g=Object.prototype.hasOwnProperty,k={key:!0,ref:!0,__self:!0,__source:!0};function j(e,t,r){var n,a={},i=null,s=null;if(null!=t)for(n in void 0!==t.ref&&(s=t.ref),void 0!==t.key&&(i=""+t.key),t)g.call(t,n)&&!k.hasOwnProperty(n)&&(a[n]=t[n]);var u=arguments.length-2;if(1===u)a.children=r;else if(1<u){for(var l=Array(u),c=0;c<u;c++)l[c]=arguments[c+2];a.children=l}if(e&&e.defaultProps)for(n in u=e.defaultProps)void 0===a[n]&&(a[n]=u[n]);return{$$typeof:o,type:e,key:i,ref:s,props:a,_owner:w.current}}function O(e){return"object"==typeof e&&null!==e&&e.$$typeof===o}var C=/\/+/g;function E(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function S(e,t,r,n,i){var s=typeof e;"undefined"!==s&&"boolean"!==s||(e=null);var u=!1;if(null===e)u=!0;else switch(s){case"string":case"number":u=!0;break;case"object":switch(e.$$typeof){case o:case a:u=!0}}if(u)return i=i(u=e),e=""===n?"."+E(u,0):n,Array.isArray(i)?(r="",null!=e&&(r=e.replace(C,"$&/")+"/"),S(i,t,r,"",(function(e){return e}))):null!=i&&(O(i)&&(i=function(e,t){return{$$typeof:o,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(i,r+(!i.key||u&&u.key===i.key?"":(""+i.key).replace(C,"$&/")+"/")+e)),t.push(i)),1;if(u=0,n=""===n?".":n+":",Array.isArray(e))for(var l=0;l<e.length;l++){var c=n+E(s=e[l],l);u+=S(s,t,r,c,i)}else if(c=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=p&&e[p]||e["@@iterator"])?e:null}(e),"function"==typeof c)for(e=c.call(e),l=0;!(s=e.next()).done;)u+=S(s=s.value,t,r,c=n+E(s,l++),i);else if("object"===s)throw t=""+e,Error(d(31,"[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t));return u}function P(e,t,r){if(null==e)return e;var n=[],o=0;return S(e,n,"","",(function(e){return t.call(r,e,o++)})),n}function R(e){if(-1===e._status){var t=e._result;t=t(),e._status=0,e._result=t,t.then((function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)}),(function(t){0===e._status&&(e._status=2,e._result=t)}))}if(1===e._status)return e._result;throw e._result}var $={current:null};function x(){var e=$.current;if(null===e)throw Error(d(321));return e}var L={ReactCurrentDispatcher:$,ReactCurrentBatchConfig:{transition:0},ReactCurrentOwner:w,IsSomeRendererActing:{current:!1},assign:n};t.Children={map:P,forEach:function(e,t,r){P(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;return P(e,(function(){t++})),t},toArray:function(e){return P(e,(function(e){return e}))||[]},only:function(e){if(!O(e))throw Error(d(143));return e}},t.Component=v,t.PureComponent=b,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=L,t.cloneElement=function(e,t,r){if(null==e)throw Error(d(267,e));var a=n({},e.props),i=e.key,s=e.ref,u=e._owner;if(null!=t){if(void 0!==t.ref&&(s=t.ref,u=w.current),void 0!==t.key&&(i=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)g.call(t,c)&&!k.hasOwnProperty(c)&&(a[c]=void 0===t[c]&&void 0!==l?l[c]:t[c])}var c=arguments.length-2;if(1===c)a.children=r;else if(1<c){l=Array(c);for(var f=0;f<c;f++)l[f]=arguments[f+2];a.children=l}return{$$typeof:o,type:e.type,key:i,ref:s,props:a,_owner:u}},t.createContext=function(e,t){return void 0===t&&(t=null),(e={$$typeof:s,_calculateChangedBits:t,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:i,_context:e},e.Consumer=e},t.createElement=j,t.createFactory=function(e){var t=j.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:u,render:e}},t.isValidElement=O,t.lazy=function(e){return{$$typeof:c,_payload:{_status:-1,_result:e},_init:R}},t.memo=function(e,t){return{$$typeof:l,type:e,compare:void 0===t?null:t}},t.useCallback=function(e,t){return x().useCallback(e,t)},t.useContext=function(e,t){return x().useContext(e,t)},t.useDebugValue=function(){},t.useEffect=function(e,t){return x().useEffect(e,t)},t.useImperativeHandle=function(e,t,r){return x().useImperativeHandle(e,t,r)},t.useLayoutEffect=function(e,t){return x().useLayoutEffect(e,t)},t.useMemo=function(e,t){return x().useMemo(e,t)},t.useReducer=function(e,t,r){return x().useReducer(e,t,r)},t.useRef=function(e){return x().useRef(e)},t.useState=function(e){return x().useState(e)},t.version="17.0.2"},294:(e,t,r)=>{"use strict";e.exports=r(408)},893:(e,t,r)=>{"use strict";e.exports=r(251)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{default:()=>p});var e=r(294);const t="all",o="^on(.*)";var a=r(262),i=r.n(a);let s=-1;function u(e,t){const r=e.match(t)||["",""];return r[1].charAt(0).toLowerCase()+r[1].slice(1)}var l=r(893);function c(e){return(r,n)=>{Object.keys(e).forEach((a=>{const i=u(a,o);i===r&&e[a](n),i===t&&e[a](r,n)}))}}class f extends e.Component{constructor(t){super(t),this.ref=t.ref||e.createRef(),this.config=function(e){const t={};return Object.keys(e).forEach((r=>{i().has(r)&&(t[r]=e[r])})),{...e.config,...t,isReactComponent:!0}}(t),this.player=null,this.didMountCallback=t.didMountCallback,this.willUnmountCallback=t.willUnmountCallback,this.id=t.id||(s++,`jwplayer-${s}`),this.onHandler=null,this.library=t.library}async componentDidMount(){if(await function(e){if(!window.jwplayer&&!e)throw new Error("jwplayer-react requires either a library prop, or a library script");return window.jwplayer?Promise.resolve():function(e){return new Promise(((t,r)=>{const n=document.createElement("script");n.onload=t,n.onerror=r,n.src=e,document.body.append(n)}))}(e)}(this.library),this.player=this.createPlayer(),this.createEventListeners(),this.didMountCallback){const{player:e,id:t}=this;this.didMountCallback({player:e,id:t})}}shouldComponentUpdate(e){return!(!this.player||this.didOnEventsChange(e)&&(this.updateOnEventListener(e),1))}componentWillUnmount(){if(this.willUnmountCallback){const{player:e,id:t}=this;this.willUnmountCallback({player:e,id:t})}this.player&&(this.player.off(),this.player.remove(),this.player=null)}createPlayer(){const{config:e,ref:t}=this,r={...window.jwDefaults,...e},n=t.current;return window.jwplayer(n.id).setup(r)}didOnEventsChange(e){const t=e=>e.match(o),r=Object.keys(this.props).filter(t).sort(),n=Object.keys(e).filter(t).sort();return n.length!==r.length||n.some(((t,n)=>r[n]!==t||e[t]!==this.props[t]))}createEventListeners(){Object.keys(this.props).forEach((e=>{const t=u(e,"^once(.*)");t&&this.player.once(t,this.props[e])})),this.onHandler=c(this.props),this.player.on(t,this.onHandler)}updateOnEventListener(e){this.onHandler&&this.player.off(t,this.onHandler),this.onHandler=c(e),this.player.on(t,this.onHandler)}render(){return(0,l.jsx)("div",{id:this.id,ref:this.ref})}}const p=f})(),module.exports=n})();