|
| 1 | +import { g as getDefaultExportFromCjs, u as utils, p as patterns } from "./kk-adapt-export-9sEo3eKk.js"; |
| 2 | +import React__default from "react"; |
| 3 | +function _mergeNamespaces(n, m) { |
| 4 | + for (var i = 0; i < m.length; i++) { |
| 5 | + const e = m[i]; |
| 6 | + if (typeof e !== "string" && !Array.isArray(e)) { |
| 7 | + for (const k in e) { |
| 8 | + if (k !== "default" && !(k in n)) { |
| 9 | + const d = Object.getOwnPropertyDescriptor(e, k); |
| 10 | + if (d) { |
| 11 | + Object.defineProperty(n, k, d.get ? d : { |
| 12 | + enumerable: true, |
| 13 | + get: () => e[k] |
| 14 | + }); |
| 15 | + } |
| 16 | + } |
| 17 | + } |
| 18 | + } |
| 19 | + } |
| 20 | + return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" })); |
| 21 | +} |
| 22 | +var __create = Object.create; |
| 23 | +var __defProp = Object.defineProperty; |
| 24 | +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
| 25 | +var __getOwnPropNames = Object.getOwnPropertyNames; |
| 26 | +var __getProtoOf = Object.getPrototypeOf; |
| 27 | +var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 28 | +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; |
| 29 | +var __export = (target, all) => { |
| 30 | + for (var name in all) |
| 31 | + __defProp(target, name, { get: all[name], enumerable: true }); |
| 32 | +}; |
| 33 | +var __copyProps = (to, from, except, desc) => { |
| 34 | + if (from && typeof from === "object" || typeof from === "function") { |
| 35 | + for (let key of __getOwnPropNames(from)) |
| 36 | + if (!__hasOwnProp.call(to, key) && key !== except) |
| 37 | + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
| 38 | + } |
| 39 | + return to; |
| 40 | +}; |
| 41 | +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
| 42 | + // If the importer is in node compatibility mode or this is not an ESM |
| 43 | + // file that has been converted to a CommonJS file using a Babel- |
| 44 | + // compatible transform (i.e. "__esModule" has not been set), then set |
| 45 | + // "default" to the CommonJS "module.exports" for node compatibility. |
| 46 | + !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
| 47 | + mod |
| 48 | +)); |
| 49 | +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
| 50 | +var __publicField = (obj, key, value) => { |
| 51 | + __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); |
| 52 | + return value; |
| 53 | +}; |
| 54 | +var DailyMotion_exports = {}; |
| 55 | +__export(DailyMotion_exports, { |
| 56 | + default: () => DailyMotion |
| 57 | +}); |
| 58 | +var DailyMotion_1 = __toCommonJS(DailyMotion_exports); |
| 59 | +var import_react2 = __toESM(React__default); |
| 60 | +var import_utils = utils; |
| 61 | +var import_patterns = patterns; |
| 62 | +const SDK_URL = "https://api.dmcdn.net/all.js"; |
| 63 | +const SDK_GLOBAL = "DM"; |
| 64 | +const SDK_GLOBAL_READY = "dmAsyncInit"; |
| 65 | +class DailyMotion extends import_react2.Component { |
| 66 | + constructor() { |
| 67 | + super(...arguments); |
| 68 | + __publicField(this, "callPlayer", import_utils.callPlayer); |
| 69 | + __publicField(this, "onDurationChange", () => { |
| 70 | + const duration = this.getDuration(); |
| 71 | + this.props.onDuration(duration); |
| 72 | + }); |
| 73 | + __publicField(this, "mute", () => { |
| 74 | + this.callPlayer("setMuted", true); |
| 75 | + }); |
| 76 | + __publicField(this, "unmute", () => { |
| 77 | + this.callPlayer("setMuted", false); |
| 78 | + }); |
| 79 | + __publicField(this, "ref", (container) => { |
| 80 | + this.container = container; |
| 81 | + }); |
| 82 | + } |
| 83 | + componentDidMount() { |
| 84 | + this.props.onMount && this.props.onMount(this); |
| 85 | + } |
| 86 | + load(url) { |
| 87 | + const { controls, config, onError, playing } = this.props; |
| 88 | + const [, id] = url.match(import_patterns.MATCH_URL_DAILYMOTION); |
| 89 | + if (this.player) { |
| 90 | + this.player.load(id, { |
| 91 | + start: (0, import_utils.parseStartTime)(url), |
| 92 | + autoplay: playing |
| 93 | + }); |
| 94 | + return; |
| 95 | + } |
| 96 | + (0, import_utils.getSDK)(SDK_URL, SDK_GLOBAL, SDK_GLOBAL_READY, (DM) => DM.player).then((DM) => { |
| 97 | + if (!this.container) |
| 98 | + return; |
| 99 | + const Player = DM.player; |
| 100 | + this.player = new Player(this.container, { |
| 101 | + width: "100%", |
| 102 | + height: "100%", |
| 103 | + video: id, |
| 104 | + params: { |
| 105 | + controls, |
| 106 | + autoplay: this.props.playing, |
| 107 | + mute: this.props.muted, |
| 108 | + start: (0, import_utils.parseStartTime)(url), |
| 109 | + origin: window.location.origin, |
| 110 | + ...config.params |
| 111 | + }, |
| 112 | + events: { |
| 113 | + apiready: this.props.onReady, |
| 114 | + seeked: () => this.props.onSeek(this.player.currentTime), |
| 115 | + video_end: this.props.onEnded, |
| 116 | + durationchange: this.onDurationChange, |
| 117 | + pause: this.props.onPause, |
| 118 | + playing: this.props.onPlay, |
| 119 | + waiting: this.props.onBuffer, |
| 120 | + error: (event) => onError(event) |
| 121 | + } |
| 122 | + }); |
| 123 | + }, onError); |
| 124 | + } |
| 125 | + play() { |
| 126 | + this.callPlayer("play"); |
| 127 | + } |
| 128 | + pause() { |
| 129 | + this.callPlayer("pause"); |
| 130 | + } |
| 131 | + stop() { |
| 132 | + } |
| 133 | + seekTo(seconds, keepPlaying = true) { |
| 134 | + this.callPlayer("seek", seconds); |
| 135 | + if (!keepPlaying) { |
| 136 | + this.pause(); |
| 137 | + } |
| 138 | + } |
| 139 | + setVolume(fraction) { |
| 140 | + this.callPlayer("setVolume", fraction); |
| 141 | + } |
| 142 | + getDuration() { |
| 143 | + return this.player.duration || null; |
| 144 | + } |
| 145 | + getCurrentTime() { |
| 146 | + return this.player.currentTime; |
| 147 | + } |
| 148 | + getSecondsLoaded() { |
| 149 | + return this.player.bufferedTime; |
| 150 | + } |
| 151 | + render() { |
| 152 | + const { display } = this.props; |
| 153 | + const style = { |
| 154 | + width: "100%", |
| 155 | + height: "100%", |
| 156 | + display |
| 157 | + }; |
| 158 | + return /* @__PURE__ */ import_react2.default.createElement("div", { style }, /* @__PURE__ */ import_react2.default.createElement("div", { ref: this.ref })); |
| 159 | + } |
| 160 | +} |
| 161 | +__publicField(DailyMotion, "displayName", "DailyMotion"); |
| 162 | +__publicField(DailyMotion, "canPlay", import_patterns.canPlay.dailymotion); |
| 163 | +__publicField(DailyMotion, "loopOnEnded", true); |
| 164 | +const DailyMotion$1 = /* @__PURE__ */ getDefaultExportFromCjs(DailyMotion_1); |
| 165 | +const DailyMotion$2 = /* @__PURE__ */ _mergeNamespaces({ |
| 166 | + __proto__: null, |
| 167 | + default: DailyMotion$1 |
| 168 | +}, [DailyMotion_1]); |
| 169 | +export { |
| 170 | + DailyMotion$2 as D |
| 171 | +}; |
0 commit comments