UNPKG

@aigamo/nostalgic-diva

Version:

React function components for imperatively controlling embedded players (audio, Niconico, SoundCloud and YouTube) using refs.

66 lines (65 loc) 1.72 kB
import t, { memo as m, useCallback as l } from "react"; import { L as y, D as s } from "./index-DzXJDFxB.js"; import { e as g } from "./ensureScriptLoaded-C7IsEn-U.js"; import { P as u } from "./PlayerContainer-BSDtKMGl.js"; const v = m( ({ options: e, ...o }) => { const { logger: r } = o; r.log(y.Debug, "DailymotionPlayer"); const i = l(async () => { await g("https://api.dmcdn.net/all.js", r); }, [r]), d = l( (a, n) => Promise.resolve( new DM.player(a, { video: n, width: "100%", height: "100%", events: { apiready: () => { e?.onLoaded?.({ id: n }); }, seeked: () => { e?.onTimeUpdate?.({ duration: 0, percent: 0, seconds: 0 }); }, video_end: () => { e?.onEnded?.(); }, durationchange: () => { }, pause: () => { e?.onPause?.(); }, playing: () => { e?.onPlay?.(); }, waiting: () => { }, error: (c) => { e?.onError?.(c); } } }) ), [e] ); return /* @__PURE__ */ t.createElement( u, { ...o, options: e, loadScript: i, playerFactory: d, controllerFactory: s }, (a) => /* @__PURE__ */ t.createElement("div", { style: { width: "100%", height: "100%" } }, /* @__PURE__ */ t.createElement("div", { ref: a })) ); } ); export { v as default }; //# sourceMappingURL=DailymotionPlayer-DetFPu4s.js.map