react-pro-video-player
Version:
A fully customizable and responsive React video player with fullscreen, captions, playback speed control, advertisement support, DRM solution and modern UI support — perfect for all your professional video needs.
12 lines (11 loc) • 35.9 kB
JavaScript
import e,{useState as r,useRef as t,useCallback as n,useEffect as o}from"react";import a from"hls.js";function i(e,r,t,n){return new(t||(t=Promise))(function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t(function(e){e(r)})).then(i,s)}c((n=n.apply(e,r||[])).next())})}function s(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=r.call(e,a)}catch(e){s=[6,e],n=0}finally{t=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}"function"==typeof SuppressedError&&SuppressedError;var c,l={exports:{}},u={};var f,p={};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/"production"===process.env.NODE_ENV?l.exports=function(){if(c)return u;c=1;var r=e,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function s(e,r,n){var s,c={},l=null,u=null;for(s in void 0!==n&&(l=""+n),void 0!==r.key&&(l=""+r.key),void 0!==r.ref&&(u=r.ref),r)o.call(r,s)&&!i.hasOwnProperty(s)&&(c[s]=r[s]);if(e&&e.defaultProps)for(s in r=e.defaultProps)void 0===c[s]&&(c[s]=r[s]);return{$$typeof:t,type:e,key:l,ref:u,props:c,_owner:a.current}}return u.Fragment=n,u.jsx=s,u.jsxs=s,u}():l.exports=(f||(f=1,"production"!==process.env.NODE_ENV&&function(){var r,t=e,n=Symbol.for("react.element"),o=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),h=Symbol.iterator,g=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];!function(e,r,t){var n=g.ReactDebugCurrentFrame.getStackAddendum();""!==n&&(r+="%s",t=t.concat([n]));var o=t.map(function(e){return String(e)});o.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,o)}("error",e,t)}function x(e){return e.displayName||"Context"}function w(e){if(null==e)return null;if("number"==typeof e.tag&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case a:return"Fragment";case o:return"Portal";case s:return"Profiler";case i:return"StrictMode";case f:return"Suspense";case d:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return x(e)+".Consumer";case c:return x(e._context)+".Provider";case u:return function(e,r,t){var n=e.displayName;if(n)return n;var o=r.displayName||r.name||"";return""!==o?t+"("+o+")":t}(e,e.render,"ForwardRef");case m:var r=e.displayName||null;return null!==r?r:w(e.type)||"Memo";case v:var t=e,n=t._payload,p=t._init;try{return w(p(n))}catch(e){return null}}return null}r=Symbol.for("react.module.reference");var C,j,N,k,E,L,S,_=Object.assign,V=0;function O(){}O.__reactDisabledLog=!0;var T,M=g.ReactCurrentDispatcher;function R(e,r,t){if(void 0===T)try{throw Error()}catch(e){var n=e.stack.trim().match(/\n( *(at )?)/);T=n&&n[1]||""}return"\n"+T+e}var H,P=!1,F="function"==typeof WeakMap?WeakMap:Map;function I(e,r){if(!e||P)return"";var t,n=H.get(e);if(void 0!==n)return n;P=!0;var o,a=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=M.current,M.current=null,function(){if(0===V){C=console.log,j=console.info,N=console.warn,k=console.error,E=console.group,L=console.groupCollapsed,S=console.groupEnd;var e={configurable:!0,enumerable:!0,value:O,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}V++}();try{if(r){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(i,[])}catch(e){t=e}Reflect.construct(e,[],i)}else{try{i.call()}catch(e){t=e}e.call(i.prototype)}}else{try{throw Error()}catch(e){t=e}e()}}catch(r){if(r&&t&&"string"==typeof r.stack){for(var s=r.stack.split("\n"),c=t.stack.split("\n"),l=s.length-1,u=c.length-1;l>=1&&u>=0&&s[l]!==c[u];)u--;for(;l>=1&&u>=0;l--,u--)if(s[l]!==c[u]){if(1!==l||1!==u)do{if(l--,--u<0||s[l]!==c[u]){var f="\n"+s[l].replace(" at new "," at ");return e.displayName&&f.includes("<anonymous>")&&(f=f.replace("<anonymous>",e.displayName)),"function"==typeof e&&H.set(e,f),f}}while(l>=1&&u>=0);break}}}finally{P=!1,M.current=o,function(){if(0===--V){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:_({},e,{value:C}),info:_({},e,{value:j}),warn:_({},e,{value:N}),error:_({},e,{value:k}),group:_({},e,{value:E}),groupCollapsed:_({},e,{value:L}),groupEnd:_({},e,{value:S})})}V<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=a}var p=e?e.displayName||e.name:"",d=p?R(p):"";return"function"==typeof e&&H.set(e,d),d}function Z(e,r,t){if(null==e)return"";if("function"==typeof e)return I(e,!(!(n=e.prototype)||!n.isReactComponent));var n;if("string"==typeof e)return R(e);switch(e){case f:return R("Suspense");case d:return R("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case u:return I(e.render,!1);case m:return Z(e.type,r,t);case v:var o=e,a=o._payload,i=o._init;try{return Z(i(a),r,t)}catch(e){}}return""}H=new F;var D=Object.prototype.hasOwnProperty,A={},$=g.ReactDebugCurrentFrame;function z(e){if(e){var r=e._owner,t=Z(e.type,e._source,r?r.type:null);$.setExtraStackFrame(t)}else $.setExtraStackFrame(null)}var W=Array.isArray;function B(e){return W(e)}function U(e){return""+e}function q(e){if(function(e){try{return U(e),!1}catch(e){return!0}}(e))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),U(e)}var Y,K,J,X=g.ReactCurrentOwner,G={key:!0,ref:!0,__self:!0,__source:!0};function Q(e,r,t,o,a){var i,s={},c=null,l=null;for(i in void 0!==t&&(q(t),c=""+t),function(e){if(D.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return void 0!==e.key}(r)&&(q(r.key),c=""+r.key),function(e){if(D.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return void 0!==e.ref}(r)&&(l=r.ref,function(e,r){if("string"==typeof e.ref&&X.current&&r&&X.current.stateNode!==r){var t=w(X.current.type);J[t]||(b('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',w(X.current.type),e.ref),J[t]=!0)}}(r,a)),r)D.call(r,i)&&!G.hasOwnProperty(i)&&(s[i]=r[i]);if(e&&e.defaultProps){var u=e.defaultProps;for(i in u)void 0===s[i]&&(s[i]=u[i])}if(c||l){var f="function"==typeof e?e.displayName||e.name||"Unknown":e;c&&function(e,r){var t=function(){Y||(Y=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}(s,f),l&&function(e,r){var t=function(){K||(K=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}(s,f)}return function(e,r,t,o,a,i,s){var c={$$typeof:n,type:e,key:r,ref:t,props:s,_owner:i,_store:{}};return Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c}(e,c,l,a,o,X.current,s)}J={};var ee,re=g.ReactCurrentOwner,te=g.ReactDebugCurrentFrame;function ne(e){if(e){var r=e._owner,t=Z(e.type,e._source,r?r.type:null);te.setExtraStackFrame(t)}else te.setExtraStackFrame(null)}function oe(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}function ae(){if(re.current){var e=w(re.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}ee=!1;var ie={};function se(e,r){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var t=function(e){var r=ae();if(!r){var t="string"==typeof e?e:e.displayName||e.name;t&&(r="\n\nCheck the top-level render call using <"+t+">.")}return r}(r);if(!ie[t]){ie[t]=!0;var n="";e&&e._owner&&e._owner!==re.current&&(n=" It was passed a child from "+w(e._owner.type)+"."),ne(e),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),ne(null)}}}function ce(e,r){if("object"==typeof e)if(B(e))for(var t=0;t<e.length;t++){var n=e[t];oe(n)&&se(n,r)}else if(oe(e))e._store&&(e._store.validated=!0);else if(e){var o=function(e){if(null===e||"object"!=typeof e)return null;var r=h&&e[h]||e["@@iterator"];return"function"==typeof r?r:null}(e);if("function"==typeof o&&o!==e.entries)for(var a,i=o.call(e);!(a=i.next()).done;)oe(a.value)&&se(a.value,r)}}function le(e){var r,t=e.type;if(null!=t&&"string"!=typeof t){if("function"==typeof t)r=t.propTypes;else{if("object"!=typeof t||t.$$typeof!==u&&t.$$typeof!==m)return;r=t.propTypes}if(r){var n=w(t);!function(e,r,t,n,o){var a=Function.call.bind(D);for(var i in e)if(a(e,i)){var s=void 0;try{if("function"!=typeof e[i]){var c=Error((n||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw c.name="Invariant Violation",c}s=e[i](r,i,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){s=e}!s||s instanceof Error||(z(o),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,i,typeof s),z(null)),s instanceof Error&&!(s.message in A)&&(A[s.message]=!0,z(o),b("Failed %s type: %s",t,s.message),z(null))}}(r,e.props,"prop",n,e)}else void 0===t.PropTypes||ee||(ee=!0,b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",w(t)||"Unknown"));"function"!=typeof t.getDefaultProps||t.getDefaultProps.isReactClassApproved||b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ue={};function fe(e,t,o,p,h,g){var x=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===s||e===i||e===f||e===d||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===v||e.$$typeof===m||e.$$typeof===c||e.$$typeof===l||e.$$typeof===u||e.$$typeof===r||void 0!==e.getModuleId)}(e);if(!x){var C="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(C+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var j,N=function(e){return void 0!==e?"\n\nCheck your code at "+e.fileName.replace(/^.*[\\\/]/,"")+":"+e.lineNumber+".":""}(h);C+=N||ae(),null===e?j="null":B(e)?j="array":void 0!==e&&e.$$typeof===n?(j="<"+(w(e.type)||"Unknown")+" />",C=" Did you accidentally export a JSX literal instead of a component?"):j=typeof e,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",j,C)}var k=Q(e,t,o,h,g);if(null==k)return k;if(x){var E=t.children;if(void 0!==E)if(p)if(B(E)){for(var L=0;L<E.length;L++)ce(E[L],e);Object.freeze&&Object.freeze(E)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ce(E,e)}if(D.call(t,"key")){var S=w(e),_=Object.keys(t).filter(function(e){return"key"!==e}),V=_.length>0?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}";ue[S+V]||(b('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',V,S,_.length>0?"{"+_.join(": ..., ")+": ...}":"{}",S),ue[S+V]=!0)}return e===a?function(e){for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if("children"!==n&&"key"!==n){ne(e),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),ne(null);break}}null!==e.ref&&(ne(e),b("Invalid attribute `ref` supplied to `React.Fragment`."),ne(null))}(k):le(k),k}var pe=function(e,r,t){return fe(e,r,t,!1)},de=function(e,r,t){return fe(e,r,t,!0)};p.Fragment=a,p.jsx=pe,p.jsxs=de}()),p);var d=l.exports,m=function(){var e=r(null),o=e[0],a=e[1],c=r(!1),l=c[0],u=c[1],f=r(null),p=f[0],d=f[1],m=t(null),v=n(function(e,r){return i(void 0,void 0,void 0,function(){var t,n,o,i,c;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,4,5]),u(!0),d(null),null===(c=m.current)||void 0===c||c.abort(),m.current=new AbortController,[4,fetch("http://localhost:3000/api/videos/".concat(e),{signal:m.current.signal})];case 1:if(!(t=s.sent()).ok)throw new Error("Video not found: ".concat(t.status));return[4,t.json()];case 2:return n=s.sent(),o="http://localhost:3000/api/videos/stream/".concat(e),r&&"Auto"!==r&&(o+="?quality=".concat(r)),a(o),console.log("Started streaming video: ".concat(n.title," at ").concat(r||"Auto"," quality")),[3,5];case 3:return(i=s.sent())instanceof Error&&"AbortError"===i.name?[2]:(d(i instanceof Error?i.message:"Failed to stream video"),console.error("Error streaming video:",i),[3,5]);case 4:return u(!1),[7];case 5:return[2]}})})},[]),y=n(function(){var e;null===(e=m.current)||void 0===e||e.abort(),m.current=null,a(null),u(!1),d(null)},[]);return{videoUrl:o,loading:l,error:p,startStream:v,stopStream:y}};const v=({color:r="currentColor",size:t=24,className:n,...o})=>e.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,fill:r,...o,className:"remixicon "+(n||"")},e.createElement("path",{d:"M11.9997 10.5865L16.9495 5.63672L18.3637 7.05093L13.4139 12.0007L18.3637 16.9504L16.9495 18.3646L11.9997 13.4149L7.04996 18.3646L5.63574 16.9504L10.5855 12.0007L5.63574 7.05093L7.04996 5.63672L11.9997 10.5865Z"})),y=({color:r="currentColor",size:t=24,className:n,...o})=>e.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,fill:r,...o,className:"remixicon "+(n||"")},e.createElement("path",{d:"M18 7H22V9H16V3H18V7ZM8 9H2V7H6V3H8V9ZM18 17V21H16V15H22V17H18ZM8 15V21H6V17H2V15H8Z"})),h=({color:r="currentColor",size:t=24,className:n,...o})=>e.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,fill:r,...o,className:"remixicon "+(n||"")},e.createElement("path",{d:"M8 3V5H4V9H2V3H8ZM2 21V15H4V19H8V21H2ZM22 21H16V19H20V15H22V21ZM22 9H20V5H16V3H22V9Z"})),g=({color:r="currentColor",size:t=24,className:n,...o})=>e.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,fill:r,...o,className:"remixicon "+(n||"")},e.createElement("path",{d:"M6 5H8V19H6V5ZM16 5H18V19H16V5Z"})),b=({color:r="currentColor",size:t=24,className:n,...o})=>e.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,fill:r,...o,className:"remixicon "+(n||"")},e.createElement("path",{d:"M16.3944 12.0001L10 7.7371V16.263L16.3944 12.0001ZM19.376 12.4161L8.77735 19.4818C8.54759 19.635 8.23715 19.5729 8.08397 19.3432C8.02922 19.261 8 19.1645 8 19.0658V4.93433C8 4.65818 8.22386 4.43433 8.5 4.43433C8.59871 4.43433 8.69522 4.46355 8.77735 4.5183L19.376 11.584C19.6057 11.7372 19.6678 12.0477 19.5146 12.2774C19.478 12.3323 19.4309 12.3795 19.376 12.4161Z"})),x=({color:r="currentColor",size:t=24,className:n,...o})=>e.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,fill:r,...o,className:"remixicon "+(n||"")},e.createElement("path",{d:"M3.33946 17.0002C2.90721 16.2515 2.58277 15.4702 2.36133 14.6741C3.3338 14.1779 3.99972 13.1668 3.99972 12.0002C3.99972 10.8345 3.3348 9.824 2.36353 9.32741C2.81025 7.71651 3.65857 6.21627 4.86474 4.99001C5.7807 5.58416 6.98935 5.65534 7.99972 5.072C9.01009 4.48866 9.55277 3.40635 9.4962 2.31604C11.1613 1.8846 12.8847 1.90004 14.5031 2.31862C14.4475 3.40806 14.9901 4.48912 15.9997 5.072C17.0101 5.65532 18.2187 5.58416 19.1346 4.99007C19.7133 5.57986 20.2277 6.25151 20.66 7.00021C21.0922 7.7489 21.4167 8.53025 21.6381 9.32628C20.6656 9.82247 19.9997 10.8336 19.9997 12.0002C19.9997 13.166 20.6646 14.1764 21.6359 14.673C21.1892 16.2839 20.3409 17.7841 19.1347 19.0104C18.2187 18.4163 17.0101 18.3451 15.9997 18.9284C14.9893 19.5117 14.4467 20.5941 14.5032 21.6844C12.8382 22.1158 11.1148 22.1004 9.49633 21.6818C9.55191 20.5923 9.00929 19.5113 7.99972 18.9284C6.98938 18.3451 5.78079 18.4162 4.86484 19.0103C4.28617 18.4205 3.77172 17.7489 3.33946 17.0002ZM8.99972 17.1964C10.0911 17.8265 10.8749 18.8227 11.2503 19.9659C11.7486 20.0133 12.2502 20.014 12.7486 19.9675C13.1238 18.8237 13.9078 17.8268 14.9997 17.1964C16.0916 16.5659 17.347 16.3855 18.5252 16.6324C18.8146 16.224 19.0648 15.7892 19.2729 15.334C18.4706 14.4373 17.9997 13.2604 17.9997 12.0002C17.9997 10.74 18.4706 9.5632 19.2729 8.6665C19.1688 8.4405 19.0538 8.21822 18.9279 8.00021C18.802 7.78219 18.667 7.57148 18.5233 7.36842C17.3457 7.61476 16.0911 7.43414 14.9997 6.80405C13.9083 6.17395 13.1246 5.17768 12.7491 4.03455C12.2509 3.98714 11.7492 3.98646 11.2509 4.03292C10.8756 5.17671 10.0916 6.17364 8.99972 6.80405C7.9078 7.43447 6.65245 7.61494 5.47428 7.36803C5.18485 7.77641 4.93463 8.21117 4.72656 8.66637C5.52881 9.56311 5.99972 10.74 5.99972 12.0002C5.99972 13.2604 5.52883 14.4372 4.72656 15.3339C4.83067 15.5599 4.94564 15.7822 5.07152 16.0002C5.19739 16.2182 5.3324 16.4289 5.47612 16.632C6.65377 16.3857 7.90838 16.5663 8.99972 17.1964ZM11.9997 15.0002C10.3429 15.0002 8.99972 13.6571 8.99972 12.0002C8.99972 10.3434 10.3429 9.00021 11.9997 9.00021C13.6566 9.00021 14.9997 10.3434 14.9997 12.0002C14.9997 13.6571 13.6566 15.0002 11.9997 15.0002ZM11.9997 13.0002C12.552 13.0002 12.9997 12.5525 12.9997 12.0002C12.9997 11.4479 12.552 11.0002 11.9997 11.0002C11.4474 11.0002 10.9997 11.4479 10.9997 12.0002C10.9997 12.5525 11.4474 13.0002 11.9997 13.0002Z"})),w=({color:r="currentColor",size:t=24,className:n,...o})=>e.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,fill:r,...o,className:"remixicon "+(n||"")},e.createElement("path",{d:"M12 13.3334L2.77735 19.4818C2.54759 19.635 2.23715 19.5729 2.08397 19.3432C2.02922 19.261 2 19.1645 2 19.0658V4.93433C2 4.65818 2.22386 4.43433 2.5 4.43433C2.59871 4.43433 2.69522 4.46355 2.77735 4.5183L12 10.6667V4.93433C12 4.65818 12.2239 4.43433 12.5 4.43433C12.5987 4.43433 12.6952 4.46355 12.7774 4.5183L23.376 11.584C23.6057 11.7372 23.6678 12.0477 23.5146 12.2774C23.478 12.3323 23.4309 12.3795 23.376 12.4161L12.7774 19.4818C12.5476 19.635 12.2372 19.5729 12.084 19.3432C12.0292 19.261 12 19.1645 12 19.0658V13.3334ZM10.3944 12.0001L4 7.7371V16.263L10.3944 12.0001ZM14 7.7371V16.263L20.3944 12.0001L14 7.7371Z"})),C=({color:r="currentColor",size:t=24,className:n,...o})=>e.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,fill:r,...o,className:"remixicon "+(n||"")},e.createElement("path",{d:"M9.03189 11.9999L6 9.85977V14.1401L9.03189 11.9999ZM4.78834 17.4434C4.70398 17.503 4.60326 17.535 4.5 17.535C4.22386 17.535 4 17.3111 4 17.035V6.96488C4 6.86163 4.03197 6.7609 4.09152 6.67654C4.25076 6.45094 4.56274 6.39715 4.78834 6.5564L11.9213 11.5914C11.9679 11.6243 12.0086 11.665 12.0415 11.7116C12.2007 11.9372 12.1469 12.2492 11.9213 12.4084L4.78834 17.4434ZM15 14.1401L18.0319 11.9999L15 9.85977V14.1401ZM13 6.96488C13 6.86163 13.032 6.7609 13.0915 6.67654C13.2508 6.45094 13.5627 6.39715 13.7883 6.5564L20.9213 11.5914C20.9679 11.6243 21.0086 11.665 21.0415 11.7116C21.2007 11.9372 21.1469 12.2492 20.9213 12.4084L13.7883 17.4434C13.704 17.503 13.6033 17.535 13.5 17.535C13.2239 17.535 13 17.3111 13 17.035V6.96488Z"})),j=({color:r="currentColor",size:t=24,className:n,...o})=>e.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,fill:r,...o,className:"remixicon "+(n||"")},e.createElement("path",{d:"M10 7.22056L6.60282 10.0001H3V14.0001H6.60282L10 16.7796V7.22056ZM5.88889 16.0001H2C1.44772 16.0001 1 15.5524 1 15.0001V9.00007C1 8.44778 1.44772 8.00007 2 8.00007H5.88889L11.1834 3.66821C11.3971 3.49335 11.7121 3.52485 11.887 3.73857C11.9601 3.8279 12 3.93977 12 4.05519V19.9449C12 20.2211 11.7761 20.4449 11.5 20.4449C11.3846 20.4449 11.2727 20.405 11.1834 20.3319L5.88889 16.0001ZM20.4142 12.0001L23.9497 15.5356L22.5355 16.9498L19 13.4143L15.4645 16.9498L14.0503 15.5356L17.5858 12.0001L14.0503 8.46454L15.4645 7.05032L19 10.5859L22.5355 7.05032L23.9497 8.46454L20.4142 12.0001Z"})),N=({color:r="currentColor",size:t=24,className:n,...o})=>e.createElement("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:t,height:t,fill:r,...o,className:"remixicon "+(n||"")},e.createElement("path",{d:"M6.60282 10.0001L10 7.22056V16.7796L6.60282 14.0001H3V10.0001H6.60282ZM2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"}));var k={justifyContent:"flex-start"},E=function(e){return{width:e?"95%":"97%",margin:"0 auto"}},L={minWidth:48,textAlign:"left",overflow:"hidden",textOverflow:"ellipsis"},S={minWidth:48,textAlign:"right",overflow:"hidden",textOverflow:"ellipsis"},_={position:"relative",display:"inline-block"},V=function(e){if(!isFinite(e))return"0:00";var r=Math.floor(e/60),t=Math.floor(e%60);return"".concat(r,":").concat(t.toString().padStart(2,"0"))},O=function(e){var c=e.videoId;e.title;var l=e.hlsUrl,u=e.defaultVideoUrl,f=e.onClose;e.isCapturingScreenAllowed,e.isAdvertisementAllowed,e.advertisementSponserName,e.advertisementImage,e.advertisementVideo,e.advertisementUrl,e.advertisementImageDuration,e.advertisementVideoDuration;var p=t(null),O=t(null),T=m(),M=T.videoUrl,R=T.loading,H=T.error,P=T.startStream,F=T.stopStream,I=r(!1),Z=I[0],D=I[1],A=r(0),$=A[0],z=A[1],W=r(0),B=W[0],U=W[1],q=r(1),Y=q[0],K=q[1],J=r(!0),X=J[0],G=J[1],Q=r(0);Q[0];var ee=Q[1],re=r(!1),te=re[0],ne=re[1],oe=r(null),ae=oe[0],ie=oe[1],se=r(!1),ce=se[0],le=se[1],ue=r(null),fe=ue[0],pe=ue[1],de=r(!1),me=de[0],ve=de[1],ye=r("Auto"),he=ye[0],ge=ye[1],be=t(null),xe=t(null),we=r(!1),Ce=we[0],je=we[1],Ne=r("Hindi"),ke=Ne[0],Ee=Ne[1],Le=r(1),Se=Le[0];Le[1];var _e=t(null),Ve=t(null),Oe=r(!1),Te=Oe[0],Me=Oe[1],Re=t(null),He=t(null);o(function(){var e=document.body.style.overflow;return document.body.style.overflow="hidden",function(){document.body.style.overflow=e}},[]),o(function(){if(!l&&!u)return P(c),function(){F()}},[c,P,F,l,u]),o(function(){var e=p.current;if(e){var r=function(){return z(e.currentTime)},t=function(){if(p.current){var e=p.current.duration;isFinite(e)&&e>0&&U(e)}},n=function(){return D(!0)},o=function(){return D(!1)},a=function(){if(e.buffered.length>0){var r=e.buffered.end(e.buffered.length-1)/e.duration*100;ee(r)}},i=function(r){console.error("Video error:",r),console.error("Video error details:",e.error)},s=function(){var e=!!document.fullscreenElement;(le(e),e)||/Mobi/i.test(navigator.userAgent)&&screen.orientation&&"unlock"in screen.orientation&&screen.orientation.unlock()};return e.addEventListener("timeupdate",r),e.addEventListener("loadedmetadata",t),e.addEventListener("durationchange",t),e.addEventListener("play",n),e.addEventListener("pause",o),e.addEventListener("progress",a),e.addEventListener("error",i),document.addEventListener("fullscreenchange",s),t(),function(){e.removeEventListener("timeupdate",r),e.removeEventListener("loadedmetadata",t),e.removeEventListener("durationchange",t),e.removeEventListener("play",n),e.removeEventListener("pause",o),e.removeEventListener("progress",a),e.removeEventListener("error",i),document.removeEventListener("fullscreenchange",s)}}},[M]),o(function(){if(fe){var e=setTimeout(function(){pe(null)},300);return function(){return clearTimeout(e)}}},[fe]),o(function(){if(be.current){var e=100*(te?0:Y);be.current.style.setProperty("--volume-percent","".concat(e,"%"))}},[Y,te]),o(function(){if(xe.current&&B>0){var e=$/B*100;xe.current.style.setProperty("--progress-percent","".concat(e,"%"))}},[$,B]),o(function(){if(l&&p.current){var e=null;return a.isSupported()?((e=new a).loadSource(l),e.attachMedia(p.current)):p.current.canPlayType("application/vnd.apple.mpegurl")&&(p.current.src=l),function(){e&&e.destroy()}}},[l]);var Pe=n(function(){G(!0),ae&&clearTimeout(ae),ie(setTimeout(function(){return G(!1)},3e3))},[ae]),Fe=n(function(){var e=p.current;e&&(Z?e.pause():e.play(),pe(Z?"pause":"play"))},[Z]),Ie=n(function(){var e=p.current;e&&(e.currentTime=Math.max(0,e.currentTime-10))},[]),Ze=n(function(){var e=p.current;e&&(e.currentTime=Math.min(e.duration,e.currentTime+10))},[]),De=n(function(e){var r=p.current;if(r){var t=parseFloat(e.target.value);r.currentTime=t,z(t)}},[]),Ae=n(function(e){var r=p.current;if(r){var t=parseFloat(e.target.value);r.volume=t,K(t),ne(0===t),be.current&&setTimeout(function(){return be.current&&be.current.blur()},150)}},[]),$e=n(function(){var e=p.current;e&&(e.muted=!te,ne(!te),te||0!==e.volume||(e.volume=.5,K(.5)))},[te]),ze=n(function(e){if(p.current&&e!==he){var r=p.current.currentTime,t=!p.current.paused;ge(e),ve(!1),P(c,e);p.current.addEventListener("loadeddata",function(){p.current&&(p.current.currentTime=r,t&&p.current.play())},{once:!0})}else ve(!1)},[he,P,c]),We=n(function(){return i(void 0,void 0,void 0,function(){var e,r,t;return s(this,function(n){switch(n.label){case 0:if(!(e=O.current))return[2];n.label=1;case 1:return n.trys.push([1,10,,11]),document.fullscreenElement?[3,7]:[4,e.requestFullscreen()];case 2:if(n.sent(),!(/Mobi/i.test(navigator.userAgent)&&screen.orientation&&"lock"in screen.orientation))return[3,6];n.label=3;case 3:return n.trys.push([3,5,,6]),[4,screen.orientation.lock("landscape")];case 4:return n.sent(),[3,6];case 5:return r=n.sent(),console.warn("Could not lock screen orientation:",r),[3,6];case 6:return[3,9];case 7:return[4,document.exitFullscreen()];case 8:n.sent(),n.label=9;case 9:return[3,11];case 10:return t=n.sent(),console.error("Fullscreen request failed:",t),[3,11];case 11:return[2]}})})},[]),Be=function(){p.current&&!p.current.paused&&(z(p.current.currentTime),_e.current=requestAnimationFrame(Be))};return o(function(){return Z?_e.current=requestAnimationFrame(Be):_e.current&&(cancelAnimationFrame(_e.current),_e.current=null),function(){_e.current&&cancelAnimationFrame(_e.current)}},[Z]),o(function(){if(me||Te)return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)};function e(e){He.current&&!He.current.contains(e.target)&&(ve(!1),Me(!1))}},[me,Te]),R?d.jsx("div",{className:"loading-overlay",children:d.jsxs("div",{className:"loading-content",children:[d.jsx("div",{className:"loading-spinner"}),d.jsx("p",{className:"loading-text",children:"Loading video..."}),d.jsx("div",{className:"loading-progress-container",children:d.jsx("div",{className:"loading-progress-bar",style:{width:"100%"}})})]})}):H?d.jsx("div",{className:"error-overlay",children:d.jsxs("div",{className:"error-content",children:[d.jsx("div",{className:"error-icon",children:"⚠️"}),d.jsx("p",{className:"error-title",children:"Error loading video"}),d.jsx("p",{className:"error-message",children:H}),d.jsx("button",{onClick:function(){return P(c)},className:"error-button",children:"Retry"}),f&&d.jsx("button",{onClick:f,className:"error-button secondary",children:"Close"})]})}):d.jsx("div",{className:"video-player-overlay",children:d.jsxs("div",{ref:O,className:"video-player-container ".concat(ce?"fullscreen":"not-fullscreen"),onMouseMove:Pe,onMouseLeave:function(){ae&&clearTimeout(ae),G(!1)},children:[!ce&&d.jsx("button",{onClick:f,className:"close-button","aria-label":"Close",children:d.jsx(v,{className:"close-button-icon"})}),d.jsxs("div",{className:"video-container",children:[d.jsx("video",{ref:p,src:l?void 0:u||M||void 0,className:"video-element ".concat(ce?"fullscreen":"not-fullscreen"),onClick:Fe,onDoubleClick:We,crossOrigin:"anonymous",preload:"metadata",tabIndex:0}),d.jsx("div",{className:"playback-feedback ".concat(fe?"visible":"hidden"),children:d.jsxs("div",{className:"playback-feedback-icon",children:["play"===fe&&d.jsx(b,{className:"playback-icon"}),"pause"===fe&&d.jsx(g,{className:"playback-icon"})]})}),d.jsxs("div",{className:"controls-overlay ".concat(X||!Z?"visible":"hidden"),children:[d.jsxs("div",{className:"controls-row",style:k,children:[d.jsx("button",{onClick:Fe,className:"control-button play-pause-button","aria-label":Z?"Pause":"Play",children:Z?d.jsx(g,{className:"control-icon"}):d.jsx(b,{className:"control-icon"})}),d.jsx("button",{onClick:Ie,className:"control-button","aria-label":"Rewind 10 seconds",children:d.jsx(C,{className:"control-icon"})}),d.jsx("button",{onClick:Ze,className:"control-button","aria-label":"Fast-forward 10 seconds",children:d.jsx(w,{className:"control-icon"})}),d.jsxs("div",{className:"volume-control-group",style:{display:"flex",alignItems:"center",minWidth:0},children:[d.jsx("button",{onClick:$e,className:"control-button","aria-label":te?"Unmute":"Mute",children:te||0===Y?d.jsx(j,{className:"control-icon"}):d.jsx(N,{className:"control-icon"})}),d.jsx("div",{className:"volume-slider-container",children:d.jsx("input",{ref:be,type:"range",min:"0",max:"1",step:"0.01",value:te?0:Y,onChange:Ae,className:"volume-slider","aria-label":"Volume"})})]}),d.jsx("div",{style:{flex:1}}),d.jsxs("div",{className:"settings-button-wrapper",style:_,children:[d.jsx("button",{onClick:function(){return ve(!me)},className:"control-button","aria-label":"Settings",children:d.jsx(x,{className:"control-icon"})}),me&&d.jsxs("div",{className:"settings-menu",ref:He,children:[d.jsxs("div",{className:"settings-row",style:{padding:"1rem 0"},children:[d.jsx("span",{children:"Autoplay"}),d.jsxs("label",{className:"switch",children:[d.jsx("input",{type:"checkbox",checked:Ce,onChange:function(){return je(function(e){return!e})}}),d.jsx("span",{className:"slider"})]})]}),d.jsxs("div",{className:"settings-row".concat(Te?" quality-open":""),style:{padding:"1rem 0",position:"relative"},children:[d.jsx("span",{children:"Audio"}),d.jsxs("span",{ref:Re,tabIndex:0,style:{color:"#fb923c",fontWeight:600,cursor:"pointer",display:"inline-flex",alignItems:"center"},onClick:function(){return Me(function(e){return!e})},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||Me(function(e){return!e})},"aria-haspopup":"true","aria-expanded":Te,"aria-label":"Select audio language",children:[ke,d.jsx("span",{className:"caret",style:{marginLeft:8,fontSize:"1.1em",color:"#fbbf24",transition:"transform 0.2s",transform:Te?"rotate(-180deg)":void 0},children:"▼"}),Te&&d.jsx("div",{className:"settings-submenu",style:{left:"80px",top:"auto",bottom:"25px",marginTop:0,marginBottom:8,minWidth:140,zIndex:110},children:["Hindi","English","Spanish"].map(function(e){return d.jsx("button",{onClick:function(){Ee(e),Me(!1)},className:ke===e?"active":"",tabIndex:0,children:e},e)})})]})]}),d.jsxs("div",{className:"settings-row",style:{padding:"1rem 0",position:"relative"},children:[d.jsx("span",{children:"Quality"}),d.jsxs("span",{ref:Ve,tabIndex:0,style:{color:"#fb923c",fontWeight:600,cursor:"pointer",display:"inline-flex",alignItems:"center"},onClick:function(){return ve(function(e){return!e})},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||ve(function(e){return!e})},"aria-haspopup":"true","aria-expanded":me,"aria-label":"Select video quality",children:[he,"1080p"===he&&d.jsx("span",{className:"hd-badge",children:" HD"}),d.jsx("span",{className:"caret",style:{marginLeft:8,fontSize:"1.1em",color:"#fbbf24",transition:"transform 0.2s",transform:me?"rotate(-180deg)":void 0},children:"▼"}),me&&d.jsx("div",{className:"settings-submenu",style:{left:"80px",top:"auto",bottom:"25px",marginTop:0,marginBottom:8,minWidth:140,zIndex:110},children:["Auto","1080p","720p","480p"].map(function(e){return d.jsxs("button",{onClick:function(){ze(e),ve(!1)},className:he===e?"active":"",tabIndex:0,children:[e,"1080p"===e&&d.jsx("span",{className:"hd-badge",children:" HD"})]},e)})})]})]}),d.jsxs("div",{className:"settings-row",style:{padding:"1rem 0"},children:[d.jsx("span",{children:"Playback Speed"}),d.jsxs("span",{children:[Se,"x"]})]})]})]}),d.jsx("button",{onClick:We,className:"control-button","aria-label":ce?"Exit Fullscreen":"Enter Fullscreen",children:ce?d.jsx(y,{className:"control-icon"}):d.jsx(h,{className:"control-icon"})})]}),d.jsxs("div",{className:"seekbar-row",style:E(ce),children:[d.jsx("span",{className:"seekbar-time",style:L,children:V($)}),d.jsx("input",{ref:xe,type:"range",min:"0",max:B||100,value:$,onChange:De,className:"seek-slider","aria-label":"Seek",style:{flex:1,minWidth:0}}),d.jsx("span",{className:"seekbar-time",style:S,children:V(B)})]})]})]})]})})};export{O as VideoPlayer,O as default,m as useVideoStream};
//# sourceMappingURL=index.esm.js.map