suada-components 1.0.2504230710 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/BreadCrumb/Breadcrumb.js.map +1 -1
- package/dist/components/Button/Button.interface.d.ts +1 -0
- package/dist/components/DailyMotion-B2EpqlJO.esm.js +178 -0
- package/dist/components/DailyMotion-BYA5rhY5.js +180 -0
- package/dist/components/Facebook-DBxSErS8.esm.js +179 -0
- package/dist/components/Facebook-DJMdBwGM.js +181 -0
- package/dist/components/FilePlayer-DLiC_Doh.esm.js +408 -0
- package/dist/components/FilePlayer-DRqq2T-L.js +410 -0
- package/dist/components/Kaltura-BAvKhQp8.esm.js +176 -0
- package/dist/components/Kaltura-DFK3UxTc.js +178 -0
- package/dist/components/Mixcloud-C0S4Txcb.esm.js +164 -0
- package/dist/components/Mixcloud-CnG6kbdi.js +166 -0
- package/dist/components/Mux-BCS9rYAf.esm.js +264 -0
- package/dist/components/Mux-ChXwYRDL.js +266 -0
- package/dist/components/Preview-CPdzmWpt.js +175 -0
- package/dist/components/Preview-MgDcO7wW.esm.js +173 -0
- package/dist/components/SoundCloud-BxxMgfs2.esm.js +181 -0
- package/dist/components/SoundCloud-CcFGRoSv.js +183 -0
- package/dist/components/Streamable-BIBOfZ0w.js +176 -0
- package/dist/components/Streamable-Drn6K8AN.esm.js +174 -0
- package/dist/components/Twitch-CGC2HQMj.esm.js +168 -0
- package/dist/components/Twitch-DoUQRPQR.js +170 -0
- package/dist/components/VideoPlayer/Controls/Controls.d.ts +4 -0
- package/dist/components/VideoPlayer/Controls/Controls.interface.d.ts +32 -0
- package/dist/components/VideoPlayer/Controls/Controls.interface.js +2 -0
- package/dist/components/VideoPlayer/Controls/Controls.interface.js.map +1 -0
- package/dist/components/VideoPlayer/Controls/Controls.js +36 -0
- package/dist/components/VideoPlayer/Controls/Controls.js.map +1 -0
- package/dist/components/VideoPlayer/Controls/Controls.styles.d.ts +16 -0
- package/dist/components/VideoPlayer/Controls/Controls.styles.js +25 -0
- package/dist/components/VideoPlayer/Controls/Controls.styles.js.map +1 -0
- package/dist/components/VideoPlayer/Controls/index.d.ts +1 -0
- package/dist/components/VideoPlayer/Controls/index.js +2 -0
- package/dist/components/VideoPlayer/Controls/index.js.map +1 -0
- package/dist/components/VideoPlayer/PlaybackSpeedMenu.d.ts +4 -0
- package/dist/components/VideoPlayer/PlaybackSpeedMenu.interface.d.ts +18 -0
- package/dist/components/VideoPlayer/PlaybackSpeedMenu.interface.js +2 -0
- package/dist/components/VideoPlayer/PlaybackSpeedMenu.interface.js.map +1 -0
- package/dist/components/VideoPlayer/PlaybackSpeedMenu.js +20 -0
- package/dist/components/VideoPlayer/PlaybackSpeedMenu.js.map +1 -0
- package/dist/components/VideoPlayer/PlaybackSpeedMenu.styles.d.ts +4 -0
- package/dist/components/VideoPlayer/PlaybackSpeedMenu.styles.js +18 -0
- package/dist/components/VideoPlayer/PlaybackSpeedMenu.styles.js.map +1 -0
- package/dist/components/VideoPlayer/Player.d.ts +3 -11
- package/dist/components/VideoPlayer/Player.interface.d.ts +63 -0
- package/dist/components/VideoPlayer/Player.interface.js +2 -0
- package/dist/components/VideoPlayer/Player.interface.js.map +1 -0
- package/dist/components/VideoPlayer/Player.js +82 -97
- package/dist/components/VideoPlayer/Player.js.map +1 -1
- package/dist/components/VideoPlayer/Player.styles.d.ts +8 -0
- package/dist/components/VideoPlayer/Player.styles.js +17 -0
- package/dist/components/VideoPlayer/Player.styles.js.map +1 -0
- package/dist/components/VideoPlayer/VideoPlayer.stories.d.ts +10 -26
- package/dist/components/VideoPlayer/VideoPlayer.stories.js +174 -19
- package/dist/components/VideoPlayer/VideoPlayer.stories.js.map +1 -1
- package/dist/components/VideoPlayer/constants/index.d.ts +2 -0
- package/dist/components/VideoPlayer/constants/index.js +31 -0
- package/dist/components/VideoPlayer/constants/index.js.map +1 -0
- package/dist/components/VideoPlayer/parseVtt.d.ts +6 -0
- package/dist/components/VideoPlayer/parseVtt.js +35 -0
- package/dist/components/VideoPlayer/parseVtt.js.map +1 -0
- package/dist/components/VideoPlayer/timeConversion.d.ts +5 -0
- package/dist/components/VideoPlayer/timeConversion.js +70 -0
- package/dist/components/VideoPlayer/timeConversion.js.map +1 -0
- package/dist/components/VideoPlayer/useDynamicPosition.d.ts +16 -0
- package/dist/components/VideoPlayer/useDynamicPosition.js +50 -0
- package/dist/components/VideoPlayer/useDynamicPosition.js.map +1 -0
- package/dist/components/VideoPlayer/useEventListener.d.ts +3 -0
- package/dist/components/VideoPlayer/useEventListener.js +27 -0
- package/dist/components/VideoPlayer/useEventListener.js.map +1 -0
- package/dist/components/VideoPlayer/useMenuToggle.d.ts +22 -0
- package/dist/components/VideoPlayer/useMenuToggle.js +25 -0
- package/dist/components/VideoPlayer/useMenuToggle.js.map +1 -0
- package/dist/components/VideoPlayer/useOnOutsideClick.d.ts +3 -0
- package/dist/components/VideoPlayer/useOnOutsideClick.js +16 -0
- package/dist/components/VideoPlayer/useOnOutsideClick.js.map +1 -0
- package/dist/components/VideoPlayer/usePlayerControls.d.ts +3 -0
- package/dist/components/VideoPlayer/usePlayerControls.js +330 -0
- package/dist/components/VideoPlayer/usePlayerControls.js.map +1 -0
- package/dist/components/Vidyard-B-jW75yA.esm.js +172 -0
- package/dist/components/Vidyard-If2H-ayj.js +174 -0
- package/dist/components/Vimeo-Cvg3rB5o.esm.js +213 -0
- package/dist/components/Vimeo-hI3cddOi.js +215 -0
- package/dist/components/Wistia-BtYIM6Uo.esm.js +188 -0
- package/dist/components/Wistia-CZwfIsgx.js +190 -0
- package/dist/components/YouTube-D1u9T9FZ.js +260 -0
- package/dist/components/YouTube-vwMwhQ13.esm.js +258 -0
- package/dist/components/components/Button/Button.interface.d.ts +1 -0
- package/dist/components/components/VideoPlayer/Controls/Controls.d.ts +4 -0
- package/dist/components/components/VideoPlayer/Controls/Controls.interface.d.ts +32 -0
- package/dist/components/components/VideoPlayer/Controls/Controls.styles.d.ts +16 -0
- package/dist/components/components/VideoPlayer/Controls/index.d.ts +1 -0
- package/dist/components/components/VideoPlayer/PlaybackSpeedMenu.d.ts +4 -0
- package/dist/components/components/VideoPlayer/PlaybackSpeedMenu.interface.d.ts +18 -0
- package/dist/components/components/VideoPlayer/PlaybackSpeedMenu.styles.d.ts +4 -0
- package/dist/components/components/VideoPlayer/Player.d.ts +3 -11
- package/dist/components/components/VideoPlayer/Player.interface.d.ts +63 -0
- package/dist/components/components/VideoPlayer/Player.styles.d.ts +8 -0
- package/dist/components/components/VideoPlayer/constants/index.d.ts +2 -0
- package/dist/components/components/VideoPlayer/parseVtt.d.ts +6 -0
- package/dist/components/components/VideoPlayer/timeConversion.d.ts +5 -0
- package/dist/components/components/VideoPlayer/useDynamicPosition.d.ts +16 -0
- package/dist/components/components/VideoPlayer/useEventListener.d.ts +3 -0
- package/dist/components/components/VideoPlayer/useMenuToggle.d.ts +22 -0
- package/dist/components/components/VideoPlayer/useOnOutsideClick.d.ts +3 -0
- package/dist/components/components/VideoPlayer/usePlayerControls.d.ts +3 -0
- package/dist/components/icons/Heart.d.ts +7 -0
- package/dist/components/icons/Maximize.d.ts +3 -0
- package/dist/components/icons/Meter.d.ts +3 -0
- package/dist/components/icons/Minimize.d.ts +3 -0
- package/dist/components/icons/Pause.d.ts +3 -0
- package/dist/components/icons/Play.d.ts +3 -0
- package/dist/components/icons/Rewind.d.ts +7 -0
- package/dist/components/icons/Skip.d.ts +8 -0
- package/dist/components/icons/Subtitles.d.ts +7 -0
- package/dist/components/icons/VideoCheckmark.d.ts +3 -0
- package/dist/components/icons/VolumeMute.d.ts +8 -0
- package/dist/components/icons/VolumeUp.d.ts +8 -0
- package/dist/components/icons/index.d.ts +11 -0
- package/dist/components/index-DLzCbCHu.esm.js +94482 -0
- package/dist/components/index-wLnkslO9.js +94536 -0
- package/dist/components/index.esm.js +3 -122501
- package/dist/icons/Heart.d.ts +7 -0
- package/dist/icons/Heart.js +28 -0
- package/dist/icons/Heart.js.map +1 -0
- package/dist/icons/Maximize.d.ts +3 -0
- package/dist/icons/Maximize.js +28 -0
- package/dist/icons/Maximize.js.map +1 -0
- package/dist/icons/Meter.d.ts +3 -0
- package/dist/icons/Meter.js +28 -0
- package/dist/icons/Meter.js.map +1 -0
- package/dist/icons/Minimize.d.ts +3 -0
- package/dist/icons/Minimize.js +28 -0
- package/dist/icons/Minimize.js.map +1 -0
- package/dist/icons/Pause.d.ts +3 -0
- package/dist/icons/Pause.js +28 -0
- package/dist/icons/Pause.js.map +1 -0
- package/dist/icons/Play.d.ts +3 -0
- package/dist/icons/Play.js +28 -0
- package/dist/icons/Play.js.map +1 -0
- package/dist/icons/Rewind.d.ts +7 -0
- package/dist/icons/Rewind.js +28 -0
- package/dist/icons/Rewind.js.map +1 -0
- package/dist/icons/Skip.d.ts +8 -0
- package/dist/icons/Skip.js +28 -0
- package/dist/icons/Skip.js.map +1 -0
- package/dist/icons/Subtitles.d.ts +7 -0
- package/dist/icons/Subtitles.js +28 -0
- package/dist/icons/Subtitles.js.map +1 -0
- package/dist/icons/VideoCheckmark.d.ts +3 -0
- package/dist/icons/VideoCheckmark.js +28 -0
- package/dist/icons/VideoCheckmark.js.map +1 -0
- package/dist/icons/VolumeMute.d.ts +8 -0
- package/dist/icons/VolumeMute.js +28 -0
- package/dist/icons/VolumeMute.js.map +1 -0
- package/dist/icons/VolumeUp.d.ts +8 -0
- package/dist/icons/VolumeUp.js +28 -0
- package/dist/icons/VolumeUp.js.map +1 -0
- package/dist/icons/components/Button/Button.interface.d.ts +1 -0
- package/dist/icons/components/VideoPlayer/Controls/Controls.d.ts +4 -0
- package/dist/icons/components/VideoPlayer/Controls/Controls.interface.d.ts +32 -0
- package/dist/icons/components/VideoPlayer/Controls/Controls.styles.d.ts +16 -0
- package/dist/icons/components/VideoPlayer/Controls/index.d.ts +1 -0
- package/dist/icons/components/VideoPlayer/PlaybackSpeedMenu.d.ts +4 -0
- package/dist/icons/components/VideoPlayer/PlaybackSpeedMenu.interface.d.ts +18 -0
- package/dist/icons/components/VideoPlayer/PlaybackSpeedMenu.styles.d.ts +4 -0
- package/dist/icons/components/VideoPlayer/Player.d.ts +3 -11
- package/dist/icons/components/VideoPlayer/Player.interface.d.ts +63 -0
- package/dist/icons/components/VideoPlayer/Player.styles.d.ts +8 -0
- package/dist/icons/components/VideoPlayer/constants/index.d.ts +2 -0
- package/dist/icons/components/VideoPlayer/parseVtt.d.ts +6 -0
- package/dist/icons/components/VideoPlayer/timeConversion.d.ts +5 -0
- package/dist/icons/components/VideoPlayer/useDynamicPosition.d.ts +16 -0
- package/dist/icons/components/VideoPlayer/useEventListener.d.ts +3 -0
- package/dist/icons/components/VideoPlayer/useMenuToggle.d.ts +22 -0
- package/dist/icons/components/VideoPlayer/useOnOutsideClick.d.ts +3 -0
- package/dist/icons/components/VideoPlayer/usePlayerControls.d.ts +3 -0
- package/dist/icons/icons/Heart.d.ts +7 -0
- package/dist/icons/icons/Maximize.d.ts +3 -0
- package/dist/icons/icons/Meter.d.ts +3 -0
- package/dist/icons/icons/Minimize.d.ts +3 -0
- package/dist/icons/icons/Pause.d.ts +3 -0
- package/dist/icons/icons/Play.d.ts +3 -0
- package/dist/icons/icons/Rewind.d.ts +7 -0
- package/dist/icons/icons/Skip.d.ts +8 -0
- package/dist/icons/icons/Subtitles.d.ts +7 -0
- package/dist/icons/icons/VideoCheckmark.d.ts +3 -0
- package/dist/icons/icons/VolumeMute.d.ts +8 -0
- package/dist/icons/icons/VolumeUp.d.ts +8 -0
- package/dist/icons/icons/index.d.ts +11 -0
- package/dist/icons/index.d.ts +11 -0
- package/dist/icons/index.esm.js +308 -1
- package/dist/icons/index.js +11 -0
- package/dist/icons/index.js.map +1 -1
- package/package.json +3 -1
- package/dist/components/VideoPlayer/styled-components.d.ts +0 -9
- package/dist/components/VideoPlayer/styled-components.js +0 -19
- package/dist/components/VideoPlayer/styled-components.js.map +0 -1
- package/dist/components/components/VideoPlayer/styled-components.d.ts +0 -9
- package/dist/icons/components/VideoPlayer/styled-components.d.ts +0 -9
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-wLnkslO9.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
function _mergeNamespaces(n, m) {
|
|
7
|
+
m.forEach(function (e) {
|
|
8
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default' && !(k in n)) {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return e[k]; }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
return Object.freeze(n);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var Streamable_1;
|
|
22
|
+
var hasRequiredStreamable;
|
|
23
|
+
|
|
24
|
+
function requireStreamable () {
|
|
25
|
+
if (hasRequiredStreamable) return Streamable_1;
|
|
26
|
+
hasRequiredStreamable = 1;
|
|
27
|
+
var __create = Object.create;
|
|
28
|
+
var __defProp = Object.defineProperty;
|
|
29
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
30
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
31
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
32
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
33
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
34
|
+
var __export = (target, all) => {
|
|
35
|
+
for (var name in all)
|
|
36
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
37
|
+
};
|
|
38
|
+
var __copyProps = (to, from, except, desc) => {
|
|
39
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
40
|
+
for (let key of __getOwnPropNames(from))
|
|
41
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
42
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
43
|
+
}
|
|
44
|
+
return to;
|
|
45
|
+
};
|
|
46
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
47
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
48
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
49
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
50
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
51
|
+
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
52
|
+
mod
|
|
53
|
+
));
|
|
54
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
55
|
+
var __publicField = (obj, key, value) => {
|
|
56
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
57
|
+
return value;
|
|
58
|
+
};
|
|
59
|
+
var Streamable_exports = {};
|
|
60
|
+
__export(Streamable_exports, {
|
|
61
|
+
default: () => Streamable
|
|
62
|
+
});
|
|
63
|
+
Streamable_1 = __toCommonJS(Streamable_exports);
|
|
64
|
+
var import_react = __toESM(React);
|
|
65
|
+
var import_utils = /*@__PURE__*/ index.requireUtils();
|
|
66
|
+
var import_patterns = /*@__PURE__*/ index.requirePatterns();
|
|
67
|
+
const SDK_URL = "https://cdn.embed.ly/player-0.1.0.min.js";
|
|
68
|
+
const SDK_GLOBAL = "playerjs";
|
|
69
|
+
class Streamable extends import_react.Component {
|
|
70
|
+
constructor() {
|
|
71
|
+
super(...arguments);
|
|
72
|
+
__publicField(this, "callPlayer", import_utils.callPlayer);
|
|
73
|
+
__publicField(this, "duration", null);
|
|
74
|
+
__publicField(this, "currentTime", null);
|
|
75
|
+
__publicField(this, "secondsLoaded", null);
|
|
76
|
+
__publicField(this, "mute", () => {
|
|
77
|
+
this.callPlayer("mute");
|
|
78
|
+
});
|
|
79
|
+
__publicField(this, "unmute", () => {
|
|
80
|
+
this.callPlayer("unmute");
|
|
81
|
+
});
|
|
82
|
+
__publicField(this, "ref", (iframe) => {
|
|
83
|
+
this.iframe = iframe;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
componentDidMount() {
|
|
87
|
+
this.props.onMount && this.props.onMount(this);
|
|
88
|
+
}
|
|
89
|
+
load(url) {
|
|
90
|
+
(0, import_utils.getSDK)(SDK_URL, SDK_GLOBAL).then((playerjs) => {
|
|
91
|
+
if (!this.iframe)
|
|
92
|
+
return;
|
|
93
|
+
this.player = new playerjs.Player(this.iframe);
|
|
94
|
+
this.player.setLoop(this.props.loop);
|
|
95
|
+
this.player.on("ready", this.props.onReady);
|
|
96
|
+
this.player.on("play", this.props.onPlay);
|
|
97
|
+
this.player.on("pause", this.props.onPause);
|
|
98
|
+
this.player.on("seeked", this.props.onSeek);
|
|
99
|
+
this.player.on("ended", this.props.onEnded);
|
|
100
|
+
this.player.on("error", this.props.onError);
|
|
101
|
+
this.player.on("timeupdate", ({ duration, seconds }) => {
|
|
102
|
+
this.duration = duration;
|
|
103
|
+
this.currentTime = seconds;
|
|
104
|
+
});
|
|
105
|
+
this.player.on("buffered", ({ percent }) => {
|
|
106
|
+
if (this.duration) {
|
|
107
|
+
this.secondsLoaded = this.duration * percent;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
if (this.props.muted) {
|
|
111
|
+
this.player.mute();
|
|
112
|
+
}
|
|
113
|
+
}, this.props.onError);
|
|
114
|
+
}
|
|
115
|
+
play() {
|
|
116
|
+
this.callPlayer("play");
|
|
117
|
+
}
|
|
118
|
+
pause() {
|
|
119
|
+
this.callPlayer("pause");
|
|
120
|
+
}
|
|
121
|
+
stop() {
|
|
122
|
+
}
|
|
123
|
+
seekTo(seconds, keepPlaying = true) {
|
|
124
|
+
this.callPlayer("setCurrentTime", seconds);
|
|
125
|
+
if (!keepPlaying) {
|
|
126
|
+
this.pause();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
setVolume(fraction) {
|
|
130
|
+
this.callPlayer("setVolume", fraction * 100);
|
|
131
|
+
}
|
|
132
|
+
setLoop(loop) {
|
|
133
|
+
this.callPlayer("setLoop", loop);
|
|
134
|
+
}
|
|
135
|
+
getDuration() {
|
|
136
|
+
return this.duration;
|
|
137
|
+
}
|
|
138
|
+
getCurrentTime() {
|
|
139
|
+
return this.currentTime;
|
|
140
|
+
}
|
|
141
|
+
getSecondsLoaded() {
|
|
142
|
+
return this.secondsLoaded;
|
|
143
|
+
}
|
|
144
|
+
render() {
|
|
145
|
+
const id = this.props.url.match(import_patterns.MATCH_URL_STREAMABLE)[1];
|
|
146
|
+
const style = {
|
|
147
|
+
width: "100%",
|
|
148
|
+
height: "100%"
|
|
149
|
+
};
|
|
150
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
151
|
+
"iframe",
|
|
152
|
+
{
|
|
153
|
+
ref: this.ref,
|
|
154
|
+
src: `https://streamable.com/o/${id}`,
|
|
155
|
+
frameBorder: "0",
|
|
156
|
+
scrolling: "no",
|
|
157
|
+
style,
|
|
158
|
+
allow: "encrypted-media; autoplay; fullscreen;"
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
__publicField(Streamable, "displayName", "Streamable");
|
|
164
|
+
__publicField(Streamable, "canPlay", import_patterns.canPlay.streamable);
|
|
165
|
+
return Streamable_1;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
var StreamableExports = /*@__PURE__*/ requireStreamable();
|
|
169
|
+
var Streamable = /*@__PURE__*/index.getDefaultExportFromCjs(StreamableExports);
|
|
170
|
+
|
|
171
|
+
var Streamable$1 = /*#__PURE__*/_mergeNamespaces({
|
|
172
|
+
__proto__: null,
|
|
173
|
+
default: Streamable
|
|
174
|
+
}, [StreamableExports]);
|
|
175
|
+
|
|
176
|
+
exports.Streamable = Streamable$1;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { r as requireUtils, a as requirePatterns, g as getDefaultExportFromCjs } from './index-DLzCbCHu.esm.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
function _mergeNamespaces(n, m) {
|
|
5
|
+
m.forEach(function (e) {
|
|
6
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
7
|
+
if (k !== 'default' && !(k in n)) {
|
|
8
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
9
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return e[k]; }
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
return Object.freeze(n);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var Streamable_1;
|
|
20
|
+
var hasRequiredStreamable;
|
|
21
|
+
|
|
22
|
+
function requireStreamable () {
|
|
23
|
+
if (hasRequiredStreamable) return Streamable_1;
|
|
24
|
+
hasRequiredStreamable = 1;
|
|
25
|
+
var __create = Object.create;
|
|
26
|
+
var __defProp = Object.defineProperty;
|
|
27
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
28
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
29
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
30
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
31
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
32
|
+
var __export = (target, all) => {
|
|
33
|
+
for (var name in all)
|
|
34
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
35
|
+
};
|
|
36
|
+
var __copyProps = (to, from, except, desc) => {
|
|
37
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
38
|
+
for (let key of __getOwnPropNames(from))
|
|
39
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
40
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
41
|
+
}
|
|
42
|
+
return to;
|
|
43
|
+
};
|
|
44
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
45
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
46
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
47
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
48
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
49
|
+
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
50
|
+
mod
|
|
51
|
+
));
|
|
52
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
53
|
+
var __publicField = (obj, key, value) => {
|
|
54
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
55
|
+
return value;
|
|
56
|
+
};
|
|
57
|
+
var Streamable_exports = {};
|
|
58
|
+
__export(Streamable_exports, {
|
|
59
|
+
default: () => Streamable
|
|
60
|
+
});
|
|
61
|
+
Streamable_1 = __toCommonJS(Streamable_exports);
|
|
62
|
+
var import_react = __toESM(React__default);
|
|
63
|
+
var import_utils = /*@__PURE__*/ requireUtils();
|
|
64
|
+
var import_patterns = /*@__PURE__*/ requirePatterns();
|
|
65
|
+
const SDK_URL = "https://cdn.embed.ly/player-0.1.0.min.js";
|
|
66
|
+
const SDK_GLOBAL = "playerjs";
|
|
67
|
+
class Streamable extends import_react.Component {
|
|
68
|
+
constructor() {
|
|
69
|
+
super(...arguments);
|
|
70
|
+
__publicField(this, "callPlayer", import_utils.callPlayer);
|
|
71
|
+
__publicField(this, "duration", null);
|
|
72
|
+
__publicField(this, "currentTime", null);
|
|
73
|
+
__publicField(this, "secondsLoaded", null);
|
|
74
|
+
__publicField(this, "mute", () => {
|
|
75
|
+
this.callPlayer("mute");
|
|
76
|
+
});
|
|
77
|
+
__publicField(this, "unmute", () => {
|
|
78
|
+
this.callPlayer("unmute");
|
|
79
|
+
});
|
|
80
|
+
__publicField(this, "ref", (iframe) => {
|
|
81
|
+
this.iframe = iframe;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
componentDidMount() {
|
|
85
|
+
this.props.onMount && this.props.onMount(this);
|
|
86
|
+
}
|
|
87
|
+
load(url) {
|
|
88
|
+
(0, import_utils.getSDK)(SDK_URL, SDK_GLOBAL).then((playerjs) => {
|
|
89
|
+
if (!this.iframe)
|
|
90
|
+
return;
|
|
91
|
+
this.player = new playerjs.Player(this.iframe);
|
|
92
|
+
this.player.setLoop(this.props.loop);
|
|
93
|
+
this.player.on("ready", this.props.onReady);
|
|
94
|
+
this.player.on("play", this.props.onPlay);
|
|
95
|
+
this.player.on("pause", this.props.onPause);
|
|
96
|
+
this.player.on("seeked", this.props.onSeek);
|
|
97
|
+
this.player.on("ended", this.props.onEnded);
|
|
98
|
+
this.player.on("error", this.props.onError);
|
|
99
|
+
this.player.on("timeupdate", ({ duration, seconds }) => {
|
|
100
|
+
this.duration = duration;
|
|
101
|
+
this.currentTime = seconds;
|
|
102
|
+
});
|
|
103
|
+
this.player.on("buffered", ({ percent }) => {
|
|
104
|
+
if (this.duration) {
|
|
105
|
+
this.secondsLoaded = this.duration * percent;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (this.props.muted) {
|
|
109
|
+
this.player.mute();
|
|
110
|
+
}
|
|
111
|
+
}, this.props.onError);
|
|
112
|
+
}
|
|
113
|
+
play() {
|
|
114
|
+
this.callPlayer("play");
|
|
115
|
+
}
|
|
116
|
+
pause() {
|
|
117
|
+
this.callPlayer("pause");
|
|
118
|
+
}
|
|
119
|
+
stop() {
|
|
120
|
+
}
|
|
121
|
+
seekTo(seconds, keepPlaying = true) {
|
|
122
|
+
this.callPlayer("setCurrentTime", seconds);
|
|
123
|
+
if (!keepPlaying) {
|
|
124
|
+
this.pause();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
setVolume(fraction) {
|
|
128
|
+
this.callPlayer("setVolume", fraction * 100);
|
|
129
|
+
}
|
|
130
|
+
setLoop(loop) {
|
|
131
|
+
this.callPlayer("setLoop", loop);
|
|
132
|
+
}
|
|
133
|
+
getDuration() {
|
|
134
|
+
return this.duration;
|
|
135
|
+
}
|
|
136
|
+
getCurrentTime() {
|
|
137
|
+
return this.currentTime;
|
|
138
|
+
}
|
|
139
|
+
getSecondsLoaded() {
|
|
140
|
+
return this.secondsLoaded;
|
|
141
|
+
}
|
|
142
|
+
render() {
|
|
143
|
+
const id = this.props.url.match(import_patterns.MATCH_URL_STREAMABLE)[1];
|
|
144
|
+
const style = {
|
|
145
|
+
width: "100%",
|
|
146
|
+
height: "100%"
|
|
147
|
+
};
|
|
148
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
149
|
+
"iframe",
|
|
150
|
+
{
|
|
151
|
+
ref: this.ref,
|
|
152
|
+
src: `https://streamable.com/o/${id}`,
|
|
153
|
+
frameBorder: "0",
|
|
154
|
+
scrolling: "no",
|
|
155
|
+
style,
|
|
156
|
+
allow: "encrypted-media; autoplay; fullscreen;"
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
__publicField(Streamable, "displayName", "Streamable");
|
|
162
|
+
__publicField(Streamable, "canPlay", import_patterns.canPlay.streamable);
|
|
163
|
+
return Streamable_1;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
var StreamableExports = /*@__PURE__*/ requireStreamable();
|
|
167
|
+
var Streamable = /*@__PURE__*/getDefaultExportFromCjs(StreamableExports);
|
|
168
|
+
|
|
169
|
+
var Streamable$1 = /*#__PURE__*/_mergeNamespaces({
|
|
170
|
+
__proto__: null,
|
|
171
|
+
default: Streamable
|
|
172
|
+
}, [StreamableExports]);
|
|
173
|
+
|
|
174
|
+
export { Streamable$1 as S };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { r as requireUtils, a as requirePatterns, g as getDefaultExportFromCjs } from './index-DLzCbCHu.esm.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
function _mergeNamespaces(n, m) {
|
|
5
|
+
m.forEach(function (e) {
|
|
6
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
7
|
+
if (k !== 'default' && !(k in n)) {
|
|
8
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
9
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return e[k]; }
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
return Object.freeze(n);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var Twitch_1;
|
|
20
|
+
var hasRequiredTwitch;
|
|
21
|
+
|
|
22
|
+
function requireTwitch () {
|
|
23
|
+
if (hasRequiredTwitch) return Twitch_1;
|
|
24
|
+
hasRequiredTwitch = 1;
|
|
25
|
+
var __create = Object.create;
|
|
26
|
+
var __defProp = Object.defineProperty;
|
|
27
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
28
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
29
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
30
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
31
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
32
|
+
var __export = (target, all) => {
|
|
33
|
+
for (var name in all)
|
|
34
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
35
|
+
};
|
|
36
|
+
var __copyProps = (to, from, except, desc) => {
|
|
37
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
38
|
+
for (let key of __getOwnPropNames(from))
|
|
39
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
40
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
41
|
+
}
|
|
42
|
+
return to;
|
|
43
|
+
};
|
|
44
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
45
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
46
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
47
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
48
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
49
|
+
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
50
|
+
mod
|
|
51
|
+
));
|
|
52
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
53
|
+
var __publicField = (obj, key, value) => {
|
|
54
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
55
|
+
return value;
|
|
56
|
+
};
|
|
57
|
+
var Twitch_exports = {};
|
|
58
|
+
__export(Twitch_exports, {
|
|
59
|
+
default: () => Twitch
|
|
60
|
+
});
|
|
61
|
+
Twitch_1 = __toCommonJS(Twitch_exports);
|
|
62
|
+
var import_react = __toESM(React__default);
|
|
63
|
+
var import_utils = /*@__PURE__*/ requireUtils();
|
|
64
|
+
var import_patterns = /*@__PURE__*/ requirePatterns();
|
|
65
|
+
const SDK_URL = "https://player.twitch.tv/js/embed/v1.js";
|
|
66
|
+
const SDK_GLOBAL = "Twitch";
|
|
67
|
+
const PLAYER_ID_PREFIX = "twitch-player-";
|
|
68
|
+
class Twitch extends import_react.Component {
|
|
69
|
+
constructor() {
|
|
70
|
+
super(...arguments);
|
|
71
|
+
__publicField(this, "callPlayer", import_utils.callPlayer);
|
|
72
|
+
__publicField(this, "playerID", this.props.config.playerId || `${PLAYER_ID_PREFIX}${(0, import_utils.randomString)()}`);
|
|
73
|
+
__publicField(this, "mute", () => {
|
|
74
|
+
this.callPlayer("setMuted", true);
|
|
75
|
+
});
|
|
76
|
+
__publicField(this, "unmute", () => {
|
|
77
|
+
this.callPlayer("setMuted", false);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
componentDidMount() {
|
|
81
|
+
this.props.onMount && this.props.onMount(this);
|
|
82
|
+
}
|
|
83
|
+
load(url, isReady) {
|
|
84
|
+
const { playsinline, onError, config, controls } = this.props;
|
|
85
|
+
const isChannel = import_patterns.MATCH_URL_TWITCH_CHANNEL.test(url);
|
|
86
|
+
const id = isChannel ? url.match(import_patterns.MATCH_URL_TWITCH_CHANNEL)[1] : url.match(import_patterns.MATCH_URL_TWITCH_VIDEO)[1];
|
|
87
|
+
if (isReady) {
|
|
88
|
+
if (isChannel) {
|
|
89
|
+
this.player.setChannel(id);
|
|
90
|
+
} else {
|
|
91
|
+
this.player.setVideo("v" + id);
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
(0, import_utils.getSDK)(SDK_URL, SDK_GLOBAL).then((Twitch2) => {
|
|
96
|
+
this.player = new Twitch2.Player(this.playerID, {
|
|
97
|
+
video: isChannel ? "" : id,
|
|
98
|
+
channel: isChannel ? id : "",
|
|
99
|
+
height: "100%",
|
|
100
|
+
width: "100%",
|
|
101
|
+
playsinline,
|
|
102
|
+
autoplay: this.props.playing,
|
|
103
|
+
muted: this.props.muted,
|
|
104
|
+
// https://github.com/CookPete/react-player/issues/733#issuecomment-549085859
|
|
105
|
+
controls: isChannel ? true : controls,
|
|
106
|
+
time: (0, import_utils.parseStartTime)(url),
|
|
107
|
+
...config.options
|
|
108
|
+
});
|
|
109
|
+
const { READY, PLAYING, PAUSE, ENDED, ONLINE, OFFLINE, SEEK } = Twitch2.Player;
|
|
110
|
+
this.player.addEventListener(READY, this.props.onReady);
|
|
111
|
+
this.player.addEventListener(PLAYING, this.props.onPlay);
|
|
112
|
+
this.player.addEventListener(PAUSE, this.props.onPause);
|
|
113
|
+
this.player.addEventListener(ENDED, this.props.onEnded);
|
|
114
|
+
this.player.addEventListener(SEEK, this.props.onSeek);
|
|
115
|
+
this.player.addEventListener(ONLINE, this.props.onLoaded);
|
|
116
|
+
this.player.addEventListener(OFFLINE, this.props.onLoaded);
|
|
117
|
+
}, onError);
|
|
118
|
+
}
|
|
119
|
+
play() {
|
|
120
|
+
this.callPlayer("play");
|
|
121
|
+
}
|
|
122
|
+
pause() {
|
|
123
|
+
this.callPlayer("pause");
|
|
124
|
+
}
|
|
125
|
+
stop() {
|
|
126
|
+
this.callPlayer("pause");
|
|
127
|
+
}
|
|
128
|
+
seekTo(seconds, keepPlaying = true) {
|
|
129
|
+
this.callPlayer("seek", seconds);
|
|
130
|
+
if (!keepPlaying) {
|
|
131
|
+
this.pause();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
setVolume(fraction) {
|
|
135
|
+
this.callPlayer("setVolume", fraction);
|
|
136
|
+
}
|
|
137
|
+
getDuration() {
|
|
138
|
+
return this.callPlayer("getDuration");
|
|
139
|
+
}
|
|
140
|
+
getCurrentTime() {
|
|
141
|
+
return this.callPlayer("getCurrentTime");
|
|
142
|
+
}
|
|
143
|
+
getSecondsLoaded() {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
render() {
|
|
147
|
+
const style = {
|
|
148
|
+
width: "100%",
|
|
149
|
+
height: "100%"
|
|
150
|
+
};
|
|
151
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { style, id: this.playerID });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
__publicField(Twitch, "displayName", "Twitch");
|
|
155
|
+
__publicField(Twitch, "canPlay", import_patterns.canPlay.twitch);
|
|
156
|
+
__publicField(Twitch, "loopOnEnded", true);
|
|
157
|
+
return Twitch_1;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
var TwitchExports = /*@__PURE__*/ requireTwitch();
|
|
161
|
+
var Twitch = /*@__PURE__*/getDefaultExportFromCjs(TwitchExports);
|
|
162
|
+
|
|
163
|
+
var Twitch$1 = /*#__PURE__*/_mergeNamespaces({
|
|
164
|
+
__proto__: null,
|
|
165
|
+
default: Twitch
|
|
166
|
+
}, [TwitchExports]);
|
|
167
|
+
|
|
168
|
+
export { Twitch$1 as T };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-wLnkslO9.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
function _mergeNamespaces(n, m) {
|
|
7
|
+
m.forEach(function (e) {
|
|
8
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default' && !(k in n)) {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return e[k]; }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
return Object.freeze(n);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var Twitch_1;
|
|
22
|
+
var hasRequiredTwitch;
|
|
23
|
+
|
|
24
|
+
function requireTwitch () {
|
|
25
|
+
if (hasRequiredTwitch) return Twitch_1;
|
|
26
|
+
hasRequiredTwitch = 1;
|
|
27
|
+
var __create = Object.create;
|
|
28
|
+
var __defProp = Object.defineProperty;
|
|
29
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
30
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
31
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
32
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
33
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
34
|
+
var __export = (target, all) => {
|
|
35
|
+
for (var name in all)
|
|
36
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
37
|
+
};
|
|
38
|
+
var __copyProps = (to, from, except, desc) => {
|
|
39
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
40
|
+
for (let key of __getOwnPropNames(from))
|
|
41
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
42
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
43
|
+
}
|
|
44
|
+
return to;
|
|
45
|
+
};
|
|
46
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
47
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
48
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
49
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
50
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
51
|
+
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
52
|
+
mod
|
|
53
|
+
));
|
|
54
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
55
|
+
var __publicField = (obj, key, value) => {
|
|
56
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
57
|
+
return value;
|
|
58
|
+
};
|
|
59
|
+
var Twitch_exports = {};
|
|
60
|
+
__export(Twitch_exports, {
|
|
61
|
+
default: () => Twitch
|
|
62
|
+
});
|
|
63
|
+
Twitch_1 = __toCommonJS(Twitch_exports);
|
|
64
|
+
var import_react = __toESM(React);
|
|
65
|
+
var import_utils = /*@__PURE__*/ index.requireUtils();
|
|
66
|
+
var import_patterns = /*@__PURE__*/ index.requirePatterns();
|
|
67
|
+
const SDK_URL = "https://player.twitch.tv/js/embed/v1.js";
|
|
68
|
+
const SDK_GLOBAL = "Twitch";
|
|
69
|
+
const PLAYER_ID_PREFIX = "twitch-player-";
|
|
70
|
+
class Twitch extends import_react.Component {
|
|
71
|
+
constructor() {
|
|
72
|
+
super(...arguments);
|
|
73
|
+
__publicField(this, "callPlayer", import_utils.callPlayer);
|
|
74
|
+
__publicField(this, "playerID", this.props.config.playerId || `${PLAYER_ID_PREFIX}${(0, import_utils.randomString)()}`);
|
|
75
|
+
__publicField(this, "mute", () => {
|
|
76
|
+
this.callPlayer("setMuted", true);
|
|
77
|
+
});
|
|
78
|
+
__publicField(this, "unmute", () => {
|
|
79
|
+
this.callPlayer("setMuted", false);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
componentDidMount() {
|
|
83
|
+
this.props.onMount && this.props.onMount(this);
|
|
84
|
+
}
|
|
85
|
+
load(url, isReady) {
|
|
86
|
+
const { playsinline, onError, config, controls } = this.props;
|
|
87
|
+
const isChannel = import_patterns.MATCH_URL_TWITCH_CHANNEL.test(url);
|
|
88
|
+
const id = isChannel ? url.match(import_patterns.MATCH_URL_TWITCH_CHANNEL)[1] : url.match(import_patterns.MATCH_URL_TWITCH_VIDEO)[1];
|
|
89
|
+
if (isReady) {
|
|
90
|
+
if (isChannel) {
|
|
91
|
+
this.player.setChannel(id);
|
|
92
|
+
} else {
|
|
93
|
+
this.player.setVideo("v" + id);
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
(0, import_utils.getSDK)(SDK_URL, SDK_GLOBAL).then((Twitch2) => {
|
|
98
|
+
this.player = new Twitch2.Player(this.playerID, {
|
|
99
|
+
video: isChannel ? "" : id,
|
|
100
|
+
channel: isChannel ? id : "",
|
|
101
|
+
height: "100%",
|
|
102
|
+
width: "100%",
|
|
103
|
+
playsinline,
|
|
104
|
+
autoplay: this.props.playing,
|
|
105
|
+
muted: this.props.muted,
|
|
106
|
+
// https://github.com/CookPete/react-player/issues/733#issuecomment-549085859
|
|
107
|
+
controls: isChannel ? true : controls,
|
|
108
|
+
time: (0, import_utils.parseStartTime)(url),
|
|
109
|
+
...config.options
|
|
110
|
+
});
|
|
111
|
+
const { READY, PLAYING, PAUSE, ENDED, ONLINE, OFFLINE, SEEK } = Twitch2.Player;
|
|
112
|
+
this.player.addEventListener(READY, this.props.onReady);
|
|
113
|
+
this.player.addEventListener(PLAYING, this.props.onPlay);
|
|
114
|
+
this.player.addEventListener(PAUSE, this.props.onPause);
|
|
115
|
+
this.player.addEventListener(ENDED, this.props.onEnded);
|
|
116
|
+
this.player.addEventListener(SEEK, this.props.onSeek);
|
|
117
|
+
this.player.addEventListener(ONLINE, this.props.onLoaded);
|
|
118
|
+
this.player.addEventListener(OFFLINE, this.props.onLoaded);
|
|
119
|
+
}, onError);
|
|
120
|
+
}
|
|
121
|
+
play() {
|
|
122
|
+
this.callPlayer("play");
|
|
123
|
+
}
|
|
124
|
+
pause() {
|
|
125
|
+
this.callPlayer("pause");
|
|
126
|
+
}
|
|
127
|
+
stop() {
|
|
128
|
+
this.callPlayer("pause");
|
|
129
|
+
}
|
|
130
|
+
seekTo(seconds, keepPlaying = true) {
|
|
131
|
+
this.callPlayer("seek", seconds);
|
|
132
|
+
if (!keepPlaying) {
|
|
133
|
+
this.pause();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
setVolume(fraction) {
|
|
137
|
+
this.callPlayer("setVolume", fraction);
|
|
138
|
+
}
|
|
139
|
+
getDuration() {
|
|
140
|
+
return this.callPlayer("getDuration");
|
|
141
|
+
}
|
|
142
|
+
getCurrentTime() {
|
|
143
|
+
return this.callPlayer("getCurrentTime");
|
|
144
|
+
}
|
|
145
|
+
getSecondsLoaded() {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
render() {
|
|
149
|
+
const style = {
|
|
150
|
+
width: "100%",
|
|
151
|
+
height: "100%"
|
|
152
|
+
};
|
|
153
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { style, id: this.playerID });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
__publicField(Twitch, "displayName", "Twitch");
|
|
157
|
+
__publicField(Twitch, "canPlay", import_patterns.canPlay.twitch);
|
|
158
|
+
__publicField(Twitch, "loopOnEnded", true);
|
|
159
|
+
return Twitch_1;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
var TwitchExports = /*@__PURE__*/ requireTwitch();
|
|
163
|
+
var Twitch = /*@__PURE__*/index.getDefaultExportFromCjs(TwitchExports);
|
|
164
|
+
|
|
165
|
+
var Twitch$1 = /*#__PURE__*/_mergeNamespaces({
|
|
166
|
+
__proto__: null,
|
|
167
|
+
default: Twitch
|
|
168
|
+
}, [TwitchExports]);
|
|
169
|
+
|
|
170
|
+
exports.Twitch = Twitch$1;
|