UNPKG

infinity-forge

Version:
47 lines 1.78 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PandaVideo = PandaVideo; exports.usePlayerVideo = usePlayerVideo; var jsx_runtime_1 = require("react/jsx-runtime"); var react_1 = require("react"); var components_1 = require("./components/index.js"); var playerVideoContext = (0, react_1.createContext)({ scriptIsReady: false, videoId: '', onError: function () { }, onEvent: function () { }, videoURL: '', configurations: {} }); function PandaVideo(props) { var _a = (0, react_1.useState)(true), scriptIsReady = _a[0], setScriptIsReady = _a[1]; // useEffect(() => { // if (process.browser && !scriptIsReady && !(window as any)?.PandaPlayer) { // const script = document.createElement('script') // script.src = 'https://player.pandavideo.com.br/api.v2.js' // script.async = true // document.body.appendChild(script) // script.onload = () => { // setScriptIsReady(true) // } // }else { // setScriptIsReady(true) // } // }, []) return ((0, jsx_runtime_1.jsx)(playerVideoContext.Provider, { value: __assign({ scriptIsReady: scriptIsReady }, props), children: (0, jsx_runtime_1.jsx)(components_1.PlayerWrapper, {}) })); } function usePlayerVideo() { return (0, react_1.useContext)(playerVideoContext); } //# sourceMappingURL=player.js.map