UNPKG

@hakit/components

Version:
62 lines (61 loc) 2.33 kB
import { a as E, j as f } from "../../../../emotion-react-jsx-runtime.browser.esm-BErL7L7Y.js"; import { c as h } from "../../../../emotion-styled-base.browser.esm-Dyg8Y4aq.js"; import { forwardRef as g, useRef as L, useImperativeHandle as N, useCallback as _, useEffect as b } from "react"; import { localize as P } from "@hakit/core"; function R() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; } const w = /* @__PURE__ */ h("video", process.env.NODE_ENV === "production" ? { target: "e19y1x090" } : { target: "e19y1x090", label: "Video" })(process.env.NODE_ENV === "production" ? { name: "1082qq3", styles: "display:block;width:100%" } : { name: "1082qq3", styles: "display:block;width:100%", toString: R }), I = g(({ src: v, type: u, onVideoStateChange: a, ...y }, m) => { const n = L(null); N(m, () => n.current); const t = _((e) => { a && a(e); }, [a]); return b(() => { const e = n.current, r = () => { t("canplay"); }, s = () => { t("canplaythrough"); }, o = () => { t("waiting"); }, d = () => { t("stalled"); }, i = () => { t("loadeddata"); }, l = () => { t("play"); }, c = () => { t("playing"); }, p = () => { t("pause"); }; return e && (e.addEventListener("canplay", r), e.addEventListener("canplaythrough", s), e.addEventListener("waiting", o), e.addEventListener("stalled", d), e.addEventListener("loadeddata", i), e.addEventListener("playing", c), e.addEventListener("play", l), e.addEventListener("pause", p)), () => { e && (e.removeEventListener("canplay", r), e.removeEventListener("canplaythrough", s), e.removeEventListener("waiting", o), e.removeEventListener("stalled", d), e.removeEventListener("loadeddata", i), e.removeEventListener("playing", c), e.removeEventListener("play", l), e.removeEventListener("pause", p)); }; }, [t]), /* @__PURE__ */ E(w, { ref: n, ...y, children: [ /* @__PURE__ */ f("source", { src: v, type: u }), P("fields.format.description") ] }); }); I.displayName = "VideoPlayer"; export { I as VideoPlayer }; //# sourceMappingURL=index.js.map