@folklore/hooks 0.0.27 → 0.0.28
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/cjs.js +921 -840
- package/dist/es.js +920 -838
- package/package.json +4 -2
package/dist/cjs.js
CHANGED
|
@@ -2,52 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
6
5
|
var raf = require('raf');
|
|
7
6
|
var react = require('react');
|
|
8
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
9
7
|
var services = require('@folklore/services');
|
|
10
8
|
var createDebug = require('debug');
|
|
11
9
|
var EventsManager = require('@folklore/events');
|
|
12
|
-
var
|
|
10
|
+
var cancelablePromise = require('cancelable-promise');
|
|
11
|
+
var isNumber = require('lodash/isNumber');
|
|
13
12
|
|
|
14
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
14
|
|
|
16
|
-
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
17
15
|
var raf__default = /*#__PURE__*/_interopDefaultLegacy(raf);
|
|
18
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
19
16
|
var createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
|
|
20
17
|
var EventsManager__default = /*#__PURE__*/_interopDefaultLegacy(EventsManager);
|
|
21
|
-
var
|
|
18
|
+
var isNumber__default = /*#__PURE__*/_interopDefaultLegacy(isNumber);
|
|
22
19
|
|
|
23
20
|
function useCounter(desiredValue, _ref) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var startTime = null;
|
|
37
|
-
var duration = 0;
|
|
38
|
-
var canceled = false;
|
|
39
|
-
var startValue = currentValue;
|
|
40
|
-
var delta = desiredValue - startValue;
|
|
21
|
+
let {
|
|
22
|
+
maxDuration = 2000,
|
|
23
|
+
speed = 1 / 10
|
|
24
|
+
} = _ref;
|
|
25
|
+
const [currentValue, setCurrentValue] = react.useState(desiredValue);
|
|
26
|
+
react.useEffect(() => {
|
|
27
|
+
let animationFrame = null;
|
|
28
|
+
let startTime = null;
|
|
29
|
+
let duration = 0;
|
|
30
|
+
let canceled = false;
|
|
31
|
+
const startValue = currentValue;
|
|
32
|
+
const delta = desiredValue - startValue;
|
|
41
33
|
|
|
42
34
|
function loop() {
|
|
43
35
|
if (canceled) {
|
|
44
36
|
return;
|
|
45
37
|
}
|
|
46
38
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
const currentTime = Date.now();
|
|
40
|
+
const elapsedTime = currentTime - startTime;
|
|
41
|
+
const progress = Math.min(elapsedTime / duration, 1);
|
|
42
|
+
const newValue = Math.round(startValue + progress * delta);
|
|
51
43
|
setCurrentValue(newValue);
|
|
52
44
|
|
|
53
45
|
if (newValue !== desiredValue) {
|
|
@@ -61,7 +53,7 @@ function useCounter(desiredValue, _ref) {
|
|
|
61
53
|
animationFrame = raf__default["default"](loop);
|
|
62
54
|
}
|
|
63
55
|
|
|
64
|
-
return
|
|
56
|
+
return () => {
|
|
65
57
|
canceled = true;
|
|
66
58
|
|
|
67
59
|
if (animationFrame !== null) {
|
|
@@ -73,28 +65,17 @@ function useCounter(desiredValue, _ref) {
|
|
|
73
65
|
}
|
|
74
66
|
|
|
75
67
|
function usePlayerCurrentTime(player) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return p.currentTime;
|
|
88
|
-
} : _ref$getCurrentTime;
|
|
89
|
-
|
|
90
|
-
var _useState = react.useState(0),
|
|
91
|
-
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
92
|
-
currentTime = _useState2[0],
|
|
93
|
-
setCurrentTime = _useState2[1];
|
|
94
|
-
|
|
95
|
-
var realCurrentTime = react.useRef(currentTime);
|
|
96
|
-
var lastIdRef = react.useRef(id);
|
|
97
|
-
var idChanged = lastIdRef.current !== id;
|
|
68
|
+
let {
|
|
69
|
+
id = null,
|
|
70
|
+
disabled = false,
|
|
71
|
+
updateInterval = 1000,
|
|
72
|
+
onUpdate: customOnUpdate = null,
|
|
73
|
+
getCurrentTime = p => p.currentTime
|
|
74
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
75
|
+
const [currentTime, setCurrentTime] = react.useState(0);
|
|
76
|
+
const realCurrentTime = react.useRef(currentTime);
|
|
77
|
+
const lastIdRef = react.useRef(id);
|
|
78
|
+
const idChanged = lastIdRef.current !== id;
|
|
98
79
|
|
|
99
80
|
if (idChanged) {
|
|
100
81
|
realCurrentTime.current = 0;
|
|
@@ -102,14 +83,14 @@ function usePlayerCurrentTime(player) {
|
|
|
102
83
|
} // Check time update
|
|
103
84
|
|
|
104
85
|
|
|
105
|
-
react.useEffect(
|
|
86
|
+
react.useEffect(() => {
|
|
106
87
|
if (disabled || player === null) {
|
|
107
|
-
return
|
|
88
|
+
return () => {};
|
|
108
89
|
}
|
|
109
90
|
|
|
110
|
-
|
|
91
|
+
let canceled = false;
|
|
111
92
|
|
|
112
|
-
|
|
93
|
+
const updateTime = time => {
|
|
113
94
|
if (canceled) {
|
|
114
95
|
return;
|
|
115
96
|
}
|
|
@@ -122,8 +103,8 @@ function usePlayerCurrentTime(player) {
|
|
|
122
103
|
}
|
|
123
104
|
};
|
|
124
105
|
|
|
125
|
-
|
|
126
|
-
|
|
106
|
+
const interval = setInterval(() => {
|
|
107
|
+
const time = getCurrentTime(player);
|
|
127
108
|
|
|
128
109
|
if (typeof time.then !== 'undefined') {
|
|
129
110
|
time.then(updateTime);
|
|
@@ -131,7 +112,7 @@ function usePlayerCurrentTime(player) {
|
|
|
131
112
|
updateTime(time);
|
|
132
113
|
}
|
|
133
114
|
}, updateInterval);
|
|
134
|
-
return
|
|
115
|
+
return () => {
|
|
135
116
|
canceled = true;
|
|
136
117
|
clearInterval(interval);
|
|
137
118
|
};
|
|
@@ -139,115 +120,67 @@ function usePlayerCurrentTime(player) {
|
|
|
139
120
|
return realCurrentTime.current;
|
|
140
121
|
}
|
|
141
122
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
var match = url.match(/\/video\/([^/?]+)/);
|
|
186
|
-
return match !== null ? match[1] : null;
|
|
187
|
-
} : _params$getVideoId;
|
|
188
|
-
|
|
189
|
-
var _useState = react.useState(typeof window.DM !== 'undefined'),
|
|
190
|
-
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
191
|
-
apiLoaded = _useState2[0],
|
|
192
|
-
setApiLoaded = _useState2[1];
|
|
193
|
-
|
|
194
|
-
var _useState3 = react.useState(false),
|
|
195
|
-
_useState4 = _slicedToArray__default["default"](_useState3, 2),
|
|
196
|
-
playerReady = _useState4[0],
|
|
197
|
-
setPlayerReady = _useState4[1];
|
|
198
|
-
|
|
199
|
-
var _useState5 = react.useState(false),
|
|
200
|
-
_useState6 = _slicedToArray__default["default"](_useState5, 2),
|
|
201
|
-
loaded = _useState6[0],
|
|
202
|
-
setLoaded = _useState6[1];
|
|
203
|
-
|
|
204
|
-
var apiRef = react.useRef(typeof window.DM !== 'undefined' ? window.DM : null);
|
|
205
|
-
var ready = apiLoaded && playerReady;
|
|
206
|
-
var videoId = react.useMemo(function () {
|
|
207
|
-
return getVideoId(id);
|
|
208
|
-
}, [id]);
|
|
209
|
-
var elementRef = react.useRef(null);
|
|
210
|
-
var playerRef = react.useRef(null);
|
|
211
|
-
var playerElementRef = react.useRef(elementRef.current);
|
|
212
|
-
var elementHasChanged = elementRef.current !== playerElementRef.current;
|
|
213
|
-
|
|
214
|
-
var _useState7 = react.useState(initialMuted),
|
|
215
|
-
_useState8 = _slicedToArray__default["default"](_useState7, 2),
|
|
216
|
-
muted = _useState8[0],
|
|
217
|
-
setMuted = _useState8[1];
|
|
218
|
-
|
|
219
|
-
var _useState9 = react.useState(initialMuted ? 0 : 1),
|
|
220
|
-
_useState10 = _slicedToArray__default["default"](_useState9, 2),
|
|
221
|
-
volume = _useState10[0],
|
|
222
|
-
setVolumeState = _useState10[1];
|
|
223
|
-
|
|
224
|
-
var _useState11 = react.useState({
|
|
123
|
+
const noPlayerError$1 = new Error('No player');
|
|
124
|
+
const debug$3 = createDebug__default["default"]('folklore:video:dailymotion');
|
|
125
|
+
|
|
126
|
+
const useDailymotionPlayer = function () {
|
|
127
|
+
let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
128
|
+
let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
129
|
+
const {
|
|
130
|
+
width = 0,
|
|
131
|
+
height = 0,
|
|
132
|
+
duration = 0,
|
|
133
|
+
autoplay = false,
|
|
134
|
+
muted: initialMuted = false,
|
|
135
|
+
start = 0,
|
|
136
|
+
controls = true,
|
|
137
|
+
queueAutoplayNext = false,
|
|
138
|
+
queueEnable = false,
|
|
139
|
+
sharingEnable = false,
|
|
140
|
+
uiLogo = false,
|
|
141
|
+
uiStartScreenInfo = true,
|
|
142
|
+
timeUpdateInterval = 1000,
|
|
143
|
+
onTimeUpdate: customOnTimeUpdate = null,
|
|
144
|
+
getVideoId = url => {
|
|
145
|
+
if (url === null || url.match(/^https?:/) === null) {
|
|
146
|
+
return url;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const match = url.match(/\/video\/([^/?]+)/);
|
|
150
|
+
return match !== null ? match[1] : null;
|
|
151
|
+
}
|
|
152
|
+
} = params;
|
|
153
|
+
const [apiLoaded, setApiLoaded] = react.useState(typeof window.DM !== 'undefined');
|
|
154
|
+
const [playerReady, setPlayerReady] = react.useState(false);
|
|
155
|
+
const [loaded, setLoaded] = react.useState(false);
|
|
156
|
+
const apiRef = react.useRef(typeof window.DM !== 'undefined' ? window.DM : null);
|
|
157
|
+
const ready = apiLoaded && playerReady;
|
|
158
|
+
const videoId = react.useMemo(() => getVideoId(id), [id]);
|
|
159
|
+
const elementRef = react.useRef(null);
|
|
160
|
+
const playerRef = react.useRef(null);
|
|
161
|
+
const playerElementRef = react.useRef(elementRef.current);
|
|
162
|
+
const elementHasChanged = elementRef.current !== playerElementRef.current;
|
|
163
|
+
const [muted, setMuted] = react.useState(initialMuted);
|
|
164
|
+
const [volume, setVolumeState] = react.useState(initialMuted ? 0 : 1);
|
|
165
|
+
const [playState, setPlayState] = react.useState({
|
|
225
166
|
playing: false,
|
|
226
167
|
paused: false,
|
|
227
168
|
ended: false,
|
|
228
169
|
buffering: false,
|
|
229
170
|
adPlaying: false
|
|
230
|
-
})
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
width: width,
|
|
237
|
-
height: height,
|
|
238
|
-
duration: duration
|
|
239
|
-
}),
|
|
240
|
-
_useState14 = _slicedToArray__default["default"](_useState13, 2),
|
|
241
|
-
metadata = _useState14[0],
|
|
242
|
-
setMetadata = _useState14[1]; // Load SDK
|
|
243
|
-
|
|
171
|
+
});
|
|
172
|
+
const [metadata, setMetadata] = react.useState({
|
|
173
|
+
width,
|
|
174
|
+
height,
|
|
175
|
+
duration
|
|
176
|
+
}); // Load SDK
|
|
244
177
|
|
|
245
|
-
react.useEffect(
|
|
246
|
-
|
|
178
|
+
react.useEffect(() => {
|
|
179
|
+
let canceled = false;
|
|
247
180
|
|
|
248
181
|
if (!apiLoaded && videoId !== null) {
|
|
249
182
|
debug$3('Load API');
|
|
250
|
-
services.loadDailymotion().then(
|
|
183
|
+
services.loadDailymotion().then(api => {
|
|
251
184
|
if (!canceled) {
|
|
252
185
|
apiRef.current = api;
|
|
253
186
|
setApiLoaded(true);
|
|
@@ -256,35 +189,38 @@ var useDailymotionPlayer = function useDailymotionPlayer() {
|
|
|
256
189
|
});
|
|
257
190
|
}
|
|
258
191
|
|
|
259
|
-
return
|
|
192
|
+
return () => {
|
|
260
193
|
canceled = true;
|
|
261
194
|
};
|
|
262
195
|
}, [videoId, apiLoaded, setApiLoaded]); // Create or update player
|
|
263
196
|
|
|
264
|
-
react.useEffect(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
197
|
+
react.useEffect(() => {
|
|
198
|
+
const {
|
|
199
|
+
current: DM = null
|
|
200
|
+
} = apiRef;
|
|
201
|
+
const {
|
|
202
|
+
current: currentPlayer = null
|
|
203
|
+
} = playerRef;
|
|
204
|
+
const {
|
|
205
|
+
current: element = null
|
|
206
|
+
} = elementRef;
|
|
271
207
|
|
|
272
208
|
if (!apiLoaded || videoId === null || element === null) {
|
|
273
209
|
return;
|
|
274
210
|
}
|
|
275
211
|
|
|
276
|
-
|
|
212
|
+
const playerParams = {
|
|
277
213
|
'autoplay-d': autoplay,
|
|
278
214
|
// muted,
|
|
279
|
-
start
|
|
280
|
-
controls
|
|
215
|
+
start,
|
|
216
|
+
controls,
|
|
281
217
|
'queue-autoplay-next': queueAutoplayNext,
|
|
282
218
|
'queue-enable': queueEnable,
|
|
283
219
|
'sharing-enable': sharingEnable,
|
|
284
220
|
'ui-logo': uiLogo,
|
|
285
221
|
'ui-start-screen-info': uiStartScreenInfo
|
|
286
222
|
};
|
|
287
|
-
|
|
223
|
+
let player = currentPlayer;
|
|
288
224
|
|
|
289
225
|
if (player !== null) {
|
|
290
226
|
player.load(videoId, {
|
|
@@ -294,8 +230,8 @@ var useDailymotionPlayer = function useDailymotionPlayer() {
|
|
|
294
230
|
} else {
|
|
295
231
|
player = DM.player(element, {
|
|
296
232
|
video: videoId,
|
|
297
|
-
width
|
|
298
|
-
height
|
|
233
|
+
width,
|
|
234
|
+
height,
|
|
299
235
|
params: playerParams
|
|
300
236
|
});
|
|
301
237
|
debug$3('Create player [ID: %s]', videoId);
|
|
@@ -308,16 +244,17 @@ var useDailymotionPlayer = function useDailymotionPlayer() {
|
|
|
308
244
|
playerRef.current = player;
|
|
309
245
|
playerElementRef.current = element;
|
|
310
246
|
}, [apiLoaded, elementHasChanged, videoId, width, height, autoplay, muted, start, controls, queueAutoplayNext, queueEnable, sharingEnable, uiLogo, uiStartScreenInfo]);
|
|
311
|
-
react.useEffect(
|
|
312
|
-
|
|
313
|
-
|
|
247
|
+
react.useEffect(() => {
|
|
248
|
+
const {
|
|
249
|
+
current: player = null
|
|
250
|
+
} = playerRef;
|
|
314
251
|
|
|
315
252
|
if (player === null) {
|
|
316
|
-
return
|
|
253
|
+
return () => {};
|
|
317
254
|
}
|
|
318
255
|
|
|
319
|
-
|
|
320
|
-
|
|
256
|
+
let currentPlayState = playState;
|
|
257
|
+
let currentMetadata = metadata;
|
|
321
258
|
|
|
322
259
|
function onPlaybackReady() {
|
|
323
260
|
setLoaded(true);
|
|
@@ -325,17 +262,17 @@ var useDailymotionPlayer = function useDailymotionPlayer() {
|
|
|
325
262
|
}
|
|
326
263
|
|
|
327
264
|
function onLoadedMetadata() {
|
|
328
|
-
currentMetadata =
|
|
265
|
+
currentMetadata = { ...currentMetadata,
|
|
329
266
|
duration: player.duration
|
|
330
|
-
}
|
|
267
|
+
};
|
|
331
268
|
setMetadata(currentMetadata);
|
|
332
269
|
debug$3('onLoadedMetadata [ID: %s]', videoId);
|
|
333
270
|
}
|
|
334
271
|
|
|
335
272
|
function onDurationChange() {
|
|
336
|
-
currentMetadata =
|
|
273
|
+
currentMetadata = { ...currentMetadata,
|
|
337
274
|
duration: player.duration
|
|
338
|
-
}
|
|
275
|
+
};
|
|
339
276
|
setMetadata(currentMetadata);
|
|
340
277
|
debug$3('onDurationChange [ID: %s]', videoId);
|
|
341
278
|
}
|
|
@@ -347,63 +284,63 @@ var useDailymotionPlayer = function useDailymotionPlayer() {
|
|
|
347
284
|
}
|
|
348
285
|
|
|
349
286
|
function onPlay() {
|
|
350
|
-
currentPlayState =
|
|
287
|
+
currentPlayState = { ...currentPlayState,
|
|
351
288
|
playing: true,
|
|
352
289
|
paused: false,
|
|
353
290
|
ended: false
|
|
354
|
-
}
|
|
291
|
+
};
|
|
355
292
|
setPlayState(currentPlayState);
|
|
356
293
|
debug$3('onPlay [ID: %s]', videoId);
|
|
357
294
|
}
|
|
358
295
|
|
|
359
296
|
function onPause() {
|
|
360
|
-
currentPlayState =
|
|
297
|
+
currentPlayState = { ...currentPlayState,
|
|
361
298
|
playing: false,
|
|
362
299
|
paused: true,
|
|
363
300
|
ended: false
|
|
364
|
-
}
|
|
301
|
+
};
|
|
365
302
|
setPlayState(currentPlayState);
|
|
366
303
|
debug$3('onPause [ID: %s]', videoId);
|
|
367
304
|
}
|
|
368
305
|
|
|
369
306
|
function onEnd() {
|
|
370
|
-
currentPlayState =
|
|
307
|
+
currentPlayState = { ...currentPlayState,
|
|
371
308
|
playing: false,
|
|
372
309
|
paused: false,
|
|
373
310
|
ended: true
|
|
374
|
-
}
|
|
311
|
+
};
|
|
375
312
|
setPlayState(currentPlayState);
|
|
376
313
|
debug$3('onEnd [ID: %s]', videoId);
|
|
377
314
|
}
|
|
378
315
|
|
|
379
316
|
function onPlaying() {
|
|
380
|
-
currentPlayState =
|
|
317
|
+
currentPlayState = { ...currentPlayState,
|
|
381
318
|
buffering: false
|
|
382
|
-
}
|
|
319
|
+
};
|
|
383
320
|
setPlayState(currentPlayState);
|
|
384
321
|
debug$3('onPlaying [ID: %s]', videoId);
|
|
385
322
|
}
|
|
386
323
|
|
|
387
324
|
function onWaiting() {
|
|
388
|
-
currentPlayState =
|
|
325
|
+
currentPlayState = { ...currentPlayState,
|
|
389
326
|
buffering: true
|
|
390
|
-
}
|
|
327
|
+
};
|
|
391
328
|
setPlayState(currentPlayState);
|
|
392
329
|
debug$3('onWaiting [ID: %s]', videoId);
|
|
393
330
|
}
|
|
394
331
|
|
|
395
332
|
function onAdStart() {
|
|
396
|
-
currentPlayState =
|
|
333
|
+
currentPlayState = { ...currentPlayState,
|
|
397
334
|
adPlaying: true
|
|
398
|
-
}
|
|
335
|
+
};
|
|
399
336
|
setPlayState(currentPlayState);
|
|
400
337
|
debug$3('onAdStart [ID: %s]', videoId);
|
|
401
338
|
}
|
|
402
339
|
|
|
403
340
|
function onAdEnd() {
|
|
404
|
-
currentPlayState =
|
|
341
|
+
currentPlayState = { ...currentPlayState,
|
|
405
342
|
adPlaying: false
|
|
406
|
-
}
|
|
343
|
+
};
|
|
407
344
|
setPlayState(currentPlayState);
|
|
408
345
|
debug$3('onAdEnd [ID: %s]', videoId);
|
|
409
346
|
}
|
|
@@ -419,7 +356,7 @@ var useDailymotionPlayer = function useDailymotionPlayer() {
|
|
|
419
356
|
player.addEventListener('waiting', onWaiting);
|
|
420
357
|
player.addEventListener('ad_start', onAdStart);
|
|
421
358
|
player.addEventListener('ad_end', onAdEnd);
|
|
422
|
-
return
|
|
359
|
+
return () => {
|
|
423
360
|
player.removeEventListener('playback_ready', onPlaybackReady);
|
|
424
361
|
player.removeEventListener('loadedmetadata', onLoadedMetadata);
|
|
425
362
|
player.removeEventListener('durationchange', onDurationChange);
|
|
@@ -433,63 +370,79 @@ var useDailymotionPlayer = function useDailymotionPlayer() {
|
|
|
433
370
|
player.removeEventListener('ad_end', onAdEnd);
|
|
434
371
|
};
|
|
435
372
|
}, [playerRef.current, playerReady, videoId, setLoaded, setPlayState, setMetadata, setVolumeState, setMuted]);
|
|
436
|
-
|
|
437
|
-
|
|
373
|
+
const play = react.useCallback(() => {
|
|
374
|
+
const {
|
|
375
|
+
current: player
|
|
376
|
+
} = playerRef;
|
|
438
377
|
return player !== null ? player.play() : Promise.reject(noPlayerError$1);
|
|
439
378
|
}, []);
|
|
440
|
-
|
|
441
|
-
|
|
379
|
+
const pause = react.useCallback(() => {
|
|
380
|
+
const {
|
|
381
|
+
current: player
|
|
382
|
+
} = playerRef;
|
|
442
383
|
return player !== null ? player.pause() : Promise.reject(noPlayerError$1);
|
|
443
384
|
}, []);
|
|
444
|
-
|
|
445
|
-
|
|
385
|
+
const setVolume = react.useCallback(newVolume => {
|
|
386
|
+
const {
|
|
387
|
+
current: player
|
|
388
|
+
} = playerRef;
|
|
446
389
|
return player !== null ? player.setVolume(newVolume) : Promise.reject(noPlayerError$1);
|
|
447
390
|
}, []);
|
|
448
|
-
|
|
449
|
-
|
|
391
|
+
const mute = react.useCallback(() => {
|
|
392
|
+
const {
|
|
393
|
+
current: player
|
|
394
|
+
} = playerRef;
|
|
450
395
|
return player !== null ? player.setMute(true) : Promise.reject(noPlayerError$1);
|
|
451
396
|
}, []);
|
|
452
|
-
|
|
453
|
-
|
|
397
|
+
const unmute = react.useCallback(() => {
|
|
398
|
+
const {
|
|
399
|
+
current: player
|
|
400
|
+
} = playerRef;
|
|
454
401
|
return player !== null ? player.setMute(false) : Promise.reject(noPlayerError$1);
|
|
455
402
|
}, []);
|
|
456
|
-
|
|
457
|
-
|
|
403
|
+
const seek = react.useCallback(time => {
|
|
404
|
+
const {
|
|
405
|
+
current: player
|
|
406
|
+
} = playerRef;
|
|
458
407
|
return player !== null ? player.seek(time) : Promise.reject(noPlayerError$1);
|
|
459
408
|
}, []);
|
|
460
|
-
|
|
461
|
-
|
|
409
|
+
const {
|
|
410
|
+
playing
|
|
411
|
+
} = playState;
|
|
412
|
+
const currentTime = usePlayerCurrentTime(playerRef.current, {
|
|
462
413
|
id: videoId,
|
|
463
414
|
disabled: !playing || timeUpdateInterval === null,
|
|
464
415
|
updateInterval: timeUpdateInterval,
|
|
465
416
|
onUpdate: customOnTimeUpdate
|
|
466
417
|
});
|
|
467
|
-
return
|
|
418
|
+
return {
|
|
468
419
|
ref: elementRef,
|
|
469
420
|
player: playerRef.current,
|
|
470
|
-
ready
|
|
471
|
-
play
|
|
472
|
-
pause
|
|
473
|
-
mute
|
|
474
|
-
unmute
|
|
475
|
-
setVolume
|
|
476
|
-
seek
|
|
477
|
-
currentTime
|
|
478
|
-
loaded
|
|
479
|
-
muted
|
|
480
|
-
volume
|
|
481
|
-
|
|
421
|
+
ready,
|
|
422
|
+
play,
|
|
423
|
+
pause,
|
|
424
|
+
mute,
|
|
425
|
+
unmute,
|
|
426
|
+
setVolume,
|
|
427
|
+
seek,
|
|
428
|
+
currentTime,
|
|
429
|
+
loaded,
|
|
430
|
+
muted,
|
|
431
|
+
volume,
|
|
432
|
+
...metadata,
|
|
433
|
+
...playState
|
|
434
|
+
};
|
|
482
435
|
};
|
|
483
436
|
|
|
484
|
-
|
|
437
|
+
const eventsManager$1 = typeof document !== 'undefined' ? new EventsManager__default["default"](document) : null;
|
|
485
438
|
|
|
486
|
-
|
|
487
|
-
react.useEffect(
|
|
439
|
+
const useDocumentEvent = (event, callback) => {
|
|
440
|
+
react.useEffect(() => {
|
|
488
441
|
if (eventsManager$1 !== null && callback !== null) {
|
|
489
442
|
eventsManager$1.subscribe(event, callback);
|
|
490
443
|
}
|
|
491
444
|
|
|
492
|
-
return
|
|
445
|
+
return () => {
|
|
493
446
|
if (eventsManager$1 !== null && callback !== null) {
|
|
494
447
|
eventsManager$1.unsubscribe(event, callback);
|
|
495
448
|
}
|
|
@@ -497,15 +450,15 @@ var useDocumentEvent = function useDocumentEvent(event, callback) {
|
|
|
497
450
|
}, [event, callback]);
|
|
498
451
|
};
|
|
499
452
|
|
|
500
|
-
|
|
453
|
+
const eventsManager = typeof window !== 'undefined' ? new EventsManager__default["default"](window) : null;
|
|
501
454
|
|
|
502
|
-
|
|
503
|
-
react.useEffect(
|
|
455
|
+
const useWindowEvent = (event, callback) => {
|
|
456
|
+
react.useEffect(() => {
|
|
504
457
|
if (eventsManager !== null && callback !== null) {
|
|
505
458
|
eventsManager.subscribe(event, callback);
|
|
506
459
|
}
|
|
507
460
|
|
|
508
|
-
return
|
|
461
|
+
return () => {
|
|
509
462
|
if (eventsManager !== null && callback !== null) {
|
|
510
463
|
eventsManager.unsubscribe(event, callback);
|
|
511
464
|
}
|
|
@@ -514,10 +467,12 @@ var useWindowEvent = function useWindowEvent(event, callback) {
|
|
|
514
467
|
};
|
|
515
468
|
|
|
516
469
|
function useKeyboard() {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
470
|
+
let keyMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
471
|
+
const onKeyDown = react.useCallback(event => {
|
|
472
|
+
const {
|
|
473
|
+
key
|
|
474
|
+
} = event;
|
|
475
|
+
let callback = null;
|
|
521
476
|
|
|
522
477
|
if (typeof keyMap === 'function') {
|
|
523
478
|
callback = keyMap;
|
|
@@ -529,9 +484,11 @@ function useKeyboard() {
|
|
|
529
484
|
callback(event);
|
|
530
485
|
}
|
|
531
486
|
}, [keyMap]);
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
487
|
+
const onKeyUp = react.useCallback(event => {
|
|
488
|
+
const {
|
|
489
|
+
key
|
|
490
|
+
} = event;
|
|
491
|
+
let callback = null;
|
|
535
492
|
|
|
536
493
|
if (typeof keyMap === 'function') {
|
|
537
494
|
callback = keyMap;
|
|
@@ -547,68 +504,274 @@ function useKeyboard() {
|
|
|
547
504
|
useWindowEvent('keyup', keyMap !== null ? onKeyUp : null);
|
|
548
505
|
}
|
|
549
506
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
507
|
+
const useItemsPaginated = function (loader) {
|
|
508
|
+
let {
|
|
509
|
+
page = null,
|
|
510
|
+
count = 10,
|
|
511
|
+
pages: initialPages = null,
|
|
512
|
+
getPageFromResponse = _ref2 => {
|
|
513
|
+
let {
|
|
514
|
+
pagination: {
|
|
515
|
+
page: currentPage,
|
|
516
|
+
last_page: lastPage,
|
|
517
|
+
total
|
|
518
|
+
},
|
|
519
|
+
data: items
|
|
520
|
+
} = _ref2;
|
|
521
|
+
return {
|
|
522
|
+
page: parseInt(currentPage, 10),
|
|
523
|
+
lastPage: parseInt(lastPage, 10),
|
|
524
|
+
total: parseInt(total, 10),
|
|
525
|
+
items
|
|
526
|
+
};
|
|
527
|
+
},
|
|
528
|
+
onLoaded = null,
|
|
529
|
+
onError = null,
|
|
530
|
+
query = null
|
|
531
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
532
|
+
const lastState = react.useRef(null);
|
|
533
|
+
const initialState = react.useMemo(() => {
|
|
534
|
+
const finalInitialPages = initialPages !== null ? initialPages.map(it => getPageFromResponse(it)) : null;
|
|
535
|
+
const finalLastPage = finalInitialPages !== null ? finalInitialPages.reduce((currentLastPage, _ref3) => {
|
|
536
|
+
let {
|
|
537
|
+
lastPage: initialLastPage
|
|
538
|
+
} = _ref3;
|
|
539
|
+
return initialLastPage > currentLastPage ? initialLastPage : currentLastPage;
|
|
540
|
+
}, -1) : -1;
|
|
541
|
+
return {
|
|
542
|
+
lastPage: finalLastPage,
|
|
543
|
+
total: finalInitialPages !== null ? finalInitialPages[0].total : 0,
|
|
544
|
+
loaded: finalLastPage !== -1 && finalInitialPages !== null && finalInitialPages.length === finalLastPage,
|
|
545
|
+
loading: false,
|
|
546
|
+
pages: finalInitialPages !== null ? finalInitialPages : null
|
|
547
|
+
};
|
|
548
|
+
}, [initialPages]);
|
|
549
|
+
const currentPagesRef = react.useRef(initialState.pages);
|
|
550
|
+
const [state, setState] = react.useState(initialState);
|
|
551
|
+
const {
|
|
552
|
+
lastPage,
|
|
553
|
+
loaded,
|
|
554
|
+
loading,
|
|
555
|
+
pages,
|
|
556
|
+
total
|
|
557
|
+
} = state;
|
|
558
|
+
const items = pages !== null ? pages.reduce((pagesItems, _ref4) => {
|
|
559
|
+
let {
|
|
560
|
+
items: pageItems
|
|
561
|
+
} = _ref4;
|
|
562
|
+
return pagesItems.concat(pageItems);
|
|
563
|
+
}, []) : null;
|
|
564
|
+
|
|
565
|
+
const updateState = update => setState({ ...state,
|
|
566
|
+
...update
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
const updateFromResponse = function (response) {
|
|
570
|
+
let error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
571
|
+
let reset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
572
|
+
|
|
573
|
+
if (error !== null) {
|
|
574
|
+
updateState({
|
|
575
|
+
loaded: false,
|
|
576
|
+
loading: false
|
|
577
|
+
});
|
|
578
|
+
throw error;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
const newPage = getPageFromResponse(response);
|
|
582
|
+
const currentPages = currentPagesRef.current || [];
|
|
583
|
+
const newPages = (reset ? [newPage] : [...currentPages.filter(it => it.page !== newPage.page), newPage]).sort((a, b) => {
|
|
584
|
+
const {
|
|
585
|
+
page: aPage = null
|
|
586
|
+
} = a;
|
|
587
|
+
const {
|
|
588
|
+
page: bPage = null
|
|
589
|
+
} = b;
|
|
590
|
+
const hasObject = aPage !== null && bPage !== null;
|
|
591
|
+
|
|
592
|
+
if (hasObject) {
|
|
593
|
+
if (aPage === bPage) {
|
|
594
|
+
return 0;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
return aPage > bPage ? 1 : -1;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
if (isNumber__default["default"](a) && isNumber__default["default"](b)) {
|
|
601
|
+
if (a === b) {
|
|
602
|
+
return 0;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
return a > b ? 1 : -1;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
return 0;
|
|
609
|
+
});
|
|
610
|
+
currentPagesRef.current = newPages;
|
|
611
|
+
updateState({
|
|
612
|
+
loaded: true,
|
|
613
|
+
loading: false,
|
|
614
|
+
lastPage: newPage.lastPage,
|
|
615
|
+
total: newPage.total,
|
|
616
|
+
pages: newPages
|
|
617
|
+
});
|
|
618
|
+
return newPage;
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
const getNextPage = () => {
|
|
622
|
+
const allPages = lastPage !== -1 ? Array.call(null, ...Array(lastPage)).map((it, index) => index + 1) : [];
|
|
623
|
+
const currentPages = currentPagesRef.current || [];
|
|
624
|
+
const remainingPages = allPages.filter(pageNumber => currentPages.findIndex(it => it.page === pageNumber) === -1);
|
|
625
|
+
const firstItem = remainingPages.length > 0 ? remainingPages.shift() : null;
|
|
626
|
+
return firstItem !== null ? firstItem : null;
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
const loadItems = requestPage => {
|
|
630
|
+
updateState({
|
|
631
|
+
loading: true
|
|
632
|
+
});
|
|
633
|
+
return cancelablePromise.cancelable(loader(requestPage, count)).then(response => updateFromResponse(response)).catch(error => updateFromResponse(null, error)).then(response => {
|
|
634
|
+
if (onLoaded !== null) {
|
|
635
|
+
onLoaded(response);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
return response;
|
|
639
|
+
}).catch(error => {
|
|
640
|
+
if (onError !== null) {
|
|
641
|
+
onError(error);
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
const loadPage = pageToLoad => {
|
|
647
|
+
if (loading) {
|
|
648
|
+
return Promise.reject();
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
const currentPages = currentPagesRef.current || [];
|
|
652
|
+
const foundPage = currentPages.find(it => it.page === pageToLoad) || null;
|
|
653
|
+
|
|
654
|
+
if (foundPage !== null) {
|
|
655
|
+
return Promise.resolve(foundPage);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return loadItems(pageToLoad);
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
const loadNextPage = () => {
|
|
662
|
+
if (loading) {
|
|
663
|
+
return Promise.reject();
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
const nextPage = getNextPage();
|
|
667
|
+
return nextPage !== null ? loadItems(nextPage) : Promise.resolve();
|
|
668
|
+
}; // Reset all on query change
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
react.useEffect(() => {
|
|
672
|
+
const hadState = lastState.current !== null;
|
|
673
|
+
|
|
674
|
+
if (hadState) {
|
|
675
|
+
currentPagesRef.current = null;
|
|
676
|
+
updateState({
|
|
677
|
+
loaded: true,
|
|
678
|
+
loading: false,
|
|
679
|
+
lastPage: null,
|
|
680
|
+
total: 0,
|
|
681
|
+
pages: []
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
}, [query]);
|
|
685
|
+
react.useEffect(() => {
|
|
686
|
+
const hadState = lastState.current !== null;
|
|
687
|
+
lastState.current = initialState;
|
|
688
|
+
|
|
689
|
+
if (hadState) {
|
|
690
|
+
currentPagesRef.current = initialState.pages;
|
|
691
|
+
setState(initialState);
|
|
692
|
+
}
|
|
693
|
+
}, [initialState]);
|
|
694
|
+
react.useEffect(() => {
|
|
695
|
+
if (loader === null) {
|
|
696
|
+
return () => {};
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
let loadPromise = null;
|
|
700
|
+
const pageToLoad = initialPages === null && page === null ? 1 : page;
|
|
701
|
+
|
|
702
|
+
if (pageToLoad !== null) {
|
|
703
|
+
loadPromise = loadItems(pageToLoad);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
return () => {
|
|
707
|
+
if (loadPromise !== null) {
|
|
708
|
+
loadPromise.cancel();
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
}, [loader, page]);
|
|
712
|
+
const currentPage = pages !== null ? pages.find(_ref5 => {
|
|
713
|
+
let {
|
|
714
|
+
page: pageNumber
|
|
715
|
+
} = _ref5;
|
|
716
|
+
return parseInt(pageNumber, 10) === parseInt(page, 10);
|
|
717
|
+
}) || null : null;
|
|
718
|
+
return {
|
|
719
|
+
items,
|
|
720
|
+
pages,
|
|
721
|
+
currentPage,
|
|
722
|
+
pageItems: currentPage !== null ? currentPage.items : null,
|
|
723
|
+
total,
|
|
724
|
+
lastPage,
|
|
725
|
+
loaded,
|
|
726
|
+
allLoaded: lastPage !== -1 && pages.length === lastPage,
|
|
727
|
+
loading,
|
|
728
|
+
loadNextPage,
|
|
729
|
+
loadPage
|
|
730
|
+
};
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
const debug$2 = createDebug__default["default"]('folklore:video:native');
|
|
734
|
+
const noPlayerError = new Error('No player');
|
|
735
|
+
|
|
736
|
+
const useNativeVideoPlayer = function (url) {
|
|
737
|
+
let {
|
|
738
|
+
width = 0,
|
|
739
|
+
height = 0,
|
|
740
|
+
duration = 0,
|
|
741
|
+
initialMuted = false,
|
|
742
|
+
timeUpdateInterval = 1000,
|
|
743
|
+
onTimeUpdate: customOnTimeUpdate = null
|
|
744
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
745
|
+
const elementRef = react.useRef(null);
|
|
746
|
+
const [loaded, setLoaded] = react.useState(false);
|
|
747
|
+
const [volume, setVolumeState] = react.useState(initialMuted ? 0 : 1);
|
|
748
|
+
const [playState, setPlayState] = react.useState({
|
|
584
749
|
playing: false,
|
|
585
750
|
paused: false,
|
|
586
751
|
ended: false,
|
|
587
752
|
buffering: false
|
|
588
|
-
})
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
_useState8 = _slicedToArray__default["default"](_useState7, 2),
|
|
599
|
-
metadata = _useState8[0],
|
|
600
|
-
setMetadata = _useState8[1];
|
|
601
|
-
|
|
602
|
-
var play = react.useCallback(function () {
|
|
603
|
-
var player = elementRef.current;
|
|
753
|
+
});
|
|
754
|
+
const [metadata, setMetadata] = react.useState({
|
|
755
|
+
width,
|
|
756
|
+
height,
|
|
757
|
+
duration
|
|
758
|
+
});
|
|
759
|
+
const play = react.useCallback(() => {
|
|
760
|
+
const {
|
|
761
|
+
current: player
|
|
762
|
+
} = elementRef;
|
|
604
763
|
return player !== null ? player.play() : Promise.reject(noPlayerError);
|
|
605
764
|
}, []);
|
|
606
|
-
|
|
607
|
-
|
|
765
|
+
const pause = react.useCallback(() => {
|
|
766
|
+
const {
|
|
767
|
+
current: player
|
|
768
|
+
} = elementRef;
|
|
608
769
|
return player !== null ? player.pause() : Promise.reject(noPlayerError);
|
|
609
770
|
}, []);
|
|
610
|
-
|
|
611
|
-
|
|
771
|
+
const setVolume = react.useCallback(newVolume => {
|
|
772
|
+
const {
|
|
773
|
+
current: player
|
|
774
|
+
} = elementRef;
|
|
612
775
|
|
|
613
776
|
if (player !== null) {
|
|
614
777
|
player.volume = newVolume;
|
|
@@ -617,8 +780,10 @@ var useNativeVideoPlayer = function useNativeVideoPlayer(url) {
|
|
|
617
780
|
|
|
618
781
|
return Promise.reject(noPlayerError);
|
|
619
782
|
}, []);
|
|
620
|
-
|
|
621
|
-
|
|
783
|
+
const mute = react.useCallback(() => {
|
|
784
|
+
const {
|
|
785
|
+
current: player
|
|
786
|
+
} = elementRef;
|
|
622
787
|
|
|
623
788
|
if (player !== null) {
|
|
624
789
|
player.muted = true;
|
|
@@ -627,8 +792,10 @@ var useNativeVideoPlayer = function useNativeVideoPlayer(url) {
|
|
|
627
792
|
|
|
628
793
|
return Promise.reject(noPlayerError);
|
|
629
794
|
}, []);
|
|
630
|
-
|
|
631
|
-
|
|
795
|
+
const unmute = react.useCallback(() => {
|
|
796
|
+
const {
|
|
797
|
+
current: player
|
|
798
|
+
} = elementRef;
|
|
632
799
|
|
|
633
800
|
if (player !== null) {
|
|
634
801
|
player.muted = false;
|
|
@@ -637,8 +804,10 @@ var useNativeVideoPlayer = function useNativeVideoPlayer(url) {
|
|
|
637
804
|
|
|
638
805
|
return Promise.reject(noPlayerError);
|
|
639
806
|
}, []);
|
|
640
|
-
|
|
641
|
-
|
|
807
|
+
const seek = react.useCallback(newTime => {
|
|
808
|
+
const {
|
|
809
|
+
current: player
|
|
810
|
+
} = elementRef;
|
|
642
811
|
|
|
643
812
|
if (player !== null) {
|
|
644
813
|
player.currentTime = newTime;
|
|
@@ -647,8 +816,10 @@ var useNativeVideoPlayer = function useNativeVideoPlayer(url) {
|
|
|
647
816
|
|
|
648
817
|
return Promise.reject(noPlayerError);
|
|
649
818
|
}, []);
|
|
650
|
-
|
|
651
|
-
|
|
819
|
+
const setLoop = react.useCallback(newLoop => {
|
|
820
|
+
const {
|
|
821
|
+
current: player
|
|
822
|
+
} = elementRef;
|
|
652
823
|
|
|
653
824
|
if (player !== null) {
|
|
654
825
|
player.loop = newLoop;
|
|
@@ -658,20 +829,22 @@ var useNativeVideoPlayer = function useNativeVideoPlayer(url) {
|
|
|
658
829
|
return Promise.reject(noPlayerError);
|
|
659
830
|
}, []); // Bind player events
|
|
660
831
|
|
|
661
|
-
react.useEffect(
|
|
662
|
-
|
|
832
|
+
react.useEffect(() => {
|
|
833
|
+
const {
|
|
834
|
+
current: player
|
|
835
|
+
} = elementRef;
|
|
663
836
|
|
|
664
837
|
if (player === null) {
|
|
665
|
-
return
|
|
838
|
+
return () => {};
|
|
666
839
|
}
|
|
667
840
|
|
|
668
|
-
|
|
841
|
+
const onCanPlay = () => {
|
|
669
842
|
setLoaded(true);
|
|
670
843
|
debug$2('onCanPlay [URL: %s]', url);
|
|
671
844
|
};
|
|
672
845
|
|
|
673
|
-
|
|
674
|
-
|
|
846
|
+
const onMetadataLoaded = () => {
|
|
847
|
+
const newMetadata = {
|
|
675
848
|
duration: player.duration,
|
|
676
849
|
width: player.videoWidth,
|
|
677
850
|
height: player.videoHeight
|
|
@@ -680,7 +853,7 @@ var useNativeVideoPlayer = function useNativeVideoPlayer(url) {
|
|
|
680
853
|
debug$2('onMetadataLoaded [URL: %s]', url);
|
|
681
854
|
};
|
|
682
855
|
|
|
683
|
-
|
|
856
|
+
const onPlay = () => {
|
|
684
857
|
setPlayState({
|
|
685
858
|
playing: true,
|
|
686
859
|
paused: false,
|
|
@@ -690,7 +863,7 @@ var useNativeVideoPlayer = function useNativeVideoPlayer(url) {
|
|
|
690
863
|
debug$2('onPlay [URL: %s]', url);
|
|
691
864
|
};
|
|
692
865
|
|
|
693
|
-
|
|
866
|
+
const onPause = () => {
|
|
694
867
|
setPlayState({
|
|
695
868
|
playing: false,
|
|
696
869
|
paused: true,
|
|
@@ -700,7 +873,7 @@ var useNativeVideoPlayer = function useNativeVideoPlayer(url) {
|
|
|
700
873
|
debug$2('onPause [URL: %s]', url);
|
|
701
874
|
};
|
|
702
875
|
|
|
703
|
-
|
|
876
|
+
const onEnded = () => {
|
|
704
877
|
setPlayState({
|
|
705
878
|
playing: false,
|
|
706
879
|
paused: false,
|
|
@@ -716,7 +889,7 @@ var useNativeVideoPlayer = function useNativeVideoPlayer(url) {
|
|
|
716
889
|
player.addEventListener('play', onPlay);
|
|
717
890
|
player.addEventListener('pause', onPause);
|
|
718
891
|
player.addEventListener('ended', onEnded);
|
|
719
|
-
return
|
|
892
|
+
return () => {
|
|
720
893
|
debug$2('Unbind events [URL: %s]', url);
|
|
721
894
|
player.removeEventListener('canplay', onCanPlay);
|
|
722
895
|
player.removeEventListener('metadataloaded', onMetadataLoaded);
|
|
@@ -725,90 +898,79 @@ var useNativeVideoPlayer = function useNativeVideoPlayer(url) {
|
|
|
725
898
|
player.removeEventListener('ended', onEnded);
|
|
726
899
|
};
|
|
727
900
|
}, [url, elementRef.current, setPlayState, setMetadata, setVolumeState, setLoaded]);
|
|
728
|
-
|
|
729
|
-
|
|
901
|
+
const {
|
|
902
|
+
playing
|
|
903
|
+
} = playState;
|
|
904
|
+
const currentTime = usePlayerCurrentTime(elementRef.current, {
|
|
730
905
|
id: url,
|
|
731
906
|
disabled: !playing || timeUpdateInterval === null,
|
|
732
907
|
updateInterval: timeUpdateInterval,
|
|
733
908
|
onUpdate: customOnTimeUpdate
|
|
734
909
|
});
|
|
735
|
-
return
|
|
910
|
+
return {
|
|
736
911
|
ref: elementRef,
|
|
737
912
|
player: elementRef.current,
|
|
738
|
-
play
|
|
739
|
-
pause
|
|
740
|
-
mute
|
|
741
|
-
unmute
|
|
742
|
-
setVolume
|
|
743
|
-
seek
|
|
744
|
-
setLoop
|
|
913
|
+
play,
|
|
914
|
+
pause,
|
|
915
|
+
mute,
|
|
916
|
+
unmute,
|
|
917
|
+
setVolume,
|
|
918
|
+
seek,
|
|
919
|
+
setLoop,
|
|
745
920
|
ready: true,
|
|
746
|
-
currentTime
|
|
747
|
-
loaded
|
|
921
|
+
currentTime,
|
|
922
|
+
loaded,
|
|
748
923
|
muted: volume === 0,
|
|
749
|
-
volume
|
|
750
|
-
|
|
924
|
+
volume,
|
|
925
|
+
...metadata,
|
|
926
|
+
...playState
|
|
927
|
+
};
|
|
751
928
|
};
|
|
752
929
|
|
|
753
|
-
|
|
930
|
+
const observersCache = new Map();
|
|
754
931
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
rootMargin = _ref.rootMargin,
|
|
762
|
-
_ref$threshold = _ref.threshold,
|
|
763
|
-
threshold = _ref$threshold === void 0 ? null : _ref$threshold;
|
|
932
|
+
const getOptionsKey = _ref => {
|
|
933
|
+
let {
|
|
934
|
+
root = null,
|
|
935
|
+
rootMargin,
|
|
936
|
+
threshold = null
|
|
937
|
+
} = _ref;
|
|
764
938
|
return "root_".concat(root, "_rootMargin_").concat(rootMargin || null, "_threshold_").concat(threshold);
|
|
765
939
|
};
|
|
766
940
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
941
|
+
const createObserver = function (Observer) {
|
|
942
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
943
|
+
let subscribers = [];
|
|
770
944
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
return it.element === element;
|
|
774
|
-
}) || null;
|
|
945
|
+
const addSubscriber = (element, callback) => {
|
|
946
|
+
const currentSubscriber = subscribers.find(it => it.element === element) || null;
|
|
775
947
|
|
|
776
948
|
if (currentSubscriber !== null) {
|
|
777
|
-
return subscribers.map(
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
}) : it;
|
|
781
|
-
}).filter(function (it) {
|
|
782
|
-
return it.callbacks.length > 0;
|
|
783
|
-
});
|
|
949
|
+
return subscribers.map(it => it.element === element && it.callbacks.indexOf(callback) === -1 ? { ...it,
|
|
950
|
+
callbacks: [...it.callbacks, callback]
|
|
951
|
+
} : it).filter(it => it.callbacks.length > 0);
|
|
784
952
|
}
|
|
785
953
|
|
|
786
|
-
return [
|
|
787
|
-
element
|
|
954
|
+
return [...subscribers, {
|
|
955
|
+
element,
|
|
788
956
|
callbacks: [callback]
|
|
789
|
-
}]
|
|
957
|
+
}];
|
|
790
958
|
};
|
|
791
959
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
callbacks: it.callbacks.filter(function (subCallback) {
|
|
796
|
-
return subCallback !== callback;
|
|
797
|
-
})
|
|
798
|
-
}) : it;
|
|
799
|
-
}).filter(function (it) {
|
|
800
|
-
return it.callbacks.length > 0;
|
|
801
|
-
});
|
|
802
|
-
};
|
|
960
|
+
const removeSubscriber = (element, callback) => subscribers.map(it => it.element === element ? { ...it,
|
|
961
|
+
callbacks: it.callbacks.filter(subCallback => subCallback !== callback)
|
|
962
|
+
} : it).filter(it => it.callbacks.length > 0);
|
|
803
963
|
|
|
804
|
-
|
|
805
|
-
entries.forEach(
|
|
806
|
-
subscribers.forEach(
|
|
807
|
-
|
|
808
|
-
|
|
964
|
+
const onUpdate = entries => {
|
|
965
|
+
entries.forEach(entry => {
|
|
966
|
+
subscribers.forEach(_ref2 => {
|
|
967
|
+
let {
|
|
968
|
+
element,
|
|
969
|
+
callbacks
|
|
970
|
+
} = _ref2;
|
|
809
971
|
|
|
810
972
|
if (element === entry.target) {
|
|
811
|
-
callbacks.forEach(
|
|
973
|
+
callbacks.forEach(callback => {
|
|
812
974
|
callback(entry);
|
|
813
975
|
});
|
|
814
976
|
}
|
|
@@ -816,33 +978,29 @@ var createObserver = function createObserver(Observer) {
|
|
|
816
978
|
});
|
|
817
979
|
};
|
|
818
980
|
|
|
819
|
-
|
|
981
|
+
const observer = new Observer(onUpdate, options);
|
|
820
982
|
|
|
821
|
-
|
|
822
|
-
|
|
983
|
+
const unsubscribe = function (element) {
|
|
984
|
+
let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
823
985
|
subscribers = removeSubscriber(element, callback);
|
|
824
986
|
|
|
825
987
|
if (typeof observer.unobserve === 'undefined') {
|
|
826
988
|
observer.disconnect();
|
|
827
|
-
subscribers.forEach(
|
|
989
|
+
subscribers.forEach(subscriber => {
|
|
828
990
|
observer.observe(subscriber.element);
|
|
829
991
|
});
|
|
830
992
|
return;
|
|
831
993
|
}
|
|
832
994
|
|
|
833
|
-
|
|
834
|
-
return it.element === element;
|
|
835
|
-
}) || null;
|
|
995
|
+
const currentSubscriber = subscribers.find(it => it.element === element) || null;
|
|
836
996
|
|
|
837
997
|
if (currentSubscriber === null) {
|
|
838
998
|
observer.unobserve(element);
|
|
839
999
|
}
|
|
840
1000
|
};
|
|
841
1001
|
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
return it.element === element;
|
|
845
|
-
}) || null;
|
|
1002
|
+
const subscribe = (element, callback) => {
|
|
1003
|
+
const currentSubscriber = subscribers.find(it => it.element === element) || null;
|
|
846
1004
|
subscribers = addSubscriber(element, callback);
|
|
847
1005
|
|
|
848
1006
|
if (currentSubscriber === null) {
|
|
@@ -851,21 +1009,21 @@ var createObserver = function createObserver(Observer) {
|
|
|
851
1009
|
};
|
|
852
1010
|
|
|
853
1011
|
return {
|
|
854
|
-
subscribe
|
|
855
|
-
unsubscribe
|
|
856
|
-
observer
|
|
1012
|
+
subscribe,
|
|
1013
|
+
unsubscribe,
|
|
1014
|
+
observer
|
|
857
1015
|
};
|
|
858
1016
|
};
|
|
859
1017
|
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
1018
|
+
const getObserver = function (Observer) {
|
|
1019
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1020
|
+
const observerKey = getOptionsKey(options);
|
|
863
1021
|
|
|
864
1022
|
if (!observersCache.has(Observer)) {
|
|
865
1023
|
observersCache.set(Observer, {});
|
|
866
1024
|
}
|
|
867
1025
|
|
|
868
|
-
|
|
1026
|
+
const observers = observersCache.get(Observer);
|
|
869
1027
|
|
|
870
1028
|
if (typeof observers[observerKey] === 'undefined') {
|
|
871
1029
|
observers[observerKey] = createObserver(Observer, options);
|
|
@@ -874,37 +1032,30 @@ var getObserver = function getObserver(Observer) {
|
|
|
874
1032
|
|
|
875
1033
|
return observers[observerKey];
|
|
876
1034
|
};
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
var nodeElement = nodeRef.current;
|
|
899
|
-
|
|
900
|
-
var callback = function callback(newEntry) {
|
|
901
|
-
return setEntry(newEntry);
|
|
902
|
-
};
|
|
903
|
-
|
|
904
|
-
var unsubscribe = null;
|
|
1035
|
+
const useObserver = function (Observer) {
|
|
1036
|
+
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1037
|
+
let initialEntry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1038
|
+
const {
|
|
1039
|
+
root = null,
|
|
1040
|
+
rootMargin = null,
|
|
1041
|
+
threshold = null,
|
|
1042
|
+
disabled = false
|
|
1043
|
+
} = opts;
|
|
1044
|
+
const [entry, setEntry] = react.useState(initialEntry);
|
|
1045
|
+
const nodeRef = react.useRef(null);
|
|
1046
|
+
const currentElement = react.useRef(null);
|
|
1047
|
+
const elementChanged = nodeRef.current !== currentElement.current;
|
|
1048
|
+
react.useEffect(() => {
|
|
1049
|
+
const {
|
|
1050
|
+
current: nodeElement
|
|
1051
|
+
} = nodeRef;
|
|
1052
|
+
|
|
1053
|
+
const callback = newEntry => setEntry(newEntry);
|
|
1054
|
+
|
|
1055
|
+
let unsubscribe = null;
|
|
905
1056
|
|
|
906
1057
|
if (nodeElement !== null) {
|
|
907
|
-
|
|
1058
|
+
const newOpts = {};
|
|
908
1059
|
|
|
909
1060
|
if (root !== null) {
|
|
910
1061
|
newOpts.root = root;
|
|
@@ -918,16 +1069,16 @@ var useObserver = function useObserver(Observer) {
|
|
|
918
1069
|
newOpts.threshold = threshold;
|
|
919
1070
|
}
|
|
920
1071
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
1072
|
+
const {
|
|
1073
|
+
subscribe,
|
|
1074
|
+
unsubscribe: localUnsubscribe
|
|
1075
|
+
} = getObserver(Observer, newOpts);
|
|
925
1076
|
unsubscribe = localUnsubscribe;
|
|
926
1077
|
subscribe(nodeElement, callback);
|
|
927
1078
|
}
|
|
928
1079
|
|
|
929
1080
|
currentElement.current = nodeElement;
|
|
930
|
-
return
|
|
1081
|
+
return () => {
|
|
931
1082
|
if (unsubscribe !== null) {
|
|
932
1083
|
unsubscribe(nodeElement, callback);
|
|
933
1084
|
}
|
|
@@ -935,14 +1086,14 @@ var useObserver = function useObserver(Observer) {
|
|
|
935
1086
|
}, [Observer, elementChanged, disabled, root, rootMargin, threshold]);
|
|
936
1087
|
return {
|
|
937
1088
|
ref: nodeRef,
|
|
938
|
-
entry
|
|
1089
|
+
entry
|
|
939
1090
|
};
|
|
940
1091
|
};
|
|
941
1092
|
/**
|
|
942
1093
|
* Intersection Observer
|
|
943
1094
|
*/
|
|
944
1095
|
|
|
945
|
-
|
|
1096
|
+
const intersectionObserverInitialEntry = {
|
|
946
1097
|
target: null,
|
|
947
1098
|
time: null,
|
|
948
1099
|
isVisible: false,
|
|
@@ -952,130 +1103,89 @@ var intersectionObserverInitialEntry = {
|
|
|
952
1103
|
boundingClientRect: null,
|
|
953
1104
|
rootBounds: null
|
|
954
1105
|
};
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
threshold = _ref3$threshold === void 0 ? [0, 1.0] : _ref3$threshold,
|
|
963
|
-
_ref3$disabled = _ref3.disabled,
|
|
964
|
-
disabled = _ref3$disabled === void 0 ? false : _ref3$disabled;
|
|
965
|
-
|
|
1106
|
+
const useIntersectionObserver = function () {
|
|
1107
|
+
let {
|
|
1108
|
+
root = null,
|
|
1109
|
+
rootMargin = '0px',
|
|
1110
|
+
threshold = [0, 1.0],
|
|
1111
|
+
disabled = false
|
|
1112
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
966
1113
|
return useObserver(IntersectionObserver, {
|
|
967
|
-
root
|
|
968
|
-
rootMargin
|
|
969
|
-
threshold
|
|
970
|
-
disabled
|
|
1114
|
+
root,
|
|
1115
|
+
rootMargin,
|
|
1116
|
+
threshold,
|
|
1117
|
+
disabled
|
|
971
1118
|
}, intersectionObserverInitialEntry);
|
|
972
1119
|
};
|
|
973
1120
|
/**
|
|
974
1121
|
* Resize Observer
|
|
975
1122
|
*/
|
|
976
1123
|
|
|
977
|
-
|
|
1124
|
+
const resizeObserverInitialEntry = {
|
|
978
1125
|
target: null,
|
|
979
1126
|
contentRect: null,
|
|
980
1127
|
contentBoxSize: null,
|
|
981
1128
|
borderBoxSize: null
|
|
982
1129
|
};
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1130
|
+
const useResizeObserver = function () {
|
|
1131
|
+
let {
|
|
1132
|
+
disabled = false
|
|
1133
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
988
1134
|
return useObserver(ResizeObserver, {
|
|
989
|
-
disabled
|
|
1135
|
+
disabled
|
|
990
1136
|
}, resizeObserverInitialEntry);
|
|
991
1137
|
};
|
|
992
1138
|
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
996
|
-
var NO_PLAYER_ERROR$1 = new Error('No player');
|
|
997
|
-
var debug$1 = createDebug__default["default"]('folklore:video:youtube');
|
|
1139
|
+
const NO_PLAYER_ERROR$1 = new Error('No player');
|
|
1140
|
+
const debug$1 = createDebug__default["default"]('folklore:video:youtube');
|
|
998
1141
|
|
|
999
1142
|
function useYouTubePlayer(id) {
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
initialMuted = _ref$muted === void 0 ? false : _ref$muted,
|
|
1015
|
-
_ref$onVolumeChange = _ref.onVolumeChange,
|
|
1016
|
-
customOnVolumeChange = _ref$onVolumeChange === void 0 ? null : _ref$onVolumeChange,
|
|
1017
|
-
_ref$onTimeUpdate = _ref.onTimeUpdate,
|
|
1018
|
-
customOnTimeUpdate = _ref$onTimeUpdate === void 0 ? null : _ref$onTimeUpdate,
|
|
1019
|
-
_ref$getVideoId = _ref.getVideoId,
|
|
1020
|
-
getVideoId = _ref$getVideoId === void 0 ? function (url) {
|
|
1021
|
-
if (url === null || url.match(/^https?:/) === null) {
|
|
1022
|
-
return url;
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
|
|
1026
|
-
var match = url.match(regExp);
|
|
1027
|
-
return match && match[7].length === 11 ? match[7] : null;
|
|
1028
|
-
} : _ref$getVideoId;
|
|
1029
|
-
|
|
1030
|
-
var _useState = react.useState(typeof window.YT !== 'undefined'),
|
|
1031
|
-
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
1032
|
-
apiLoaded = _useState2[0],
|
|
1033
|
-
setApiLoaded = _useState2[1];
|
|
1034
|
-
|
|
1035
|
-
var apiRef = react.useRef(typeof window.YT !== 'undefined' ? window.YT : null);
|
|
1036
|
-
var elementRef = react.useRef(null);
|
|
1037
|
-
var playerRef = react.useRef(null);
|
|
1038
|
-
var playerElementRef = react.useRef(elementRef.current);
|
|
1039
|
-
var elementHasChanged = elementRef.current !== playerElementRef.current;
|
|
1040
|
-
var videoId = react.useMemo(function () {
|
|
1041
|
-
return getVideoId(id);
|
|
1042
|
-
}, [id]);
|
|
1043
|
-
|
|
1044
|
-
var _useState3 = react.useState(false),
|
|
1045
|
-
_useState4 = _slicedToArray__default["default"](_useState3, 2),
|
|
1046
|
-
ready = _useState4[0],
|
|
1047
|
-
setReady = _useState4[1];
|
|
1048
|
-
|
|
1049
|
-
var _useState5 = react.useState(initialMuted),
|
|
1050
|
-
_useState6 = _slicedToArray__default["default"](_useState5, 2),
|
|
1051
|
-
muted = _useState6[0],
|
|
1052
|
-
setMuted = _useState6[1];
|
|
1143
|
+
let {
|
|
1144
|
+
width = 0,
|
|
1145
|
+
height = 0,
|
|
1146
|
+
duration = 0,
|
|
1147
|
+
autoplay = false,
|
|
1148
|
+
controls = true,
|
|
1149
|
+
timeUpdateInterval = 1000,
|
|
1150
|
+
muted: initialMuted = false,
|
|
1151
|
+
onVolumeChange: customOnVolumeChange = null,
|
|
1152
|
+
onTimeUpdate: customOnTimeUpdate = null,
|
|
1153
|
+
getVideoId = url => {
|
|
1154
|
+
if (url === null || url.match(/^https?:/) === null) {
|
|
1155
|
+
return url;
|
|
1156
|
+
}
|
|
1053
1157
|
|
|
1054
|
-
|
|
1158
|
+
const regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
|
|
1159
|
+
const match = url.match(regExp);
|
|
1160
|
+
return match && match[7].length === 11 ? match[7] : null;
|
|
1161
|
+
}
|
|
1162
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1163
|
+
const [apiLoaded, setApiLoaded] = react.useState(typeof window.YT !== 'undefined');
|
|
1164
|
+
const apiRef = react.useRef(typeof window.YT !== 'undefined' ? window.YT : null);
|
|
1165
|
+
const elementRef = react.useRef(null);
|
|
1166
|
+
const playerRef = react.useRef(null);
|
|
1167
|
+
const playerElementRef = react.useRef(elementRef.current);
|
|
1168
|
+
const elementHasChanged = elementRef.current !== playerElementRef.current;
|
|
1169
|
+
const videoId = react.useMemo(() => getVideoId(id), [id]);
|
|
1170
|
+
const [ready, setReady] = react.useState(false);
|
|
1171
|
+
const [muted, setMuted] = react.useState(initialMuted);
|
|
1172
|
+
const [playState, setPlayState] = react.useState({
|
|
1055
1173
|
playing: false,
|
|
1056
1174
|
paused: false,
|
|
1057
1175
|
ended: false,
|
|
1058
1176
|
buffering: false
|
|
1059
|
-
})
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
duration: duration
|
|
1068
|
-
}),
|
|
1069
|
-
_useState10 = _slicedToArray__default["default"](_useState9, 2),
|
|
1070
|
-
metadata = _useState10[0],
|
|
1071
|
-
setMetadata = _useState10[1];
|
|
1072
|
-
|
|
1073
|
-
react.useEffect(function () {
|
|
1074
|
-
var canceled = false;
|
|
1177
|
+
});
|
|
1178
|
+
const [metadata, setMetadata] = react.useState({
|
|
1179
|
+
width,
|
|
1180
|
+
height,
|
|
1181
|
+
duration
|
|
1182
|
+
});
|
|
1183
|
+
react.useEffect(() => {
|
|
1184
|
+
let canceled = false;
|
|
1075
1185
|
|
|
1076
1186
|
if (!apiLoaded && videoId !== null) {
|
|
1077
1187
|
debug$1('Load API');
|
|
1078
|
-
services.loadYouTube().then(
|
|
1188
|
+
services.loadYouTube().then(api => {
|
|
1079
1189
|
if (!canceled) {
|
|
1080
1190
|
apiRef.current = api;
|
|
1081
1191
|
setApiLoaded(true);
|
|
@@ -1084,21 +1194,27 @@ function useYouTubePlayer(id) {
|
|
|
1084
1194
|
});
|
|
1085
1195
|
}
|
|
1086
1196
|
|
|
1087
|
-
return
|
|
1197
|
+
return () => {
|
|
1088
1198
|
canceled = true;
|
|
1089
1199
|
};
|
|
1090
1200
|
}, [apiLoaded, videoId, setApiLoaded]);
|
|
1091
|
-
|
|
1092
|
-
|
|
1201
|
+
const play = react.useCallback(() => {
|
|
1202
|
+
const {
|
|
1203
|
+
current: player
|
|
1204
|
+
} = playerRef;
|
|
1093
1205
|
return player !== null && typeof player.playVideo !== 'undefined' ? Promise.resolve(player.playVideo()) : Promise.reject(NO_PLAYER_ERROR$1);
|
|
1094
1206
|
}, []);
|
|
1095
|
-
|
|
1096
|
-
|
|
1207
|
+
const pause = react.useCallback(() => {
|
|
1208
|
+
const {
|
|
1209
|
+
current: player
|
|
1210
|
+
} = playerRef;
|
|
1097
1211
|
return player !== null && typeof player.pauseVideo !== 'undefined' ? Promise.resolve(player.pauseVideo()) : Promise.reject(NO_PLAYER_ERROR$1);
|
|
1098
1212
|
}, []);
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1213
|
+
const setVolume = react.useCallback(volume => {
|
|
1214
|
+
const {
|
|
1215
|
+
current: player
|
|
1216
|
+
} = playerRef;
|
|
1217
|
+
const promise = player !== null && typeof player.setVolume !== 'undefined' ? Promise.resolve(player.setVolume(volume * 100)) : Promise.reject(NO_PLAYER_ERROR$1);
|
|
1102
1218
|
|
|
1103
1219
|
if (customOnVolumeChange) {
|
|
1104
1220
|
customOnVolumeChange(volume);
|
|
@@ -1106,35 +1222,41 @@ function useYouTubePlayer(id) {
|
|
|
1106
1222
|
|
|
1107
1223
|
return promise;
|
|
1108
1224
|
}, [customOnVolumeChange]);
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1225
|
+
const mute = react.useCallback(() => {
|
|
1226
|
+
const {
|
|
1227
|
+
current: player
|
|
1228
|
+
} = playerRef;
|
|
1229
|
+
return (player !== null && typeof player.mute !== 'undefined' ? Promise.resolve(player.mute()) : Promise.reject(NO_PLAYER_ERROR$1)).then(() => setMuted(true));
|
|
1114
1230
|
}, [setMuted]);
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1231
|
+
const unmute = react.useCallback(() => {
|
|
1232
|
+
const {
|
|
1233
|
+
current: player
|
|
1234
|
+
} = playerRef;
|
|
1235
|
+
return (player !== null && typeof player.unMute !== 'undefined' ? Promise.resolve(player.unMute()) : Promise.reject(NO_PLAYER_ERROR$1)).then(() => setMuted(false));
|
|
1120
1236
|
}, []);
|
|
1121
|
-
|
|
1122
|
-
|
|
1237
|
+
const seek = react.useCallback(time => {
|
|
1238
|
+
const {
|
|
1239
|
+
current: player
|
|
1240
|
+
} = playerRef;
|
|
1123
1241
|
return player !== null && typeof player.seekTo !== 'undefined' ? Promise.resolve(player.seekTo(time)) : Promise.reject(NO_PLAYER_ERROR$1);
|
|
1124
1242
|
}, []);
|
|
1125
|
-
|
|
1126
|
-
|
|
1243
|
+
const setLoop = react.useCallback(loop => {
|
|
1244
|
+
const {
|
|
1245
|
+
current: player
|
|
1246
|
+
} = playerRef;
|
|
1127
1247
|
return player !== null && typeof player.setLoop !== 'undefined' ? Promise.resolve(player.setLoop(loop)) : Promise.reject(NO_PLAYER_ERROR$1);
|
|
1128
1248
|
}, []);
|
|
1129
|
-
|
|
1249
|
+
const destroyPlayer = react.useCallback(() => {
|
|
1130
1250
|
if (playerRef.current !== null) {
|
|
1131
1251
|
debug$1('Unset player');
|
|
1132
1252
|
playerRef.current = null;
|
|
1133
1253
|
}
|
|
1134
1254
|
}, []); // Detect iframe switch and destroy player
|
|
1135
1255
|
|
|
1136
|
-
react.useEffect(
|
|
1137
|
-
|
|
1256
|
+
react.useEffect(() => {
|
|
1257
|
+
const {
|
|
1258
|
+
current: currentPlayer
|
|
1259
|
+
} = playerRef;
|
|
1138
1260
|
|
|
1139
1261
|
if (playerElementRef.current !== elementRef.current && currentPlayer !== null) {
|
|
1140
1262
|
debug$1('iFrame switched');
|
|
@@ -1142,20 +1264,23 @@ function useYouTubePlayer(id) {
|
|
|
1142
1264
|
}
|
|
1143
1265
|
}, [elementHasChanged]); // Create player
|
|
1144
1266
|
|
|
1145
|
-
react.useEffect(
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1267
|
+
react.useEffect(() => {
|
|
1268
|
+
const {
|
|
1269
|
+
current: YT = null
|
|
1270
|
+
} = apiRef;
|
|
1271
|
+
const {
|
|
1272
|
+
current: currentPlayer = null
|
|
1273
|
+
} = playerRef;
|
|
1274
|
+
const {
|
|
1275
|
+
current: element = null
|
|
1276
|
+
} = elementRef;
|
|
1152
1277
|
|
|
1153
1278
|
if (!apiLoaded || videoId === null || element === null) {
|
|
1154
1279
|
destroyPlayer();
|
|
1155
1280
|
return;
|
|
1156
1281
|
}
|
|
1157
1282
|
|
|
1158
|
-
|
|
1283
|
+
let player = currentPlayer;
|
|
1159
1284
|
|
|
1160
1285
|
if (player !== null && typeof player.loadVideoById !== 'undefined') {
|
|
1161
1286
|
debug$1('Switch video [ID: %s]', videoId);
|
|
@@ -1163,32 +1288,36 @@ function useYouTubePlayer(id) {
|
|
|
1163
1288
|
} else {
|
|
1164
1289
|
debug$1('Create player [ID: %s]', videoId);
|
|
1165
1290
|
|
|
1166
|
-
|
|
1167
|
-
|
|
1291
|
+
const onReady = _ref => {
|
|
1292
|
+
let {
|
|
1293
|
+
target
|
|
1294
|
+
} = _ref;
|
|
1168
1295
|
player = target;
|
|
1169
1296
|
playerRef.current = target;
|
|
1170
1297
|
setReady(true);
|
|
1171
|
-
|
|
1298
|
+
const newDuration = target.getDuration();
|
|
1172
1299
|
|
|
1173
1300
|
if (newDuration !== metadata.duration) {
|
|
1174
|
-
setMetadata(
|
|
1301
|
+
setMetadata({ ...metadata,
|
|
1175
1302
|
duration: newDuration
|
|
1176
|
-
})
|
|
1303
|
+
});
|
|
1177
1304
|
}
|
|
1178
1305
|
|
|
1179
1306
|
debug$1('onReady [ID: %s]', videoId);
|
|
1180
1307
|
};
|
|
1181
1308
|
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1309
|
+
const onStateChange = _ref2 => {
|
|
1310
|
+
let {
|
|
1311
|
+
data: state
|
|
1312
|
+
} = _ref2;
|
|
1313
|
+
const newState = {
|
|
1185
1314
|
playing: state === YT.PlayerState.PLAYING,
|
|
1186
1315
|
paused: state === YT.PlayerState.PAUSED,
|
|
1187
1316
|
ended: state === YT.PlayerState.ENDED,
|
|
1188
1317
|
buffering: state === YT.PlayerState.BUFFERING
|
|
1189
1318
|
};
|
|
1190
1319
|
setPlayState(newState);
|
|
1191
|
-
|
|
1320
|
+
let stateLabel = null;
|
|
1192
1321
|
|
|
1193
1322
|
if (newState.playing) {
|
|
1194
1323
|
stateLabel = 'playing';
|
|
@@ -1208,9 +1337,9 @@ function useYouTubePlayer(id) {
|
|
|
1208
1337
|
};
|
|
1209
1338
|
|
|
1210
1339
|
player = new YT.Player(element, {
|
|
1211
|
-
videoId
|
|
1340
|
+
videoId,
|
|
1212
1341
|
playerVars: {
|
|
1213
|
-
controls
|
|
1342
|
+
controls,
|
|
1214
1343
|
autoplay: autoplay ? 1 : 0,
|
|
1215
1344
|
mute: initialMuted,
|
|
1216
1345
|
playsinline: true,
|
|
@@ -1219,8 +1348,8 @@ function useYouTubePlayer(id) {
|
|
|
1219
1348
|
modestbranding: 1
|
|
1220
1349
|
},
|
|
1221
1350
|
events: {
|
|
1222
|
-
onReady
|
|
1223
|
-
onStateChange
|
|
1351
|
+
onReady,
|
|
1352
|
+
onStateChange
|
|
1224
1353
|
}
|
|
1225
1354
|
});
|
|
1226
1355
|
}
|
|
@@ -1228,127 +1357,88 @@ function useYouTubePlayer(id) {
|
|
|
1228
1357
|
playerRef.current = player;
|
|
1229
1358
|
playerElementRef.current = element;
|
|
1230
1359
|
}, [apiLoaded, videoId, elementHasChanged, setPlayState, setReady, setMetadata, destroyPlayer]);
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1360
|
+
const {
|
|
1361
|
+
playing
|
|
1362
|
+
} = playState;
|
|
1363
|
+
const getCurrentTime = react.useCallback(p => p.getCurrentTime(), []);
|
|
1364
|
+
const currentTime = usePlayerCurrentTime(playerRef.current, {
|
|
1236
1365
|
id: videoId,
|
|
1237
1366
|
disabled: !playing || timeUpdateInterval === null,
|
|
1238
1367
|
updateInterval: timeUpdateInterval,
|
|
1239
1368
|
onUpdate: customOnTimeUpdate,
|
|
1240
|
-
getCurrentTime
|
|
1369
|
+
getCurrentTime
|
|
1241
1370
|
});
|
|
1242
|
-
return
|
|
1371
|
+
return {
|
|
1243
1372
|
ref: elementRef,
|
|
1244
1373
|
player: playerRef.current,
|
|
1245
|
-
play
|
|
1246
|
-
pause
|
|
1247
|
-
mute
|
|
1248
|
-
unmute
|
|
1249
|
-
setVolume
|
|
1250
|
-
seek
|
|
1251
|
-
setLoop
|
|
1252
|
-
ready
|
|
1253
|
-
currentTime
|
|
1254
|
-
muted
|
|
1255
|
-
loaded: ready
|
|
1256
|
-
|
|
1374
|
+
play,
|
|
1375
|
+
pause,
|
|
1376
|
+
mute,
|
|
1377
|
+
unmute,
|
|
1378
|
+
setVolume,
|
|
1379
|
+
seek,
|
|
1380
|
+
setLoop,
|
|
1381
|
+
ready,
|
|
1382
|
+
currentTime,
|
|
1383
|
+
muted,
|
|
1384
|
+
loaded: ready,
|
|
1385
|
+
...metadata,
|
|
1386
|
+
...playState
|
|
1387
|
+
};
|
|
1257
1388
|
}
|
|
1258
1389
|
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
byline = _ref$byline === void 0 ? false : _ref$byline,
|
|
1279
|
-
_ref$controls = _ref.controls,
|
|
1280
|
-
controls = _ref$controls === void 0 ? false : _ref$controls,
|
|
1281
|
-
_ref$initialMuted = _ref.initialMuted,
|
|
1282
|
-
initialMuted = _ref$initialMuted === void 0 ? false : _ref$initialMuted,
|
|
1283
|
-
_ref$timeUpdateInterv = _ref.timeUpdateInterval,
|
|
1284
|
-
timeUpdateInterval = _ref$timeUpdateInterv === void 0 ? 1000 : _ref$timeUpdateInterv,
|
|
1285
|
-
_ref$onTimeUpdate = _ref.onTimeUpdate,
|
|
1286
|
-
customOnTimeUpdate = _ref$onTimeUpdate === void 0 ? null : _ref$onTimeUpdate,
|
|
1287
|
-
_ref$getVideoId = _ref.getVideoId,
|
|
1288
|
-
getVideoId = _ref$getVideoId === void 0 ? function (url) {
|
|
1289
|
-
if (url === null || url.match(/^[0-9]+$/) !== null) {
|
|
1290
|
-
return url;
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
var match = url.match(/\/[0-9]+/);
|
|
1294
|
-
return match !== null ? match[1] : null;
|
|
1295
|
-
} : _ref$getVideoId;
|
|
1296
|
-
|
|
1297
|
-
var _useState = react.useState(false),
|
|
1298
|
-
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
1299
|
-
apiLoaded = _useState2[0],
|
|
1300
|
-
setApiLoaded = _useState2[1];
|
|
1301
|
-
|
|
1302
|
-
var apiRef = react.useRef(null);
|
|
1303
|
-
var elementRef = react.useRef(null);
|
|
1304
|
-
var playerRef = react.useRef(null);
|
|
1305
|
-
var playerElementRef = react.useRef(elementRef.current);
|
|
1306
|
-
var elementHasChanged = elementRef.current !== playerElementRef.current;
|
|
1307
|
-
var videoId = react.useMemo(function () {
|
|
1308
|
-
return getVideoId(id);
|
|
1309
|
-
}, [id]);
|
|
1310
|
-
|
|
1311
|
-
var _useState3 = react.useState(false),
|
|
1312
|
-
_useState4 = _slicedToArray__default["default"](_useState3, 2),
|
|
1313
|
-
ready = _useState4[0],
|
|
1314
|
-
setReady = _useState4[1];
|
|
1315
|
-
|
|
1316
|
-
var _useState5 = react.useState(false),
|
|
1317
|
-
_useState6 = _slicedToArray__default["default"](_useState5, 2),
|
|
1318
|
-
loaded = _useState6[0],
|
|
1319
|
-
setLoaded = _useState6[1];
|
|
1320
|
-
|
|
1321
|
-
var _useState7 = react.useState(initialMuted ? 0 : 1),
|
|
1322
|
-
_useState8 = _slicedToArray__default["default"](_useState7, 2),
|
|
1323
|
-
volume = _useState8[0],
|
|
1324
|
-
setVolumeState = _useState8[1];
|
|
1390
|
+
const debug = createDebug__default["default"]('folklore:video:vimeo');
|
|
1391
|
+
const NO_PLAYER_ERROR = new Error('No player');
|
|
1392
|
+
|
|
1393
|
+
const useVimeoPlayer = function (id) {
|
|
1394
|
+
let {
|
|
1395
|
+
width = 0,
|
|
1396
|
+
height = 0,
|
|
1397
|
+
duration = 0,
|
|
1398
|
+
autoplay = false,
|
|
1399
|
+
autopause = true,
|
|
1400
|
+
byline = false,
|
|
1401
|
+
controls = false,
|
|
1402
|
+
initialMuted = false,
|
|
1403
|
+
timeUpdateInterval = 1000,
|
|
1404
|
+
onTimeUpdate: customOnTimeUpdate = null,
|
|
1405
|
+
getVideoId = url => {
|
|
1406
|
+
if (url === null || url.match(/^[0-9]+$/) !== null) {
|
|
1407
|
+
return url;
|
|
1408
|
+
}
|
|
1325
1409
|
|
|
1326
|
-
|
|
1410
|
+
const match = url.match(/\/[0-9]+/);
|
|
1411
|
+
return match !== null ? match[1] : null;
|
|
1412
|
+
}
|
|
1413
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1414
|
+
const [apiLoaded, setApiLoaded] = react.useState(false);
|
|
1415
|
+
const apiRef = react.useRef(null);
|
|
1416
|
+
const elementRef = react.useRef(null);
|
|
1417
|
+
const playerRef = react.useRef(null);
|
|
1418
|
+
const playerElementRef = react.useRef(elementRef.current);
|
|
1419
|
+
const elementHasChanged = elementRef.current !== playerElementRef.current;
|
|
1420
|
+
const videoId = react.useMemo(() => getVideoId(id), [id]);
|
|
1421
|
+
const [ready, setReady] = react.useState(false);
|
|
1422
|
+
const [loaded, setLoaded] = react.useState(false);
|
|
1423
|
+
const [volume, setVolumeState] = react.useState(initialMuted ? 0 : 1);
|
|
1424
|
+
const [playState, setPlayState] = react.useState({
|
|
1327
1425
|
playing: false,
|
|
1328
1426
|
paused: false,
|
|
1329
1427
|
ended: false,
|
|
1330
1428
|
buffering: false
|
|
1331
|
-
})
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
width: width,
|
|
1338
|
-
height: height,
|
|
1339
|
-
duration: duration
|
|
1340
|
-
}),
|
|
1341
|
-
_useState12 = _slicedToArray__default["default"](_useState11, 2),
|
|
1342
|
-
metadata = _useState12[0],
|
|
1343
|
-
setMetadata = _useState12[1]; // Load SDK
|
|
1344
|
-
|
|
1429
|
+
});
|
|
1430
|
+
const [metadata, setMetadata] = react.useState({
|
|
1431
|
+
width,
|
|
1432
|
+
height,
|
|
1433
|
+
duration
|
|
1434
|
+
}); // Load SDK
|
|
1345
1435
|
|
|
1346
|
-
react.useEffect(
|
|
1347
|
-
|
|
1436
|
+
react.useEffect(() => {
|
|
1437
|
+
let canceled = false;
|
|
1348
1438
|
|
|
1349
1439
|
if (!apiLoaded && id !== null) {
|
|
1350
1440
|
debug('Load API');
|
|
1351
|
-
services.loadVimeo().then(
|
|
1441
|
+
services.loadVimeo().then(api => {
|
|
1352
1442
|
if (!canceled) {
|
|
1353
1443
|
apiRef.current = api;
|
|
1354
1444
|
setApiLoaded(true);
|
|
@@ -1357,40 +1447,56 @@ var useVimeoPlayer = function useVimeoPlayer(id) {
|
|
|
1357
1447
|
});
|
|
1358
1448
|
}
|
|
1359
1449
|
|
|
1360
|
-
return
|
|
1450
|
+
return () => {
|
|
1361
1451
|
canceled = true;
|
|
1362
1452
|
};
|
|
1363
1453
|
}, [id]);
|
|
1364
|
-
|
|
1365
|
-
|
|
1454
|
+
const play = react.useCallback(() => {
|
|
1455
|
+
const {
|
|
1456
|
+
current: player
|
|
1457
|
+
} = playerRef;
|
|
1366
1458
|
return player !== null ? player.play() : Promise.reject(NO_PLAYER_ERROR);
|
|
1367
1459
|
}, []);
|
|
1368
|
-
|
|
1369
|
-
|
|
1460
|
+
const pause = react.useCallback(() => {
|
|
1461
|
+
const {
|
|
1462
|
+
current: player
|
|
1463
|
+
} = playerRef;
|
|
1370
1464
|
return player !== null ? player.pause() : Promise.reject(NO_PLAYER_ERROR);
|
|
1371
1465
|
}, []);
|
|
1372
|
-
|
|
1373
|
-
|
|
1466
|
+
const setVolume = react.useCallback(newVolume => {
|
|
1467
|
+
const {
|
|
1468
|
+
current: player
|
|
1469
|
+
} = playerRef;
|
|
1374
1470
|
return player !== null ? player.setVolume(newVolume) : Promise.reject(NO_PLAYER_ERROR);
|
|
1375
1471
|
}, []);
|
|
1376
|
-
|
|
1377
|
-
|
|
1472
|
+
const mute = react.useCallback(() => {
|
|
1473
|
+
const {
|
|
1474
|
+
current: player
|
|
1475
|
+
} = playerRef;
|
|
1378
1476
|
return player !== null ? player.setVolume(0) : Promise.reject(NO_PLAYER_ERROR);
|
|
1379
1477
|
}, []);
|
|
1380
|
-
|
|
1381
|
-
|
|
1478
|
+
const unmute = react.useCallback(() => {
|
|
1479
|
+
const {
|
|
1480
|
+
current: player
|
|
1481
|
+
} = playerRef;
|
|
1382
1482
|
return player !== null ? player.setVolume(1) : Promise.reject(NO_PLAYER_ERROR);
|
|
1383
1483
|
}, []);
|
|
1384
|
-
|
|
1385
|
-
|
|
1484
|
+
const seek = react.useCallback(time => {
|
|
1485
|
+
const {
|
|
1486
|
+
current: player
|
|
1487
|
+
} = playerRef;
|
|
1386
1488
|
return player !== null ? player.setCurrentTime(time) : Promise.reject(NO_PLAYER_ERROR);
|
|
1387
1489
|
}, []);
|
|
1388
|
-
|
|
1389
|
-
|
|
1490
|
+
const setLoop = react.useCallback(loop => {
|
|
1491
|
+
const {
|
|
1492
|
+
current: player
|
|
1493
|
+
} = playerRef;
|
|
1390
1494
|
return player !== null ? player.setLoop(loop) : Promise.reject(NO_PLAYER_ERROR);
|
|
1391
1495
|
}, []);
|
|
1392
|
-
|
|
1393
|
-
|
|
1496
|
+
const destroyVideo = react.useCallback(() => {
|
|
1497
|
+
const {
|
|
1498
|
+
current: player
|
|
1499
|
+
} = playerRef;
|
|
1394
1500
|
|
|
1395
1501
|
if (player !== null) {
|
|
1396
1502
|
debug('Unload video');
|
|
@@ -1402,8 +1508,10 @@ var useVimeoPlayer = function useVimeoPlayer(id) {
|
|
|
1402
1508
|
playerRef.current = null;
|
|
1403
1509
|
}
|
|
1404
1510
|
}, []);
|
|
1405
|
-
react.useEffect(
|
|
1406
|
-
|
|
1511
|
+
react.useEffect(() => {
|
|
1512
|
+
const {
|
|
1513
|
+
current: currentPlayer
|
|
1514
|
+
} = playerRef;
|
|
1407
1515
|
|
|
1408
1516
|
if (playerElementRef.current !== elementRef.current && currentPlayer !== null) {
|
|
1409
1517
|
debug('iFrame switched');
|
|
@@ -1411,40 +1519,41 @@ var useVimeoPlayer = function useVimeoPlayer(id) {
|
|
|
1411
1519
|
}
|
|
1412
1520
|
}, [elementHasChanged]); // Create player
|
|
1413
1521
|
|
|
1414
|
-
react.useEffect(
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1522
|
+
react.useEffect(() => {
|
|
1523
|
+
const {
|
|
1524
|
+
current: Player = null
|
|
1525
|
+
} = apiRef;
|
|
1526
|
+
const {
|
|
1527
|
+
current: currentPlayer = null
|
|
1528
|
+
} = playerRef;
|
|
1529
|
+
const {
|
|
1530
|
+
current: element = null
|
|
1531
|
+
} = elementRef;
|
|
1421
1532
|
|
|
1422
1533
|
if (!apiLoaded || videoId === null || element === null) {
|
|
1423
1534
|
destroyVideo();
|
|
1424
1535
|
return;
|
|
1425
1536
|
}
|
|
1426
1537
|
|
|
1427
|
-
|
|
1538
|
+
let player = currentPlayer;
|
|
1428
1539
|
|
|
1429
1540
|
if (player === null) {
|
|
1430
1541
|
debug('Create player [ID: %s]', videoId);
|
|
1431
1542
|
player = new Player(element, {
|
|
1432
1543
|
id: videoId,
|
|
1433
|
-
autoplay
|
|
1434
|
-
autopause
|
|
1435
|
-
byline
|
|
1436
|
-
controls
|
|
1544
|
+
autoplay,
|
|
1545
|
+
autopause,
|
|
1546
|
+
byline,
|
|
1547
|
+
controls,
|
|
1437
1548
|
muted: initialMuted,
|
|
1438
1549
|
background: !controls
|
|
1439
1550
|
});
|
|
1440
|
-
player.ready().then(
|
|
1441
|
-
return setReady(true);
|
|
1442
|
-
}).catch(function (e) {
|
|
1551
|
+
player.ready().then(() => setReady(true)).catch(e => {
|
|
1443
1552
|
debug('ERROR: %o', e);
|
|
1444
1553
|
});
|
|
1445
1554
|
} else {
|
|
1446
1555
|
debug('Load video [ID: %s]', videoId);
|
|
1447
|
-
player.loadVideo(videoId).catch(
|
|
1556
|
+
player.loadVideo(videoId).catch(e => {
|
|
1448
1557
|
debug('ERROR: %o', e);
|
|
1449
1558
|
});
|
|
1450
1559
|
}
|
|
@@ -1453,28 +1562,26 @@ var useVimeoPlayer = function useVimeoPlayer(id) {
|
|
|
1453
1562
|
playerElementRef.current = element;
|
|
1454
1563
|
}, [apiLoaded, videoId, elementHasChanged, setReady, destroyVideo, setLoaded]); // Bind player events
|
|
1455
1564
|
|
|
1456
|
-
react.useEffect(
|
|
1457
|
-
|
|
1565
|
+
react.useEffect(() => {
|
|
1566
|
+
const {
|
|
1567
|
+
current: player
|
|
1568
|
+
} = playerRef;
|
|
1458
1569
|
|
|
1459
1570
|
if (player === null) {
|
|
1460
|
-
return
|
|
1571
|
+
return () => {};
|
|
1461
1572
|
}
|
|
1462
1573
|
|
|
1463
|
-
|
|
1574
|
+
let canceled = false;
|
|
1464
1575
|
|
|
1465
|
-
|
|
1466
|
-
Promise.all([player.getDuration(), player.getVideoWidth(), player.getVideoHeight(), player.getMuted()]).then(
|
|
1467
|
-
|
|
1468
|
-
newDuration = _ref3[0],
|
|
1469
|
-
newWidth = _ref3[1],
|
|
1470
|
-
newHeight = _ref3[2],
|
|
1471
|
-
newMuted = _ref3[3];
|
|
1576
|
+
const onLoaded = () => {
|
|
1577
|
+
Promise.all([player.getDuration(), player.getVideoWidth(), player.getVideoHeight(), player.getMuted()]).then(_ref => {
|
|
1578
|
+
let [newDuration, newWidth, newHeight, newMuted] = _ref;
|
|
1472
1579
|
|
|
1473
1580
|
if (canceled) {
|
|
1474
1581
|
return;
|
|
1475
1582
|
}
|
|
1476
1583
|
|
|
1477
|
-
|
|
1584
|
+
const newMetadata = {
|
|
1478
1585
|
duration: newDuration,
|
|
1479
1586
|
width: newWidth,
|
|
1480
1587
|
height: newHeight
|
|
@@ -1490,7 +1597,7 @@ var useVimeoPlayer = function useVimeoPlayer(id) {
|
|
|
1490
1597
|
debug('onLoaded [ID: %s]', videoId);
|
|
1491
1598
|
};
|
|
1492
1599
|
|
|
1493
|
-
|
|
1600
|
+
const onPlay = () => {
|
|
1494
1601
|
setPlayState({
|
|
1495
1602
|
playing: true,
|
|
1496
1603
|
paused: false,
|
|
@@ -1498,14 +1605,14 @@ var useVimeoPlayer = function useVimeoPlayer(id) {
|
|
|
1498
1605
|
buffering: false
|
|
1499
1606
|
});
|
|
1500
1607
|
debug('onPlay [ID: %s]', videoId);
|
|
1501
|
-
player.getMuted().then(
|
|
1608
|
+
player.getMuted().then(newMuted => {
|
|
1502
1609
|
if (!canceled && newMuted) {
|
|
1503
1610
|
setVolumeState(0);
|
|
1504
1611
|
}
|
|
1505
|
-
}).catch(
|
|
1612
|
+
}).catch(() => {});
|
|
1506
1613
|
};
|
|
1507
1614
|
|
|
1508
|
-
|
|
1615
|
+
const onPause = () => {
|
|
1509
1616
|
setPlayState({
|
|
1510
1617
|
playing: false,
|
|
1511
1618
|
paused: true,
|
|
@@ -1515,13 +1622,15 @@ var useVimeoPlayer = function useVimeoPlayer(id) {
|
|
|
1515
1622
|
debug('onPause [ID: %s]', videoId);
|
|
1516
1623
|
};
|
|
1517
1624
|
|
|
1518
|
-
|
|
1519
|
-
|
|
1625
|
+
const onVolumeChange = _ref2 => {
|
|
1626
|
+
let {
|
|
1627
|
+
volume: newVolume
|
|
1628
|
+
} = _ref2;
|
|
1520
1629
|
setVolumeState(newVolume);
|
|
1521
1630
|
debug('onVolumeChange [ID: %s]', videoId);
|
|
1522
1631
|
};
|
|
1523
1632
|
|
|
1524
|
-
|
|
1633
|
+
const onEnded = () => {
|
|
1525
1634
|
setPlayState({
|
|
1526
1635
|
playing: false,
|
|
1527
1636
|
paused: false,
|
|
@@ -1531,7 +1640,7 @@ var useVimeoPlayer = function useVimeoPlayer(id) {
|
|
|
1531
1640
|
debug('onEnded [ID: %s]', videoId);
|
|
1532
1641
|
};
|
|
1533
1642
|
|
|
1534
|
-
|
|
1643
|
+
const onBufferStart = () => {
|
|
1535
1644
|
setPlayState({
|
|
1536
1645
|
playing: true,
|
|
1537
1646
|
paused: false,
|
|
@@ -1541,7 +1650,7 @@ var useVimeoPlayer = function useVimeoPlayer(id) {
|
|
|
1541
1650
|
debug('onBufferStart [ID: %s]', videoId);
|
|
1542
1651
|
};
|
|
1543
1652
|
|
|
1544
|
-
|
|
1653
|
+
const onBufferEnded = () => {
|
|
1545
1654
|
setPlayState({
|
|
1546
1655
|
playing: true,
|
|
1547
1656
|
paused: false,
|
|
@@ -1559,7 +1668,7 @@ var useVimeoPlayer = function useVimeoPlayer(id) {
|
|
|
1559
1668
|
player.on('ended', onEnded);
|
|
1560
1669
|
player.on('bufferstart', onBufferStart);
|
|
1561
1670
|
player.on('bufferend', onBufferEnded);
|
|
1562
|
-
return
|
|
1671
|
+
return () => {
|
|
1563
1672
|
canceled = true;
|
|
1564
1673
|
debug('Unbind events [ID: %s]', videoId);
|
|
1565
1674
|
player.off('loaded', onLoaded);
|
|
@@ -1571,63 +1680,55 @@ var useVimeoPlayer = function useVimeoPlayer(id) {
|
|
|
1571
1680
|
player.off('bufferend', onBufferEnded);
|
|
1572
1681
|
};
|
|
1573
1682
|
}, [videoId, playerRef.current, setPlayState, setMetadata, setVolumeState, setLoaded]);
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1683
|
+
const {
|
|
1684
|
+
playing
|
|
1685
|
+
} = playState;
|
|
1686
|
+
const getCurrentTime = react.useCallback(p => p.getCurrentTime(), []);
|
|
1687
|
+
const currentTime = usePlayerCurrentTime(playerRef.current, {
|
|
1579
1688
|
id: videoId,
|
|
1580
1689
|
disabled: !playing || timeUpdateInterval === null,
|
|
1581
1690
|
updateInterval: timeUpdateInterval,
|
|
1582
1691
|
onUpdate: customOnTimeUpdate,
|
|
1583
|
-
getCurrentTime
|
|
1692
|
+
getCurrentTime
|
|
1584
1693
|
});
|
|
1585
|
-
return
|
|
1694
|
+
return {
|
|
1586
1695
|
ref: elementRef,
|
|
1587
1696
|
player: playerRef.current,
|
|
1588
|
-
play
|
|
1589
|
-
pause
|
|
1590
|
-
mute
|
|
1591
|
-
unmute
|
|
1592
|
-
setVolume
|
|
1593
|
-
seek
|
|
1594
|
-
setLoop
|
|
1595
|
-
ready
|
|
1596
|
-
currentTime
|
|
1597
|
-
loaded
|
|
1697
|
+
play,
|
|
1698
|
+
pause,
|
|
1699
|
+
mute,
|
|
1700
|
+
unmute,
|
|
1701
|
+
setVolume,
|
|
1702
|
+
seek,
|
|
1703
|
+
setLoop,
|
|
1704
|
+
ready,
|
|
1705
|
+
currentTime,
|
|
1706
|
+
loaded,
|
|
1598
1707
|
muted: volume === 0,
|
|
1599
|
-
volume
|
|
1600
|
-
|
|
1708
|
+
volume,
|
|
1709
|
+
...metadata,
|
|
1710
|
+
...playState
|
|
1711
|
+
};
|
|
1601
1712
|
};
|
|
1602
1713
|
|
|
1603
1714
|
function useVideoPlayer(params) {
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
_ref$onBufferStart = _ref.onBufferStart,
|
|
1622
|
-
customOnBufferStart = _ref$onBufferStart === void 0 ? null : _ref$onBufferStart,
|
|
1623
|
-
_ref$onBufferEnded = _ref.onBufferEnded,
|
|
1624
|
-
customOnBufferEnded = _ref$onBufferEnded === void 0 ? null : _ref$onBufferEnded;
|
|
1625
|
-
|
|
1626
|
-
var dailymotionPlayer = useDailymotionPlayer(service === 'dailymotion' ? videoId || url : null, params);
|
|
1627
|
-
var youtubePlayer = useYouTubePlayer(service === 'youtube' ? videoId || url : null, params);
|
|
1628
|
-
var vimeoPlayer = useVimeoPlayer(service === 'vimeo' ? videoId || url : null, params);
|
|
1629
|
-
var nativePlayer = useNativeVideoPlayer(url, params);
|
|
1630
|
-
var player = null;
|
|
1715
|
+
const {
|
|
1716
|
+
service = null,
|
|
1717
|
+
videoId = null,
|
|
1718
|
+
url = null,
|
|
1719
|
+
onLoaded: customOnLoaded = null,
|
|
1720
|
+
onPlay: customOnPlay = null,
|
|
1721
|
+
onPause: customOnPause = null,
|
|
1722
|
+
onEnd: customOnEnd = null,
|
|
1723
|
+
onMetadataChange: customOnMetadataChange = null,
|
|
1724
|
+
onBufferStart: customOnBufferStart = null,
|
|
1725
|
+
onBufferEnded: customOnBufferEnded = null
|
|
1726
|
+
} = params || {};
|
|
1727
|
+
const dailymotionPlayer = useDailymotionPlayer(service === 'dailymotion' ? videoId || url : null, params);
|
|
1728
|
+
const youtubePlayer = useYouTubePlayer(service === 'youtube' ? videoId || url : null, params);
|
|
1729
|
+
const vimeoPlayer = useVimeoPlayer(service === 'vimeo' ? videoId || url : null, params);
|
|
1730
|
+
const nativePlayer = useNativeVideoPlayer(url, params);
|
|
1731
|
+
let player = null;
|
|
1631
1732
|
|
|
1632
1733
|
if (service === 'dailymotion') {
|
|
1633
1734
|
player = dailymotionPlayer;
|
|
@@ -1639,53 +1740,45 @@ function useVideoPlayer(params) {
|
|
|
1639
1740
|
player = nativePlayer;
|
|
1640
1741
|
}
|
|
1641
1742
|
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
_ref2$width = _ref2.width,
|
|
1654
|
-
metaWidth = _ref2$width === void 0 ? null : _ref2$width,
|
|
1655
|
-
_ref2$height = _ref2.height,
|
|
1656
|
-
metaHeight = _ref2$height === void 0 ? null : _ref2$height,
|
|
1657
|
-
_ref2$duration = _ref2.duration,
|
|
1658
|
-
metaDuration = _ref2$duration === void 0 ? null : _ref2$duration;
|
|
1659
|
-
|
|
1660
|
-
react.useEffect(function () {
|
|
1743
|
+
const {
|
|
1744
|
+
playing = false,
|
|
1745
|
+
paused = false,
|
|
1746
|
+
buffering = false,
|
|
1747
|
+
ended = false,
|
|
1748
|
+
ready = false,
|
|
1749
|
+
width: metaWidth = null,
|
|
1750
|
+
height: metaHeight = null,
|
|
1751
|
+
duration: metaDuration = null
|
|
1752
|
+
} = player || {};
|
|
1753
|
+
react.useEffect(() => {
|
|
1661
1754
|
if (ready && customOnLoaded !== null) {
|
|
1662
1755
|
customOnLoaded();
|
|
1663
1756
|
}
|
|
1664
1757
|
}, [ready, customOnLoaded]);
|
|
1665
|
-
react.useEffect(
|
|
1758
|
+
react.useEffect(() => {
|
|
1666
1759
|
if (playing && customOnPlay !== null) {
|
|
1667
1760
|
customOnPlay();
|
|
1668
1761
|
}
|
|
1669
1762
|
}, [playing, customOnPlay]);
|
|
1670
|
-
react.useEffect(
|
|
1763
|
+
react.useEffect(() => {
|
|
1671
1764
|
if (paused && customOnPause !== null) {
|
|
1672
1765
|
customOnPause();
|
|
1673
1766
|
}
|
|
1674
1767
|
}, [paused, customOnPause]);
|
|
1675
|
-
react.useEffect(
|
|
1768
|
+
react.useEffect(() => {
|
|
1676
1769
|
if (buffering && customOnBufferStart !== null) {
|
|
1677
1770
|
customOnBufferStart();
|
|
1678
1771
|
} else if (!buffering && customOnBufferEnded !== null) {
|
|
1679
1772
|
customOnBufferEnded();
|
|
1680
1773
|
}
|
|
1681
1774
|
}, [buffering, customOnBufferStart, customOnBufferEnded]);
|
|
1682
|
-
react.useEffect(
|
|
1775
|
+
react.useEffect(() => {
|
|
1683
1776
|
if (ended && customOnEnd !== null) {
|
|
1684
1777
|
customOnEnd();
|
|
1685
1778
|
}
|
|
1686
1779
|
}, [ended, customOnEnd]);
|
|
1687
|
-
react.useEffect(
|
|
1688
|
-
|
|
1780
|
+
react.useEffect(() => {
|
|
1781
|
+
const hasMetadata = metaWidth !== null || metaHeight !== null || metaDuration !== null;
|
|
1689
1782
|
|
|
1690
1783
|
if (hasMetadata && customOnMetadataChange !== null) {
|
|
1691
1784
|
customOnMetadataChange({
|
|
@@ -1698,27 +1791,21 @@ function useVideoPlayer(params) {
|
|
|
1698
1791
|
return player;
|
|
1699
1792
|
}
|
|
1700
1793
|
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
};
|
|
1706
|
-
};
|
|
1707
|
-
|
|
1708
|
-
var currentScroll = getWindowScroll();
|
|
1794
|
+
const getWindowScroll = () => ({
|
|
1795
|
+
x: typeof window !== 'undefined' ? window.scrollX || 0 : 0,
|
|
1796
|
+
y: typeof window !== 'undefined' ? window.scrollY || 0 : 0
|
|
1797
|
+
});
|
|
1709
1798
|
|
|
1710
|
-
|
|
1711
|
-
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1712
|
-
var _opts$onChange = opts.onChange,
|
|
1713
|
-
onChange = _opts$onChange === void 0 ? null : _opts$onChange;
|
|
1799
|
+
const currentScroll = getWindowScroll();
|
|
1714
1800
|
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1801
|
+
const useWindowScroll = function () {
|
|
1802
|
+
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1803
|
+
const {
|
|
1804
|
+
onChange = null
|
|
1805
|
+
} = opts;
|
|
1806
|
+
const [scroll, setScroll] = react.useState(currentScroll);
|
|
1807
|
+
const updateScroll = react.useCallback(() => {
|
|
1808
|
+
const newScroll = getWindowScroll();
|
|
1722
1809
|
|
|
1723
1810
|
if (currentScroll.x !== newScroll.x || currentScroll.y !== newScroll.y) {
|
|
1724
1811
|
currentScroll.x = newScroll.x;
|
|
@@ -1729,40 +1816,33 @@ var useWindowScroll = function useWindowScroll() {
|
|
|
1729
1816
|
|
|
1730
1817
|
return null;
|
|
1731
1818
|
}, [setScroll]);
|
|
1732
|
-
|
|
1733
|
-
|
|
1819
|
+
const onScroll = react.useCallback(() => {
|
|
1820
|
+
const newScroll = updateScroll();
|
|
1734
1821
|
|
|
1735
1822
|
if (newScroll !== null && onChange !== null) {
|
|
1736
1823
|
onChange(newScroll);
|
|
1737
1824
|
}
|
|
1738
1825
|
}, [updateScroll, onChange]);
|
|
1739
1826
|
useWindowEvent('scroll', onScroll);
|
|
1740
|
-
react.useEffect(
|
|
1827
|
+
react.useEffect(() => {
|
|
1741
1828
|
onScroll();
|
|
1742
1829
|
}, []);
|
|
1743
1830
|
return scroll;
|
|
1744
1831
|
};
|
|
1745
1832
|
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
};
|
|
1752
|
-
var currentSize = getWindowSize();
|
|
1833
|
+
const getWindowSize = () => ({
|
|
1834
|
+
width: typeof window !== 'undefined' ? window.innerWidth || 0 : 0,
|
|
1835
|
+
height: typeof window !== 'undefined' ? window.innerHeight || 0 : 0
|
|
1836
|
+
});
|
|
1837
|
+
let currentSize = getWindowSize();
|
|
1753
1838
|
|
|
1754
1839
|
function useWindowSize() {
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
size = _useState2[0],
|
|
1762
|
-
setSize = _useState2[1];
|
|
1763
|
-
|
|
1764
|
-
var updateSize = react.useCallback(function () {
|
|
1765
|
-
var newSize = getWindowSize();
|
|
1840
|
+
let {
|
|
1841
|
+
onChange = null
|
|
1842
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1843
|
+
const [size, setSize] = react.useState(currentSize);
|
|
1844
|
+
const updateSize = react.useCallback(() => {
|
|
1845
|
+
const newSize = getWindowSize();
|
|
1766
1846
|
|
|
1767
1847
|
if (currentSize.width !== newSize.width || currentSize.height !== newSize.height) {
|
|
1768
1848
|
currentSize = newSize;
|
|
@@ -1772,15 +1852,15 @@ function useWindowSize() {
|
|
|
1772
1852
|
|
|
1773
1853
|
return null;
|
|
1774
1854
|
}, [setSize]);
|
|
1775
|
-
|
|
1776
|
-
|
|
1855
|
+
const onResize = react.useCallback(() => {
|
|
1856
|
+
const newSize = updateSize();
|
|
1777
1857
|
|
|
1778
1858
|
if (newSize !== null && onChange !== null) {
|
|
1779
1859
|
onChange(newSize);
|
|
1780
1860
|
}
|
|
1781
1861
|
}, [onChange]);
|
|
1782
1862
|
useWindowEvent('resize', onResize);
|
|
1783
|
-
react.useEffect(
|
|
1863
|
+
react.useEffect(() => {
|
|
1784
1864
|
onResize();
|
|
1785
1865
|
}, []);
|
|
1786
1866
|
return size;
|
|
@@ -1792,6 +1872,7 @@ exports.useCounter = useCounter;
|
|
|
1792
1872
|
exports.useDailymotionPlayer = useDailymotionPlayer;
|
|
1793
1873
|
exports.useDocumentEvent = useDocumentEvent;
|
|
1794
1874
|
exports.useIntersectionObserver = useIntersectionObserver;
|
|
1875
|
+
exports.useItemsPaginated = useItemsPaginated;
|
|
1795
1876
|
exports.useKeyboard = useKeyboard;
|
|
1796
1877
|
exports.useNativeVideoPlayer = useNativeVideoPlayer;
|
|
1797
1878
|
exports.useObserver = useObserver;
|