@aigamo/nostalgic-diva
Version:
React function components for imperatively controlling embedded players (audio, Niconico, SoundCloud and YouTube) using refs.
40 lines (39 loc) • 1.13 kB
JavaScript
import r, { memo as s, useCallback as a } from "react";
import { L as i, Y as u } from "./index-DzXJDFxB.js";
import { e as c } from "./ensureScriptLoaded-C7IsEn-U.js";
import { P as m } from "./PlayerContainer-BSDtKMGl.js";
const y = "https://www.youtube-nocookie.com", h = s(({ ...t }) => {
const { logger: o } = t;
o.log(i.Debug, "YouTubePlayer");
const n = a(() => new Promise(async (e, w) => {
await c(
"https://www.youtube.com/iframe_api",
o
) ? window.onYouTubeIframeAPIReady = () => {
o.log(i.Debug, "YouTube iframe API ready"), e();
} : e();
}), [o]), l = a(
(e) => Promise.resolve(
new YT.Player(e, {
host: y,
width: "100%",
height: "100%"
})
),
[]
);
return /* @__PURE__ */ r.createElement(
m,
{
...t,
loadScript: n,
playerFactory: l,
controllerFactory: u
},
(e) => /* @__PURE__ */ r.createElement("div", { style: { width: "100%", height: "100%" } }, /* @__PURE__ */ r.createElement("div", { ref: e }))
);
});
export {
h as default
};
//# sourceMappingURL=YouTubePlayer-COrDr2Qf.js.map