video-react-player 0.1.0 → 0.1.1

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.
Files changed (66) hide show
  1. package/dist/actions/player.d.ts.map +1 -0
  2. package/dist/actions/video.d.ts.map +1 -0
  3. package/dist/components/Bezel.d.ts.map +1 -0
  4. package/dist/components/BigPlayButton.d.ts.map +1 -0
  5. package/dist/components/ClickableComponent.d.ts.map +1 -0
  6. package/dist/components/LoadingSpinner.d.ts.map +1 -0
  7. package/dist/components/Player.d.ts.map +1 -0
  8. package/dist/components/PosterImage.d.ts.map +1 -0
  9. package/dist/components/Shortcut.d.ts.map +1 -0
  10. package/dist/components/Slider.d.ts.map +1 -0
  11. package/dist/components/Source.d.ts.map +1 -0
  12. package/dist/components/Video.d.ts.map +1 -0
  13. package/dist/components/control-bar/ClosedCaptionButton.d.ts.map +1 -0
  14. package/dist/components/control-bar/ControlBar.d.ts.map +1 -0
  15. package/dist/components/control-bar/DownloadButton.d.ts.map +1 -0
  16. package/dist/components/control-bar/ForwardControl.d.ts.map +1 -0
  17. package/dist/components/control-bar/ForwardReplayControl.d.ts.map +1 -0
  18. package/dist/components/control-bar/FullscreenToggle.d.ts.map +1 -0
  19. package/dist/components/control-bar/LoadProgressBar.d.ts.map +1 -0
  20. package/dist/components/control-bar/LoopToggle.d.ts.map +1 -0
  21. package/dist/components/control-bar/MouseTimeDisplay.d.ts.map +1 -0
  22. package/dist/components/control-bar/PictureInPictureToggle.d.ts.map +1 -0
  23. package/dist/components/control-bar/PlayProgressBar.d.ts.map +1 -0
  24. package/dist/components/control-bar/PlayToggle.d.ts.map +1 -0
  25. package/dist/components/control-bar/PlaybackRate.d.ts.map +1 -0
  26. package/dist/components/control-bar/PlaybackRateMenuButton.d.ts.map +1 -0
  27. package/dist/components/control-bar/ProgressControl.d.ts.map +1 -0
  28. package/dist/components/control-bar/QualityMenuButton.d.ts.map +1 -0
  29. package/dist/components/control-bar/ReplayControl.d.ts.map +1 -0
  30. package/dist/components/control-bar/ScreenshotButton.d.ts.map +1 -0
  31. package/dist/components/control-bar/SeekBar.d.ts.map +1 -0
  32. package/dist/components/control-bar/TheaterModeToggle.d.ts.map +1 -0
  33. package/dist/components/control-bar/VolumeMenuButton.d.ts.map +1 -0
  34. package/dist/components/menu/Menu.d.ts.map +1 -0
  35. package/dist/components/menu/MenuButton.d.ts.map +1 -0
  36. package/dist/components/menu/MenuItem.d.ts.map +1 -0
  37. package/dist/components/popup/Popup.d.ts.map +1 -0
  38. package/dist/components/popup/PopupButton.d.ts.map +1 -0
  39. package/dist/components/time-controls/CurrentTimeDisplay.d.ts.map +1 -0
  40. package/dist/components/time-controls/DurationDisplay.d.ts.map +1 -0
  41. package/dist/components/time-controls/RemainingTimeDisplay.d.ts.map +1 -0
  42. package/dist/components/time-controls/TimeDivider.d.ts.map +1 -0
  43. package/dist/components/volume-control/VolumeBar.d.ts.map +1 -0
  44. package/dist/components/volume-control/VolumeControl.d.ts.map +1 -0
  45. package/dist/components/volume-control/VolumeLevel.d.ts.map +1 -0
  46. package/dist/reducers/index.d.ts.map +1 -0
  47. package/dist/reducers/operation.d.ts.map +1 -0
  48. package/dist/reducers/player.d.ts.map +1 -0
  49. package/dist/types/component.d.ts.map +1 -0
  50. package/dist/types/player.d.ts.map +1 -0
  51. package/dist/utils/browser.d.ts.map +1 -0
  52. package/dist/utils/dom.d.ts.map +1 -0
  53. package/dist/utils/fullscreen.d.ts.map +1 -0
  54. package/dist/utils/index.d.ts.map +1 -0
  55. package/package.json +10 -5
  56. package/dist/video-react-new.cjs.js +0 -3904
  57. package/dist/video-react-new.css +0 -1155
  58. package/dist/video-react-new.es.js +0 -3861
  59. package/dist/video-react-new.full.js +0 -4578
  60. package/dist/video-react-new.full.min.js +0 -2
  61. package/dist/video-react-new.js +0 -4283
  62. package/dist/video-react-new.min.js +0 -2
  63. package/dist/video-react-player.full.js +0 -4578
  64. package/dist/video-react-player.full.min.js +0 -2
  65. package/dist/video-react-player.js +0 -4283
  66. package/dist/video-react-player.min.js +0 -2
@@ -1,4578 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
4
- (global = global || self, factory(global['video-react-player'] = {}, global.React));
5
- }(this, function (exports, React) { 'use strict';
6
-
7
- var React__default = 'default' in React ? React['default'] : React;
8
-
9
- function _assertThisInitialized(e) {
10
- if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
11
- return e;
12
- }
13
- function _defineProperties(e, r) {
14
- for (var t = 0; t < r.length; t++) {
15
- var o = r[t];
16
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
17
- }
18
- }
19
- function _createClass(e, r, t) {
20
- return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
21
- writable: !1
22
- }), e;
23
- }
24
- function _extends() {
25
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
26
- for (var e = 1; e < arguments.length; e++) {
27
- var t = arguments[e];
28
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
29
- }
30
- return n;
31
- }, _extends.apply(null, arguments);
32
- }
33
- function _inheritsLoose(t, o) {
34
- t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
35
- }
36
- function _objectWithoutPropertiesLoose(r, e) {
37
- if (null == r) return {};
38
- var t = {};
39
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
40
- if (-1 !== e.indexOf(n)) continue;
41
- t[n] = r[n];
42
- }
43
- return t;
44
- }
45
- function _setPrototypeOf(t, e) {
46
- return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
47
- return t.__proto__ = e, t;
48
- }, _setPrototypeOf(t, e);
49
- }
50
- function _toPrimitive(t, r) {
51
- if ("object" != typeof t || !t) return t;
52
- var e = t[Symbol.toPrimitive];
53
- if (void 0 !== e) {
54
- var i = e.call(t, r || "default");
55
- if ("object" != typeof i) return i;
56
- throw new TypeError("@@toPrimitive must return a primitive value.");
57
- }
58
- return ("string" === r ? String : Number)(t);
59
- }
60
- function _toPropertyKey(t) {
61
- var i = _toPrimitive(t, "string");
62
- return "symbol" == typeof i ? i : i + "";
63
- }
64
-
65
- function unwrapExports (x) {
66
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
67
- }
68
-
69
- function createCommonjsModule(fn, module) {
70
- return module = { exports: {} }, fn(module, module.exports), module.exports;
71
- }
72
-
73
- var classnames = createCommonjsModule(function (module) {
74
- /*!
75
- Copyright (c) 2017 Jed Watson.
76
- Licensed under the MIT License (MIT), see
77
- http://jedwatson.github.io/classnames
78
- */
79
- /* global define */
80
-
81
- (function () {
82
-
83
- var hasOwn = {}.hasOwnProperty;
84
- function classNames() {
85
- var classes = [];
86
- for (var i = 0; i < arguments.length; i++) {
87
- var arg = arguments[i];
88
- if (!arg) continue;
89
- var argType = typeof arg;
90
- if (argType === 'string' || argType === 'number') {
91
- classes.push(arg);
92
- } else if (Array.isArray(arg) && arg.length) {
93
- var inner = classNames.apply(null, arg);
94
- if (inner) {
95
- classes.push(inner);
96
- }
97
- } else if (argType === 'object') {
98
- for (var key in arg) {
99
- if (hasOwn.call(arg, key) && arg[key]) {
100
- classes.push(key);
101
- }
102
- }
103
- }
104
- }
105
- return classes.join(' ');
106
- }
107
- if (module.exports) {
108
- classNames.default = classNames;
109
- module.exports = classNames;
110
- } else {
111
- window.classNames = classNames;
112
- }
113
- })();
114
- });
115
-
116
- function symbolObservablePonyfill(root) {
117
- var result;
118
- var Symbol = root.Symbol;
119
- if (typeof Symbol === 'function') {
120
- if (Symbol.observable) {
121
- result = Symbol.observable;
122
- } else {
123
- result = Symbol('observable');
124
- Symbol.observable = result;
125
- }
126
- } else {
127
- result = '@@observable';
128
- }
129
- return result;
130
- }
131
-
132
- /* global window */
133
- var root;
134
- if (typeof self !== 'undefined') {
135
- root = self;
136
- } else if (typeof window !== 'undefined') {
137
- root = window;
138
- } else if (typeof global !== 'undefined') {
139
- root = global;
140
- } else if (typeof module !== 'undefined') {
141
- root = module;
142
- } else {
143
- root = Function('return this')();
144
- }
145
- var result = symbolObservablePonyfill(root);
146
-
147
- /**
148
- * These are private action types reserved by Redux.
149
- * For any unknown actions, you must return the current state.
150
- * If the current state is undefined, you must return the initial state.
151
- * Do not reference these action types directly in your code.
152
- */
153
- var randomString = function randomString() {
154
- return Math.random().toString(36).substring(7).split('').join('.');
155
- };
156
- var ActionTypes = {
157
- INIT: "@@redux/INIT" + randomString(),
158
- REPLACE: "@@redux/REPLACE" + randomString(),
159
- PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
160
- return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
161
- }
162
- };
163
-
164
- /**
165
- * @param {any} obj The object to inspect.
166
- * @returns {boolean} True if the argument appears to be a plain object.
167
- */
168
- function isPlainObject(obj) {
169
- if (typeof obj !== 'object' || obj === null) return false;
170
- var proto = obj;
171
- while (Object.getPrototypeOf(proto) !== null) {
172
- proto = Object.getPrototypeOf(proto);
173
- }
174
- return Object.getPrototypeOf(obj) === proto;
175
- }
176
-
177
- /**
178
- * Creates a Redux store that holds the state tree.
179
- * The only way to change the data in the store is to call `dispatch()` on it.
180
- *
181
- * There should only be a single store in your app. To specify how different
182
- * parts of the state tree respond to actions, you may combine several reducers
183
- * into a single reducer function by using `combineReducers`.
184
- *
185
- * @param {Function} reducer A function that returns the next state tree, given
186
- * the current state tree and the action to handle.
187
- *
188
- * @param {any} [preloadedState] The initial state. You may optionally specify it
189
- * to hydrate the state from the server in universal apps, or to restore a
190
- * previously serialized user session.
191
- * If you use `combineReducers` to produce the root reducer function, this must be
192
- * an object with the same shape as `combineReducers` keys.
193
- *
194
- * @param {Function} [enhancer] The store enhancer. You may optionally specify it
195
- * to enhance the store with third-party capabilities such as middleware,
196
- * time travel, persistence, etc. The only store enhancer that ships with Redux
197
- * is `applyMiddleware()`.
198
- *
199
- * @returns {Store} A Redux store that lets you read the state, dispatch actions
200
- * and subscribe to changes.
201
- */
202
-
203
- function createStore(reducer, preloadedState, enhancer) {
204
- var _ref2;
205
- if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
206
- throw new Error('It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function');
207
- }
208
- if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
209
- enhancer = preloadedState;
210
- preloadedState = undefined;
211
- }
212
- if (typeof enhancer !== 'undefined') {
213
- if (typeof enhancer !== 'function') {
214
- throw new Error('Expected the enhancer to be a function.');
215
- }
216
- return enhancer(createStore)(reducer, preloadedState);
217
- }
218
- if (typeof reducer !== 'function') {
219
- throw new Error('Expected the reducer to be a function.');
220
- }
221
- var currentReducer = reducer;
222
- var currentState = preloadedState;
223
- var currentListeners = [];
224
- var nextListeners = currentListeners;
225
- var isDispatching = false;
226
- function ensureCanMutateNextListeners() {
227
- if (nextListeners === currentListeners) {
228
- nextListeners = currentListeners.slice();
229
- }
230
- }
231
- /**
232
- * Reads the state tree managed by the store.
233
- *
234
- * @returns {any} The current state tree of your application.
235
- */
236
-
237
- function getState() {
238
- if (isDispatching) {
239
- throw new Error('You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
240
- }
241
- return currentState;
242
- }
243
- /**
244
- * Adds a change listener. It will be called any time an action is dispatched,
245
- * and some part of the state tree may potentially have changed. You may then
246
- * call `getState()` to read the current state tree inside the callback.
247
- *
248
- * You may call `dispatch()` from a change listener, with the following
249
- * caveats:
250
- *
251
- * 1. The subscriptions are snapshotted just before every `dispatch()` call.
252
- * If you subscribe or unsubscribe while the listeners are being invoked, this
253
- * will not have any effect on the `dispatch()` that is currently in progress.
254
- * However, the next `dispatch()` call, whether nested or not, will use a more
255
- * recent snapshot of the subscription list.
256
- *
257
- * 2. The listener should not expect to see all state changes, as the state
258
- * might have been updated multiple times during a nested `dispatch()` before
259
- * the listener is called. It is, however, guaranteed that all subscribers
260
- * registered before the `dispatch()` started will be called with the latest
261
- * state by the time it exits.
262
- *
263
- * @param {Function} listener A callback to be invoked on every dispatch.
264
- * @returns {Function} A function to remove this change listener.
265
- */
266
-
267
- function subscribe(listener) {
268
- if (typeof listener !== 'function') {
269
- throw new Error('Expected the listener to be a function.');
270
- }
271
- if (isDispatching) {
272
- throw new Error('You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api-reference/store#subscribe(listener) for more details.');
273
- }
274
- var isSubscribed = true;
275
- ensureCanMutateNextListeners();
276
- nextListeners.push(listener);
277
- return function unsubscribe() {
278
- if (!isSubscribed) {
279
- return;
280
- }
281
- if (isDispatching) {
282
- throw new Error('You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api-reference/store#subscribe(listener) for more details.');
283
- }
284
- isSubscribed = false;
285
- ensureCanMutateNextListeners();
286
- var index = nextListeners.indexOf(listener);
287
- nextListeners.splice(index, 1);
288
- };
289
- }
290
- /**
291
- * Dispatches an action. It is the only way to trigger a state change.
292
- *
293
- * The `reducer` function, used to create the store, will be called with the
294
- * current state tree and the given `action`. Its return value will
295
- * be considered the **next** state of the tree, and the change listeners
296
- * will be notified.
297
- *
298
- * The base implementation only supports plain object actions. If you want to
299
- * dispatch a Promise, an Observable, a thunk, or something else, you need to
300
- * wrap your store creating function into the corresponding middleware. For
301
- * example, see the documentation for the `redux-thunk` package. Even the
302
- * middleware will eventually dispatch plain object actions using this method.
303
- *
304
- * @param {Object} action A plain object representing “what changed”. It is
305
- * a good idea to keep actions serializable so you can record and replay user
306
- * sessions, or use the time travelling `redux-devtools`. An action must have
307
- * a `type` property which may not be `undefined`. It is a good idea to use
308
- * string constants for action types.
309
- *
310
- * @returns {Object} For convenience, the same action object you dispatched.
311
- *
312
- * Note that, if you use a custom middleware, it may wrap `dispatch()` to
313
- * return something else (for example, a Promise you can await).
314
- */
315
-
316
- function dispatch(action) {
317
- if (!isPlainObject(action)) {
318
- throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
319
- }
320
- if (typeof action.type === 'undefined') {
321
- throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
322
- }
323
- if (isDispatching) {
324
- throw new Error('Reducers may not dispatch actions.');
325
- }
326
- try {
327
- isDispatching = true;
328
- currentState = currentReducer(currentState, action);
329
- } finally {
330
- isDispatching = false;
331
- }
332
- var listeners = currentListeners = nextListeners;
333
- for (var i = 0; i < listeners.length; i++) {
334
- var listener = listeners[i];
335
- listener();
336
- }
337
- return action;
338
- }
339
- /**
340
- * Replaces the reducer currently used by the store to calculate the state.
341
- *
342
- * You might need this if your app implements code splitting and you want to
343
- * load some of the reducers dynamically. You might also need this if you
344
- * implement a hot reloading mechanism for Redux.
345
- *
346
- * @param {Function} nextReducer The reducer for the store to use instead.
347
- * @returns {void}
348
- */
349
-
350
- function replaceReducer(nextReducer) {
351
- if (typeof nextReducer !== 'function') {
352
- throw new Error('Expected the nextReducer to be a function.');
353
- }
354
- currentReducer = nextReducer;
355
- dispatch({
356
- type: ActionTypes.REPLACE
357
- });
358
- }
359
- /**
360
- * Interoperability point for observable/reactive libraries.
361
- * @returns {observable} A minimal observable of state changes.
362
- * For more information, see the observable proposal:
363
- * https://github.com/tc39/proposal-observable
364
- */
365
-
366
- function observable() {
367
- var _ref;
368
- var outerSubscribe = subscribe;
369
- return _ref = {
370
- /**
371
- * The minimal observable subscription method.
372
- * @param {Object} observer Any object that can be used as an observer.
373
- * The observer object should have a `next` method.
374
- * @returns {subscription} An object with an `unsubscribe` method that can
375
- * be used to unsubscribe the observable from the store, and prevent further
376
- * emission of values from the observable.
377
- */
378
- subscribe: function subscribe(observer) {
379
- if (typeof observer !== 'object' || observer === null) {
380
- throw new TypeError('Expected the observer to be an object.');
381
- }
382
- function observeState() {
383
- if (observer.next) {
384
- observer.next(getState());
385
- }
386
- }
387
- observeState();
388
- var unsubscribe = outerSubscribe(observeState);
389
- return {
390
- unsubscribe: unsubscribe
391
- };
392
- }
393
- }, _ref[result] = function () {
394
- return this;
395
- }, _ref;
396
- } // When a store is created, an "INIT" action is dispatched so that every
397
- // reducer returns their initial state. This effectively populates
398
- // the initial state tree.
399
-
400
- dispatch({
401
- type: ActionTypes.INIT
402
- });
403
- return _ref2 = {
404
- dispatch: dispatch,
405
- subscribe: subscribe,
406
- getState: getState,
407
- replaceReducer: replaceReducer
408
- }, _ref2[result] = observable, _ref2;
409
- }
410
-
411
- /**
412
-
413
- * Copyright (c) 2016 Video-React contributors
414
- * Copyright (c) 2025 ZingMe.Vn
415
- *
416
- * This source code is licensed under the MIT license found in the
417
- * LICENSE file in the root directory of this source tree.
418
- */
419
- var LOAD_START = 'video-react-player/LOAD_START';
420
- var CAN_PLAY = 'video-react-player/CAN_PLAY';
421
- var WAITING = 'video-react-player/WAITING';
422
- var CAN_PLAY_THROUGH = 'video-react-player/CAN_PLAY_THROUGH';
423
- var PLAYING = 'video-react-player/PLAYING';
424
- var PLAY = 'video-react-player/PLAY';
425
- var PAUSE = 'video-react-player/PAUSE';
426
- var END = 'video-react-player/END';
427
- var SEEKING = 'video-react-player/SEEKING';
428
- var SEEKED = 'video-react-player/SEEKED';
429
- var SEEKING_TIME = 'video-react-player/SEEKING_TIME';
430
- var END_SEEKING = 'video-react-player/END_SEEKING';
431
- var DURATION_CHANGE = 'video-react-player/DURATION_CHANGE';
432
- var TIME_UPDATE = 'video-react-player/TIME_UPDATE';
433
- var VOLUME_CHANGE = 'video-react-player/VOLUME_CHANGE';
434
- var PROGRESS_CHANGE = 'video-react-player/PROGRESS_CHANGE';
435
- var RATE_CHANGE = 'video-react-player/RATE_CHANGE';
436
- var SUSPEND = 'video-react-player/SUSPEND';
437
- var ABORT = 'video-react-player/ABORT';
438
- var EMPTIED = 'video-react-player/EMPTIED';
439
- var STALLED = 'video-react-player/STALLED';
440
- var LOADED_META_DATA = 'video-react-player/LOADED_META_DATA';
441
- var LOADED_DATA = 'video-react-player/LOADED_DATA';
442
- var RESIZE = 'video-react-player/RESIZE';
443
- var ERROR = 'video-react-player/ERROR';
444
- var ACTIVATE_TEXT_TRACK = 'video-react-player/ACTIVATE_TEXT_TRACK';
445
- var PICTURE_IN_PICTURE_CHANGE = 'video-react-player/PICTURE_IN_PICTURE_CHANGE';
446
- var LOOP_CHANGE = 'video-react-player/LOOP_CHANGE';
447
- var THEATER_MODE_CHANGE = 'video-react-player/THEATER_MODE_CHANGE';
448
- var QUALITY_CHANGE = 'video-react-player/QUALITY_CHANGE';
449
- function handleLoadStart(videoProps) {
450
- return {
451
- type: LOAD_START,
452
- videoProps: videoProps
453
- };
454
- }
455
- function handleCanPlay(videoProps) {
456
- return {
457
- type: CAN_PLAY,
458
- videoProps: videoProps
459
- };
460
- }
461
- function handleWaiting(videoProps) {
462
- return {
463
- type: WAITING,
464
- videoProps: videoProps
465
- };
466
- }
467
- function handleCanPlayThrough(videoProps) {
468
- return {
469
- type: CAN_PLAY_THROUGH,
470
- videoProps: videoProps
471
- };
472
- }
473
- function handlePlaying(videoProps) {
474
- return {
475
- type: PLAYING,
476
- videoProps: videoProps
477
- };
478
- }
479
- function handlePlay(videoProps) {
480
- return {
481
- type: PLAY,
482
- videoProps: videoProps
483
- };
484
- }
485
- function handlePause(videoProps) {
486
- return {
487
- type: PAUSE,
488
- videoProps: videoProps
489
- };
490
- }
491
- function handleEnd(videoProps) {
492
- return {
493
- type: END,
494
- videoProps: videoProps
495
- };
496
- }
497
- function handleSeeking(videoProps) {
498
- return {
499
- type: SEEKING,
500
- videoProps: videoProps
501
- };
502
- }
503
- function handleSeeked(videoProps) {
504
- return {
505
- type: SEEKED,
506
- videoProps: videoProps
507
- };
508
- }
509
- function handleDurationChange(videoProps) {
510
- return {
511
- type: DURATION_CHANGE,
512
- videoProps: videoProps
513
- };
514
- }
515
- function handleTimeUpdate(videoProps) {
516
- return {
517
- type: TIME_UPDATE,
518
- videoProps: videoProps
519
- };
520
- }
521
- function handleVolumeChange(videoProps) {
522
- return {
523
- type: VOLUME_CHANGE,
524
- videoProps: videoProps
525
- };
526
- }
527
- function handleProgressChange(videoProps) {
528
- return {
529
- type: PROGRESS_CHANGE,
530
- videoProps: videoProps
531
- };
532
- }
533
- function handleRateChange(videoProps) {
534
- return {
535
- type: RATE_CHANGE,
536
- videoProps: videoProps
537
- };
538
- }
539
- function handleSuspend(videoProps) {
540
- return {
541
- type: SUSPEND,
542
- videoProps: videoProps
543
- };
544
- }
545
- function handleAbort(videoProps) {
546
- return {
547
- type: ABORT,
548
- videoProps: videoProps
549
- };
550
- }
551
- function handleEmptied(videoProps) {
552
- return {
553
- type: EMPTIED,
554
- videoProps: videoProps
555
- };
556
- }
557
- function handleStalled(videoProps) {
558
- return {
559
- type: STALLED,
560
- videoProps: videoProps
561
- };
562
- }
563
- function handleLoadedMetaData(videoProps) {
564
- return {
565
- type: LOADED_META_DATA,
566
- videoProps: videoProps
567
- };
568
- }
569
- function handleLoadedData(videoProps) {
570
- return {
571
- type: LOADED_DATA,
572
- videoProps: videoProps
573
- };
574
- }
575
- function handleResize(videoProps) {
576
- return {
577
- type: RESIZE,
578
- videoProps: videoProps
579
- };
580
- }
581
- function handleError(videoProps) {
582
- return {
583
- type: ERROR,
584
- videoProps: videoProps
585
- };
586
- }
587
- function handleSeekingTime(time) {
588
- return {
589
- type: SEEKING_TIME,
590
- time: time
591
- };
592
- }
593
- function handleEndSeeking(time) {
594
- return {
595
- type: END_SEEKING,
596
- time: time
597
- };
598
- }
599
- function activateTextTrack(textTrack) {
600
- return {
601
- type: ACTIVATE_TEXT_TRACK,
602
- textTrack: textTrack
603
- };
604
- }
605
- function handlePictureInPictureChange(isPictureInPicture) {
606
- return {
607
- type: PICTURE_IN_PICTURE_CHANGE,
608
- isPictureInPicture: isPictureInPicture
609
- };
610
- }
611
- function handleLoopChange(loop) {
612
- return {
613
- type: LOOP_CHANGE,
614
- loop: loop
615
- };
616
- }
617
- function handleTheaterModeChange(isTheater) {
618
- return {
619
- type: THEATER_MODE_CHANGE,
620
- isTheater: isTheater
621
- };
622
- }
623
- function handleQualityChange(quality) {
624
- return {
625
- type: QUALITY_CHANGE,
626
- quality: quality
627
- };
628
- }
629
-
630
- var videoActions = /*#__PURE__*/Object.freeze({
631
- LOAD_START: LOAD_START,
632
- CAN_PLAY: CAN_PLAY,
633
- WAITING: WAITING,
634
- CAN_PLAY_THROUGH: CAN_PLAY_THROUGH,
635
- PLAYING: PLAYING,
636
- PLAY: PLAY,
637
- PAUSE: PAUSE,
638
- END: END,
639
- SEEKING: SEEKING,
640
- SEEKED: SEEKED,
641
- SEEKING_TIME: SEEKING_TIME,
642
- END_SEEKING: END_SEEKING,
643
- DURATION_CHANGE: DURATION_CHANGE,
644
- TIME_UPDATE: TIME_UPDATE,
645
- VOLUME_CHANGE: VOLUME_CHANGE,
646
- PROGRESS_CHANGE: PROGRESS_CHANGE,
647
- RATE_CHANGE: RATE_CHANGE,
648
- SUSPEND: SUSPEND,
649
- ABORT: ABORT,
650
- EMPTIED: EMPTIED,
651
- STALLED: STALLED,
652
- LOADED_META_DATA: LOADED_META_DATA,
653
- LOADED_DATA: LOADED_DATA,
654
- RESIZE: RESIZE,
655
- ERROR: ERROR,
656
- ACTIVATE_TEXT_TRACK: ACTIVATE_TEXT_TRACK,
657
- PICTURE_IN_PICTURE_CHANGE: PICTURE_IN_PICTURE_CHANGE,
658
- LOOP_CHANGE: LOOP_CHANGE,
659
- THEATER_MODE_CHANGE: THEATER_MODE_CHANGE,
660
- QUALITY_CHANGE: QUALITY_CHANGE,
661
- handleLoadStart: handleLoadStart,
662
- handleCanPlay: handleCanPlay,
663
- handleWaiting: handleWaiting,
664
- handleCanPlayThrough: handleCanPlayThrough,
665
- handlePlaying: handlePlaying,
666
- handlePlay: handlePlay,
667
- handlePause: handlePause,
668
- handleEnd: handleEnd,
669
- handleSeeking: handleSeeking,
670
- handleSeeked: handleSeeked,
671
- handleDurationChange: handleDurationChange,
672
- handleTimeUpdate: handleTimeUpdate,
673
- handleVolumeChange: handleVolumeChange,
674
- handleProgressChange: handleProgressChange,
675
- handleRateChange: handleRateChange,
676
- handleSuspend: handleSuspend,
677
- handleAbort: handleAbort,
678
- handleEmptied: handleEmptied,
679
- handleStalled: handleStalled,
680
- handleLoadedMetaData: handleLoadedMetaData,
681
- handleLoadedData: handleLoadedData,
682
- handleResize: handleResize,
683
- handleError: handleError,
684
- handleSeekingTime: handleSeekingTime,
685
- handleEndSeeking: handleEndSeeking,
686
- activateTextTrack: activateTextTrack,
687
- handlePictureInPictureChange: handlePictureInPictureChange,
688
- handleLoopChange: handleLoopChange,
689
- handleTheaterModeChange: handleTheaterModeChange,
690
- handleQualityChange: handleQualityChange
691
- });
692
-
693
- // Lazily grab the document to avoid SSR "document is not defined" errors.
694
- var doc = typeof document !== 'undefined' ? document : null;
695
- var Fullscreen = /*#__PURE__*/function () {
696
- function Fullscreen() {}
697
- var _proto = Fullscreen.prototype;
698
- _proto.request = function request(elm) {
699
- if (elm.requestFullscreen) {
700
- elm.requestFullscreen();
701
- } else if (elm.webkitRequestFullscreen) {
702
- elm.webkitRequestFullscreen();
703
- } else if (elm.mozRequestFullScreen) {
704
- elm.mozRequestFullScreen();
705
- } else if (elm.msRequestFullscreen) {
706
- elm.msRequestFullscreen();
707
- }
708
- };
709
- _proto.exit = function exit() {
710
- if (!doc) {
711
- return;
712
- }
713
- if (doc.exitFullscreen) {
714
- doc.exitFullscreen();
715
- } else if (doc.webkitExitFullscreen) {
716
- doc.webkitExitFullscreen();
717
- } else if (doc.mozCancelFullScreen) {
718
- doc.mozCancelFullScreen();
719
- } else if (doc.msExitFullscreen) {
720
- doc.msExitFullscreen();
721
- }
722
- };
723
- _proto.addEventListener = function addEventListener(handler) {
724
- if (!doc) {
725
- return;
726
- }
727
- doc.addEventListener('fullscreenchange', handler);
728
- doc.addEventListener('webkitfullscreenchange', handler);
729
- doc.addEventListener('mozfullscreenchange', handler);
730
- doc.addEventListener('MSFullscreenChange', handler);
731
- };
732
- _proto.removeEventListener = function removeEventListener(handler) {
733
- if (!doc) {
734
- return;
735
- }
736
- doc.removeEventListener('fullscreenchange', handler);
737
- doc.removeEventListener('webkitfullscreenchange', handler);
738
- doc.removeEventListener('mozfullscreenchange', handler);
739
- doc.removeEventListener('MSFullscreenChange', handler);
740
- };
741
- _createClass(Fullscreen, [{
742
- key: "isFullscreen",
743
- get: function get() {
744
- if (!doc) {
745
- return null;
746
- }
747
- return doc.fullscreenElement || doc.webkitFullscreenElement || doc.mozFullScreenElement || doc.msFullscreenElement;
748
- }
749
- }, {
750
- key: "enabled",
751
- get: function get() {
752
- if (!doc) {
753
- return false;
754
- }
755
- return doc.fullscreenEnabled || doc.webkitFullscreenEnabled || doc.mozFullScreenEnabled || doc.msFullscreenEnabled;
756
- }
757
- }]);
758
- return Fullscreen;
759
- }();
760
- var fullscreen = new Fullscreen();
761
-
762
- /**
763
-
764
- * Copyright (c) 2016 Video-React contributors
765
- * Copyright (c) 2025 ZingMe.Vn
766
- *
767
- * This source code is licensed under the MIT license found in the
768
- * LICENSE file in the root directory of this source tree.
769
- */
770
- var OPERATE = 'video-react-player/OPERATE';
771
- var FULLSCREEN_CHANGE = 'video-react-player/FULLSCREEN_CHANGE';
772
- var PLAYER_ACTIVATE = 'video-react-player/PLAYER_ACTIVATE';
773
- var USER_ACTIVATE = 'video-react-player/USER_ACTIVATE';
774
- function handleFullscreenChange(isFullscreen) {
775
- return {
776
- type: FULLSCREEN_CHANGE,
777
- isFullscreen: isFullscreen
778
- };
779
- }
780
- function activate(activity) {
781
- return {
782
- type: PLAYER_ACTIVATE,
783
- activity: activity
784
- };
785
- }
786
- function userActivate(activity) {
787
- return {
788
- type: USER_ACTIVATE,
789
- activity: activity
790
- };
791
- }
792
- function play(operation) {
793
- var _this$video;
794
- if (operation === void 0) {
795
- operation = {
796
- action: 'play',
797
- source: ''
798
- };
799
- }
800
- (_this$video = this.video) === null || _this$video === void 0 ? void 0 : _this$video.play();
801
- return {
802
- type: OPERATE,
803
- operation: operation
804
- };
805
- }
806
- function pause(operation) {
807
- var _this$video2;
808
- if (operation === void 0) {
809
- operation = {
810
- action: 'pause',
811
- source: ''
812
- };
813
- }
814
- (_this$video2 = this.video) === null || _this$video2 === void 0 ? void 0 : _this$video2.pause();
815
- return {
816
- type: OPERATE,
817
- operation: operation
818
- };
819
- }
820
- function togglePlay(operation) {
821
- var _this$video3;
822
- if (operation === void 0) {
823
- operation = {
824
- action: 'toggle-play',
825
- source: ''
826
- };
827
- }
828
- (_this$video3 = this.video) === null || _this$video3 === void 0 ? void 0 : _this$video3.togglePlay();
829
- return {
830
- type: OPERATE,
831
- operation: operation
832
- };
833
- }
834
-
835
- // seek video by time
836
- function seek(time, operation) {
837
- var _this$video4;
838
- if (operation === void 0) {
839
- operation = {
840
- action: 'seek',
841
- source: ''
842
- };
843
- }
844
- (_this$video4 = this.video) === null || _this$video4 === void 0 ? void 0 : _this$video4.seek(time);
845
- return {
846
- type: OPERATE,
847
- operation: operation
848
- };
849
- }
850
-
851
- // jump forward x seconds
852
- function forward(seconds, operation) {
853
- var _this$video5;
854
- if (operation === void 0) {
855
- operation = {
856
- action: "forward-" + seconds,
857
- source: ''
858
- };
859
- }
860
- (_this$video5 = this.video) === null || _this$video5 === void 0 ? void 0 : _this$video5.forward(seconds);
861
- return {
862
- type: OPERATE,
863
- operation: operation
864
- };
865
- }
866
-
867
- // jump back x seconds
868
- function replay(seconds, operation) {
869
- var _this$video6;
870
- if (operation === void 0) {
871
- operation = {
872
- action: "replay-" + seconds,
873
- source: ''
874
- };
875
- }
876
- (_this$video6 = this.video) === null || _this$video6 === void 0 ? void 0 : _this$video6.replay(seconds);
877
- return {
878
- type: OPERATE,
879
- operation: operation
880
- };
881
- }
882
- function changeRate(rate, operation) {
883
- if (operation === void 0) {
884
- operation = {
885
- action: 'change-rate',
886
- source: ''
887
- };
888
- }
889
- if (this.video) {
890
- this.video.playbackRate = rate;
891
- }
892
- return {
893
- type: OPERATE,
894
- operation: operation
895
- };
896
- }
897
- function changeVolume(volume, operation) {
898
- if (operation === void 0) {
899
- operation = {
900
- action: 'change-volume',
901
- source: ''
902
- };
903
- }
904
- var v = volume;
905
- if (volume < 0) {
906
- v = 0;
907
- }
908
- if (volume > 1) {
909
- v = 1;
910
- }
911
- if (this.video) {
912
- this.video.volume = v;
913
- }
914
- return {
915
- type: OPERATE,
916
- operation: operation
917
- };
918
- }
919
- function mute(muted, operation) {
920
- if (operation === void 0) {
921
- operation = {
922
- action: muted ? 'muted' : 'unmuted',
923
- source: ''
924
- };
925
- }
926
- if (this.video) {
927
- this.video.muted = muted;
928
- }
929
- return {
930
- type: OPERATE,
931
- operation: operation
932
- };
933
- }
934
- function toggleFullscreen(player) {
935
- if (fullscreen.enabled) {
936
- if (fullscreen.isFullscreen) {
937
- fullscreen.exit();
938
- } else if (this.rootElement) {
939
- fullscreen.request(this.rootElement);
940
- }
941
- return {
942
- type: OPERATE,
943
- operation: {
944
- action: 'toggle-fullscreen',
945
- source: ''
946
- }
947
- };
948
- }
949
- return {
950
- type: FULLSCREEN_CHANGE,
951
- isFullscreen: !player.isFullscreen
952
- };
953
- }
954
- function togglePictureInPicture() {
955
- var next = !this.store.getState().player.isPictureInPicture;
956
- return handlePictureInPictureChange(next);
957
- }
958
- function changeQuality(quality) {
959
- return handleQualityChange(quality);
960
- }
961
- function takeScreenshot() {
962
- return {
963
- type: OPERATE,
964
- operation: {
965
- action: 'screenshot',
966
- source: 'control'
967
- }
968
- };
969
- }
970
- function toggleTheaterMode(isTheater) {
971
- return handleTheaterModeChange(isTheater);
972
- }
973
-
974
- var playerActions = /*#__PURE__*/Object.freeze({
975
- OPERATE: OPERATE,
976
- FULLSCREEN_CHANGE: FULLSCREEN_CHANGE,
977
- PLAYER_ACTIVATE: PLAYER_ACTIVATE,
978
- USER_ACTIVATE: USER_ACTIVATE,
979
- handleFullscreenChange: handleFullscreenChange,
980
- activate: activate,
981
- userActivate: userActivate,
982
- play: play,
983
- pause: pause,
984
- togglePlay: togglePlay,
985
- seek: seek,
986
- forward: forward,
987
- replay: replay,
988
- changeRate: changeRate,
989
- changeVolume: changeVolume,
990
- mute: mute,
991
- toggleFullscreen: toggleFullscreen,
992
- togglePictureInPicture: togglePictureInPicture,
993
- changeQuality: changeQuality,
994
- takeScreenshot: takeScreenshot,
995
- toggleTheaterMode: toggleTheaterMode
996
- });
997
-
998
- var initialState = {
999
- currentSrc: null,
1000
- duration: 0,
1001
- currentTime: 0,
1002
- seekingTime: 0,
1003
- buffered: null,
1004
- textTracks: null,
1005
- waiting: false,
1006
- seeking: false,
1007
- paused: true,
1008
- autoPaused: false,
1009
- ended: false,
1010
- playbackRate: 1,
1011
- muted: false,
1012
- volume: 1,
1013
- readyState: 0,
1014
- networkState: 0,
1015
- videoWidth: 0,
1016
- videoHeight: 0,
1017
- hasStarted: false,
1018
- userActivity: true,
1019
- isActive: false,
1020
- isFullscreen: false,
1021
- isPictureInPicture: false,
1022
- loop: false,
1023
- isTheater: false,
1024
- quality: 'auto',
1025
- activeTextTrack: null
1026
- };
1027
- function player(state, action) {
1028
- if (state === void 0) {
1029
- state = initialState;
1030
- }
1031
- switch (action.type) {
1032
- case USER_ACTIVATE:
1033
- return _extends({}, state, {
1034
- userActivity: action.activity
1035
- });
1036
- case PLAYER_ACTIVATE:
1037
- return _extends({}, state, {
1038
- isActive: action.activity
1039
- });
1040
- case FULLSCREEN_CHANGE:
1041
- return _extends({}, state, {
1042
- isFullscreen: !!action.isFullscreen
1043
- });
1044
- case SEEKING_TIME:
1045
- return _extends({}, state, {
1046
- seekingTime: action.time
1047
- });
1048
- case END_SEEKING:
1049
- return _extends({}, state, {
1050
- seekingTime: 0
1051
- });
1052
- case LOAD_START:
1053
- return _extends({}, state, action.videoProps, {
1054
- hasStarted: false,
1055
- ended: false
1056
- });
1057
- case CAN_PLAY:
1058
- return _extends({}, state, action.videoProps, {
1059
- waiting: false
1060
- });
1061
- case WAITING:
1062
- return _extends({}, state, action.videoProps, {
1063
- waiting: true
1064
- });
1065
- case CAN_PLAY_THROUGH:
1066
- case PLAYING:
1067
- return _extends({}, state, action.videoProps, {
1068
- waiting: false
1069
- });
1070
- case PLAY:
1071
- return _extends({}, state, action.videoProps, {
1072
- ended: false,
1073
- paused: false,
1074
- autoPaused: false,
1075
- waiting: false,
1076
- hasStarted: true
1077
- });
1078
- case PAUSE:
1079
- return _extends({}, state, action.videoProps, {
1080
- paused: true
1081
- });
1082
- case END:
1083
- return _extends({}, state, action.videoProps, {
1084
- ended: true
1085
- });
1086
- case SEEKING:
1087
- return _extends({}, state, action.videoProps, {
1088
- seeking: true
1089
- });
1090
- case SEEKED:
1091
- return _extends({}, state, action.videoProps, {
1092
- seeking: false
1093
- });
1094
- case ERROR:
1095
- return _extends({}, state, action.videoProps, {
1096
- error: 'UNKNOWN ERROR',
1097
- ended: true
1098
- });
1099
- case DURATION_CHANGE:
1100
- case TIME_UPDATE:
1101
- case VOLUME_CHANGE:
1102
- case PROGRESS_CHANGE:
1103
- case RATE_CHANGE:
1104
- case SUSPEND:
1105
- case ABORT:
1106
- case EMPTIED:
1107
- case STALLED:
1108
- case LOADED_META_DATA:
1109
- case LOADED_DATA:
1110
- case RESIZE:
1111
- return _extends({}, state, action.videoProps);
1112
- case ACTIVATE_TEXT_TRACK:
1113
- return _extends({}, state, {
1114
- activeTextTrack: action.textTrack
1115
- });
1116
- case PICTURE_IN_PICTURE_CHANGE:
1117
- return _extends({}, state, {
1118
- isPictureInPicture: !!action.isPictureInPicture
1119
- });
1120
- case LOOP_CHANGE:
1121
- return _extends({}, state, {
1122
- loop: !!action.loop
1123
- });
1124
- case THEATER_MODE_CHANGE:
1125
- return _extends({}, state, {
1126
- isTheater: !!action.isTheater
1127
- });
1128
- case QUALITY_CHANGE:
1129
- return _extends({}, state, {
1130
- quality: action.quality || 'auto'
1131
- });
1132
- default:
1133
- return state;
1134
- }
1135
- }
1136
-
1137
- var initialState$1 = {
1138
- count: 0,
1139
- operation: {
1140
- action: '',
1141
- source: ''
1142
- }
1143
- };
1144
- function operation(state, action) {
1145
- if (state === void 0) {
1146
- state = initialState$1;
1147
- }
1148
- switch (action.type) {
1149
- case OPERATE:
1150
- return _extends({}, state, {
1151
- count: state.count + 1,
1152
- operation: _extends({}, state.operation, action.operation)
1153
- });
1154
- default:
1155
- return state;
1156
- }
1157
- }
1158
-
1159
- function reducer(state, action) {
1160
- return {
1161
- player: player(state === null || state === void 0 ? void 0 : state.player, action),
1162
- operation: operation(state === null || state === void 0 ? void 0 : state.operation, action)
1163
- };
1164
- }
1165
- var playerReducer = player;
1166
- var operationReducer = operation;
1167
-
1168
- var Manager = /*#__PURE__*/function () {
1169
- function Manager(store) {
1170
- this.store = void 0;
1171
- this.video = void 0;
1172
- this.rootElement = void 0;
1173
- this.boundActions = void 0;
1174
- this.store = store || createStore(reducer);
1175
- this.video = null;
1176
- this.rootElement = null;
1177
- this.boundActions = undefined;
1178
- }
1179
- var _proto = Manager.prototype;
1180
- _proto.getActions = function getActions() {
1181
- var _this = this;
1182
- if (this.boundActions) {
1183
- return this.boundActions;
1184
- }
1185
- var actions = _extends({}, playerActions, videoActions);
1186
- var bound = {};
1187
- Object.keys(actions).forEach(function (key) {
1188
- var creator = actions[key];
1189
- if (typeof creator !== 'function') {
1190
- return;
1191
- }
1192
- bound[key] = function () {
1193
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1194
- args[_key] = arguments[_key];
1195
- }
1196
- var action = creator.apply(_this, args);
1197
- if (typeof action !== 'undefined') {
1198
- _this.store.dispatch(action);
1199
- }
1200
- };
1201
- });
1202
- this.boundActions = bound;
1203
- return this.boundActions;
1204
- };
1205
- _proto.getState = function getState() {
1206
- return this.store.getState();
1207
- };
1208
- _proto.subscribeToStateChange = function subscribeToStateChange(listener, getState) {
1209
- if (getState === void 0) {
1210
- getState = this.getState.bind(this);
1211
- }
1212
- var prevState = getState();
1213
- var handleChange = function handleChange() {
1214
- var state = getState();
1215
- if (state === prevState) {
1216
- return;
1217
- }
1218
- var prevStateCopy = prevState;
1219
- prevState = state;
1220
- listener(state, prevStateCopy);
1221
- };
1222
- return this.store.subscribe(handleChange);
1223
- };
1224
- _proto.subscribeToOperationStateChange = function subscribeToOperationStateChange(listener) {
1225
- var _this2 = this;
1226
- return this.subscribeToStateChange(listener, function () {
1227
- return _this2.getState().operation;
1228
- });
1229
- };
1230
- _proto.subscribeToPlayerStateChange = function subscribeToPlayerStateChange(listener) {
1231
- var _this3 = this;
1232
- return this.subscribeToStateChange(listener, function () {
1233
- return _this3.getState().player;
1234
- });
1235
- };
1236
- return Manager;
1237
- }();
1238
-
1239
- // eslint-disable-next-line import/no-unresolved
1240
- var BigPlayButton = /*#__PURE__*/function (_Component) {
1241
- _inheritsLoose(BigPlayButton, _Component);
1242
- function BigPlayButton(props, context) {
1243
- var _this;
1244
- _this = _Component.call(this, props, context) || this;
1245
- _this.handleClick = _this.handleClick.bind(_assertThisInitialized(_this));
1246
- return _this;
1247
- }
1248
- var _proto = BigPlayButton.prototype;
1249
- _proto.componentDidMount = function componentDidMount() {};
1250
- _proto.handleClick = function handleClick(event) {
1251
- var _this$props$actions;
1252
- event.preventDefault();
1253
- (_this$props$actions = this.props.actions) === null || _this$props$actions === void 0 ? void 0 : _this$props$actions.play();
1254
- };
1255
- _proto.render = function render() {
1256
- var _player$hasStarted;
1257
- var _this$props = this.props,
1258
- player = _this$props.player,
1259
- position = _this$props.position;
1260
- var positionClass = position === 'center' ? 'center' : 'left';
1261
- var hasStarted = (_player$hasStarted = player === null || player === void 0 ? void 0 : player.hasStarted) !== null && _player$hasStarted !== void 0 ? _player$hasStarted : false;
1262
- var hasSource = (player === null || player === void 0 ? void 0 : player.currentSrc) !== undefined && (player === null || player === void 0 ? void 0 : player.currentSrc) !== '';
1263
- return React__default.createElement("button", {
1264
- className: classnames('video-react-player-button', 'video-react-player-big-play-button', "video-react-player-big-play-button-" + positionClass, this.props.className, {
1265
- // keep visible by default if player info is not provided
1266
- 'big-play-button-hide': hasStarted || !hasSource
1267
- }),
1268
- type: "button",
1269
- "aria-live": "polite",
1270
- tabIndex: 0,
1271
- onClick: this.handleClick
1272
- }, React__default.createElement("span", {
1273
- className: "video-react-player-control-text"
1274
- }, "Play Video"));
1275
- };
1276
- return BigPlayButton;
1277
- }(React.Component);
1278
- BigPlayButton.defaultProps = {
1279
- position: 'left'
1280
- };
1281
- BigPlayButton.displayName = 'BigPlayButton';
1282
-
1283
- function LoadingSpinner(_ref) {
1284
- var player = _ref.player,
1285
- className = _ref.className;
1286
- if (player.error) {
1287
- return null;
1288
- }
1289
- return React__default.createElement("div", {
1290
- className: classnames('video-react-player-loading-spinner', className)
1291
- });
1292
- }
1293
- LoadingSpinner.displayName = 'LoadingSpinner';
1294
-
1295
- function PosterImage(_ref) {
1296
- var poster = _ref.poster,
1297
- player = _ref.player,
1298
- actions = _ref.actions,
1299
- className = _ref.className;
1300
- if (!poster || player.hasStarted) {
1301
- return null;
1302
- }
1303
- return React__default.createElement("div", {
1304
- className: classnames('video-react-player-poster', className),
1305
- style: {
1306
- backgroundImage: "url(\"" + poster + "\")"
1307
- },
1308
- onClick: function onClick() {
1309
- if (player.paused) {
1310
- actions.play();
1311
- }
1312
- }
1313
- });
1314
- }
1315
- PosterImage.displayName = 'PosterImage';
1316
-
1317
- // NaN is the only value in javascript which is not equal to itself.
1318
- // eslint-disable-next-line no-self-compare
1319
- var isNaN = Number.isNaN || function (value) {
1320
- return value !== value;
1321
- };
1322
-
1323
- /**
1324
- * @file format-time.js
1325
- *
1326
- * Format seconds as a time string, H:MM:SS or M:SS
1327
- * Supplying a guide (in seconds) will force a number of leading zeros
1328
- * to cover the length of the guide
1329
- *
1330
- * @param {Number} seconds Number of seconds to be turned into a string
1331
- * @param {Number} guide Number (in seconds) to model the string after
1332
- * @return {String} Time formatted as H:MM:SS or M:SS
1333
- * @private
1334
- * @function formatTime
1335
- */
1336
- function formatTime(seconds, guide) {
1337
- if (seconds === void 0) {
1338
- seconds = 0;
1339
- }
1340
- if (guide === void 0) {
1341
- guide = seconds;
1342
- }
1343
- var s = Math.floor(seconds % 60);
1344
- var m = Math.floor(seconds / 60 % 60);
1345
- var h = Math.floor(seconds / 3600);
1346
- var gm = Math.floor(guide / 60 % 60);
1347
- var gh = Math.floor(guide / 3600);
1348
-
1349
- // handle invalid times
1350
- if (isNaN(seconds) || seconds === Infinity) {
1351
- // '-' is false for all relational operators (e.g. <, >=) so this setting
1352
- // will add the minimum number of fields specified by the guide
1353
- h = 0;
1354
- m = 0;
1355
- s = 0;
1356
- }
1357
- var hasHours = h > 0 || gh > 0;
1358
- var hours = hasHours ? h + ":" : '';
1359
- var minutes = ((hasHours || gm >= 10) && m < 10 ? "0" + m : m) + ":";
1360
- var secondsString = s < 10 ? "0" + s : "" + s;
1361
- return "" + hours + minutes + secondsString;
1362
- }
1363
-
1364
- // Check if the element belongs to a video element
1365
- // only accept <source />, <track />,
1366
- // <MyComponent isVideoChild />
1367
- // elements
1368
- function isVideoChild(c) {
1369
- if (!React__default.isValidElement(c)) {
1370
- return false;
1371
- }
1372
- if (c.props && c.props.isVideoChild) {
1373
- return true;
1374
- }
1375
- return c.type === 'source' || c.type === 'track';
1376
- }
1377
- var find = function find(elements, func) {
1378
- return elements.find(func);
1379
- };
1380
-
1381
- // check if two components are the same type
1382
- var isTypeEqual = function isTypeEqual(component1, component2) {
1383
- var type1 = component1.type;
1384
- var type2 = component2.type;
1385
- if (typeof type1 === 'string' || typeof type2 === 'string') {
1386
- return type1 === type2;
1387
- }
1388
- if (typeof type1 === 'function' && typeof type2 === 'function') {
1389
- return type1.displayName === type2.displayName;
1390
- }
1391
- return false;
1392
- };
1393
-
1394
- // merge default children
1395
- // sort them by `order` property
1396
- // filter them by `disabled` property
1397
- function mergeAndSortChildren(defaultChildren, _children, _parentProps, defaultOrder) {
1398
- if (defaultOrder === void 0) {
1399
- defaultOrder = 1;
1400
- }
1401
- var children = React__default.Children.toArray(_children).filter(React__default.isValidElement);
1402
- var _order = _parentProps.order,
1403
- parentProps = _objectWithoutPropertiesLoose(_parentProps, ["order"]); // ignore order from parent
1404
- return children.filter(function (e) {
1405
- return !e.props.disabled;
1406
- }) // filter the disabled components
1407
- .concat(defaultChildren.filter(function (c) {
1408
- return !find(children, function (component) {
1409
- return isTypeEqual(component, c);
1410
- });
1411
- })).map(function (element) {
1412
- var defaultComponent = find(defaultChildren, function (c) {
1413
- return isTypeEqual(c, element);
1414
- });
1415
- var defaultProps = defaultComponent ? defaultComponent.props : {};
1416
- var props = _extends({}, parentProps, defaultProps, element.props);
1417
- return React__default.cloneElement(element, props, element.props.children);
1418
- }).sort(function (a, b) {
1419
- return (a.props.order || defaultOrder) - (b.props.order || defaultOrder);
1420
- });
1421
- }
1422
-
1423
- /**
1424
- * Temporary utility for generating the warnings
1425
- */
1426
- function deprecatedWarning(oldMethodCall, newMethodCall) {
1427
- // eslint-disable-next-line no-console
1428
- console.warn("WARNING: " + oldMethodCall + " will be deprecated soon! Please use " + newMethodCall + " instead.");
1429
- }
1430
- function throttle(callback, limit) {
1431
- var wait = false;
1432
- return function () {
1433
- if (!wait) {
1434
- callback.apply(void 0, arguments);
1435
- wait = true;
1436
- setTimeout(function () {
1437
- wait = false;
1438
- }, limit);
1439
- }
1440
- };
1441
- }
1442
- var mediaProperties = ['error', 'src', 'srcObject', 'currentSrc', 'crossOrigin', 'networkState', 'preload', 'buffered', 'readyState', 'seeking', 'currentTime', 'duration', 'paused', 'defaultPlaybackRate', 'playbackRate', 'played', 'seekable', 'ended', 'autoplay', 'loop', 'mediaGroup', 'controller', 'controls', 'volume', 'muted', 'defaultMuted', 'audioTracks', 'videoTracks', 'textTracks', 'width', 'height', 'videoWidth', 'videoHeight', 'poster'];
1443
-
1444
- var Video = React.forwardRef(function (props, ref) {
1445
- var actions = props.actions,
1446
- player = props.player,
1447
- children = props.children,
1448
- startTime = props.startTime,
1449
- loop = props.loop,
1450
- poster = props.poster,
1451
- preload = props.preload,
1452
- src = props.src,
1453
- autoPlay = props.autoPlay,
1454
- playsInline = props.playsInline,
1455
- muted = props.muted,
1456
- crossOrigin = props.crossOrigin,
1457
- videoId = props.videoId,
1458
- className = props.className,
1459
- onLoadStart = props.onLoadStart,
1460
- onWaiting = props.onWaiting,
1461
- onCanPlay = props.onCanPlay,
1462
- onCanPlayThrough = props.onCanPlayThrough,
1463
- onPlaying = props.onPlaying,
1464
- onEnded = props.onEnded,
1465
- onSeeking = props.onSeeking,
1466
- onSeeked = props.onSeeked,
1467
- onPlay = props.onPlay,
1468
- onPause = props.onPause,
1469
- onProgress = props.onProgress,
1470
- onDurationChange = props.onDurationChange,
1471
- onError = props.onError,
1472
- onSuspend = props.onSuspend,
1473
- onAbort = props.onAbort,
1474
- onEmptied = props.onEmptied,
1475
- onStalled = props.onStalled,
1476
- onLoadedMetadata = props.onLoadedMetadata,
1477
- onLoadedData = props.onLoadedData,
1478
- onTimeUpdate = props.onTimeUpdate,
1479
- onRateChange = props.onRateChange,
1480
- onVolumeChange = props.onVolumeChange,
1481
- onResize = props.onResize;
1482
- var videoRef = React.useRef(null);
1483
- var propsRef = React.useRef(props);
1484
- propsRef.current = props;
1485
- var _useReducer = React.useReducer(function (count) {
1486
- return count + 1;
1487
- }, 0),
1488
- forceRender = _useReducer[1];
1489
- React.useEffect(function () {
1490
- forceRender();
1491
- }, []);
1492
- var getVideoProperties = React.useCallback(function () {
1493
- var video = videoRef.current;
1494
- if (!video) {
1495
- return {};
1496
- }
1497
- return mediaProperties.reduce(function (acc, key) {
1498
- var videoKey = key;
1499
- acc[key] = video === null || video === void 0 ? void 0 : video[videoKey];
1500
- return acc;
1501
- }, {});
1502
- }, []);
1503
- var createVideoEventHandler = React.useCallback(function (dispatcher, callback) {
1504
- return function () {
1505
- dispatcher(getVideoProperties());
1506
- if (callback) {
1507
- callback.apply(void 0, arguments);
1508
- }
1509
- };
1510
- }, [getVideoProperties]);
1511
- var handleLoadStart = React.useMemo(function () {
1512
- return createVideoEventHandler(actions.handleLoadStart, onLoadStart);
1513
- }, [actions.handleLoadStart, onLoadStart, createVideoEventHandler]);
1514
- var handleWaiting = React.useMemo(function () {
1515
- return createVideoEventHandler(actions.handleWaiting, onWaiting);
1516
- }, [actions.handleWaiting, onWaiting, createVideoEventHandler]);
1517
- var handleCanPlay = React.useMemo(function () {
1518
- return createVideoEventHandler(actions.handleCanPlay, onCanPlay);
1519
- }, [actions.handleCanPlay, onCanPlay, createVideoEventHandler]);
1520
- var handleCanPlayThrough = React.useMemo(function () {
1521
- return createVideoEventHandler(actions.handleCanPlayThrough, onCanPlayThrough);
1522
- }, [actions.handleCanPlayThrough, onCanPlayThrough, createVideoEventHandler]);
1523
- var handlePlaying = React.useMemo(function () {
1524
- return createVideoEventHandler(actions.handlePlaying, onPlaying);
1525
- }, [actions.handlePlaying, onPlaying, createVideoEventHandler]);
1526
- var handlePlay = React.useMemo(function () {
1527
- return createVideoEventHandler(actions.handlePlay, onPlay);
1528
- }, [actions.handlePlay, onPlay, createVideoEventHandler]);
1529
- var handlePause = React.useMemo(function () {
1530
- return createVideoEventHandler(actions.handlePause, onPause);
1531
- }, [actions.handlePause, onPause, createVideoEventHandler]);
1532
- var handleDurationChange = React.useMemo(function () {
1533
- return createVideoEventHandler(actions.handleDurationChange, onDurationChange);
1534
- }, [actions.handleDurationChange, onDurationChange, createVideoEventHandler]);
1535
- var handleTimeUpdate = React.useMemo(function () {
1536
- return createVideoEventHandler(actions.handleTimeUpdate, onTimeUpdate);
1537
- }, [actions.handleTimeUpdate, onTimeUpdate, createVideoEventHandler]);
1538
- var handleRateChange = React.useMemo(function () {
1539
- return createVideoEventHandler(actions.handleRateChange, onRateChange);
1540
- }, [actions.handleRateChange, onRateChange, createVideoEventHandler]);
1541
- var handleVolumeChange = React.useMemo(function () {
1542
- return createVideoEventHandler(actions.handleVolumeChange, onVolumeChange);
1543
- }, [actions.handleVolumeChange, onVolumeChange, createVideoEventHandler]);
1544
- var handleSuspend = React.useMemo(function () {
1545
- return createVideoEventHandler(actions.handleSuspend, onSuspend);
1546
- }, [actions.handleSuspend, onSuspend, createVideoEventHandler]);
1547
- var handleAbort = React.useMemo(function () {
1548
- return createVideoEventHandler(actions.handleAbort, onAbort);
1549
- }, [actions.handleAbort, onAbort, createVideoEventHandler]);
1550
- var handleEmptied = React.useMemo(function () {
1551
- return createVideoEventHandler(actions.handleEmptied, onEmptied);
1552
- }, [actions.handleEmptied, onEmptied, createVideoEventHandler]);
1553
- var handleStalled = React.useMemo(function () {
1554
- return createVideoEventHandler(actions.handleStalled, onStalled);
1555
- }, [actions.handleStalled, onStalled, createVideoEventHandler]);
1556
- var handleResize = React.useMemo(function () {
1557
- return createVideoEventHandler(actions.handleResize, onResize);
1558
- }, [actions.handleResize, onResize, createVideoEventHandler]);
1559
- var throttledProgress = React.useMemo(function () {
1560
- return throttle(function () {
1561
- actions.handleProgressChange(getVideoProperties());
1562
- }, 250);
1563
- }, [actions, getVideoProperties]);
1564
- var handleProgress = React.useCallback(function (event) {
1565
- throttledProgress();
1566
- onProgress === null || onProgress === void 0 ? void 0 : onProgress(event);
1567
- }, [onProgress, throttledProgress]);
1568
- var handleError = React.useCallback(function (event) {
1569
- actions.handleError(getVideoProperties());
1570
- onError === null || onError === void 0 ? void 0 : onError(event);
1571
- }, [actions, getVideoProperties, onError]);
1572
- var handleSeeking = React.useCallback(function (event) {
1573
- actions.handleSeeking(getVideoProperties());
1574
- onSeeking === null || onSeeking === void 0 ? void 0 : onSeeking(event);
1575
- }, [actions, getVideoProperties, onSeeking]);
1576
- var handleSeeked = React.useCallback(function (event) {
1577
- actions.handleSeeked(getVideoProperties());
1578
- onSeeked === null || onSeeked === void 0 ? void 0 : onSeeked(event);
1579
- }, [actions, getVideoProperties, onSeeked]);
1580
- var handleEnd = React.useCallback(function (event) {
1581
- var video = videoRef.current;
1582
- if (loop && video) {
1583
- video.currentTime = 0;
1584
- var promise = video.play();
1585
- promise === null || promise === void 0 ? void 0 : promise.catch(function () {});
1586
- } else if (video && !player.paused) {
1587
- video.pause();
1588
- }
1589
- actions.handleEnd(getVideoProperties());
1590
- onEnded === null || onEnded === void 0 ? void 0 : onEnded(event);
1591
- }, [actions, getVideoProperties, loop, onEnded, player.paused]);
1592
- var handleLoadedMetadata = React.useCallback(function (event) {
1593
- var video = videoRef.current;
1594
- if (typeof startTime === 'number' && startTime > 0 && video) {
1595
- video.currentTime = startTime;
1596
- }
1597
- actions.handleLoadedMetaData(getVideoProperties());
1598
- onLoadedMetadata === null || onLoadedMetadata === void 0 ? void 0 : onLoadedMetadata(event);
1599
- }, [actions, getVideoProperties, onLoadedMetadata, startTime]);
1600
- var handleLoadedData = React.useCallback(function (event) {
1601
- actions.handleLoadedData(getVideoProperties());
1602
- onLoadedData === null || onLoadedData === void 0 ? void 0 : onLoadedData(event);
1603
- }, [actions, getVideoProperties, onLoadedData]);
1604
- var handleTextTrackChange = React.useCallback(function () {
1605
- var video = videoRef.current;
1606
- if (video && video.textTracks) {
1607
- var activeTextTrack = Array.from(video.textTracks).find(function (textTrack) {
1608
- return textTrack.mode === 'showing';
1609
- });
1610
- if (activeTextTrack !== player.activeTextTrack) {
1611
- actions.activateTextTrack(activeTextTrack !== null && activeTextTrack !== void 0 ? activeTextTrack : null);
1612
- }
1613
- }
1614
- }, [actions, player.activeTextTrack]);
1615
- React.useEffect(function () {
1616
- var video = videoRef.current;
1617
- if (!video) {
1618
- return undefined;
1619
- }
1620
- if (video.textTracks) {
1621
- video.textTracks.onaddtrack = handleTextTrackChange;
1622
- video.textTracks.onremovetrack = handleTextTrackChange;
1623
- }
1624
- var handleEnterPiP = function handleEnterPiP() {
1625
- return actions.handlePictureInPictureChange(true);
1626
- };
1627
- var handleLeavePiP = function handleLeavePiP() {
1628
- return actions.handlePictureInPictureChange(false);
1629
- };
1630
- video.addEventListener('enterpictureinpicture', handleEnterPiP);
1631
- video.addEventListener('leavepictureinpicture', handleLeavePiP);
1632
- return function () {
1633
- video.removeEventListener('enterpictureinpicture', handleEnterPiP);
1634
- video.removeEventListener('leavepictureinpicture', handleLeavePiP);
1635
- };
1636
- }, [actions, handleTextTrackChange]);
1637
- var apiRef = React.useRef();
1638
- if (!apiRef.current) {
1639
- var getVideo = function getVideo() {
1640
- return videoRef.current;
1641
- };
1642
- apiRef.current = {
1643
- play: function play() {
1644
- var _getVideo;
1645
- var promise = (_getVideo = getVideo()) === null || _getVideo === void 0 ? void 0 : _getVideo.play();
1646
- if (promise && typeof promise.catch === 'function') {
1647
- promise.catch(function () {});
1648
- }
1649
- },
1650
- pause: function pause() {
1651
- var video = getVideo();
1652
- var promiseLike = video === null || video === void 0 ? void 0 : video.pause();
1653
- if (typeof promiseLike === 'object' && promiseLike !== null && 'catch' in promiseLike && typeof promiseLike.catch === 'function') {
1654
- promiseLike.catch(function () {});
1655
- }
1656
- },
1657
- load: function load() {
1658
- var _getVideo2;
1659
- (_getVideo2 = getVideo()) === null || _getVideo2 === void 0 ? void 0 : _getVideo2.load();
1660
- },
1661
- addTextTrack: function addTextTrack(kind, label, language) {
1662
- var video = getVideo();
1663
- return video ? video.addTextTrack(kind, label, language) : {};
1664
- },
1665
- canPlayType: function canPlayType() {
1666
- var _getVideo$canPlayType, _getVideo3;
1667
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1668
- args[_key] = arguments[_key];
1669
- }
1670
- return (_getVideo$canPlayType = (_getVideo3 = getVideo()) === null || _getVideo3 === void 0 ? void 0 : _getVideo3.canPlayType.apply(_getVideo3, args)) !== null && _getVideo$canPlayType !== void 0 ? _getVideo$canPlayType : '';
1671
- },
1672
- togglePlay: function togglePlay() {
1673
- var video = getVideo();
1674
- if (!video) {
1675
- return;
1676
- }
1677
- if (video.paused) {
1678
- var promise = video.play();
1679
- if (promise && typeof promise.catch === 'function') {
1680
- promise.catch(function () {});
1681
- }
1682
- } else {
1683
- var promiseLike = video.pause();
1684
- if (typeof promiseLike === 'object' && promiseLike !== null && 'catch' in promiseLike && typeof promiseLike.catch === 'function') {
1685
- promiseLike.catch(function () {});
1686
- }
1687
- }
1688
- },
1689
- seek: function seek(time) {
1690
- var video = getVideo();
1691
- if (!video) {
1692
- return;
1693
- }
1694
- try {
1695
- video.currentTime = time;
1696
- } catch (err) {
1697
- // ignore
1698
- }
1699
- },
1700
- forward: function forward(seconds) {
1701
- var video = getVideo();
1702
- if (video) {
1703
- var _apiRef$current;
1704
- (_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.seek(video.currentTime + seconds);
1705
- }
1706
- },
1707
- replay: function replay(seconds) {
1708
- var _apiRef$current2;
1709
- (_apiRef$current2 = apiRef.current) === null || _apiRef$current2 === void 0 ? void 0 : _apiRef$current2.forward(-seconds);
1710
- },
1711
- toggleFullscreen: function toggleFullscreen() {
1712
- propsRef.current.actions.toggleFullscreen(propsRef.current.player);
1713
- },
1714
- get playbackRate() {
1715
- var _getVideo$playbackRat, _getVideo4;
1716
- return (_getVideo$playbackRat = (_getVideo4 = getVideo()) === null || _getVideo4 === void 0 ? void 0 : _getVideo4.playbackRate) !== null && _getVideo$playbackRat !== void 0 ? _getVideo$playbackRat : 1;
1717
- },
1718
- set playbackRate(rate) {
1719
- var video = getVideo();
1720
- if (video) {
1721
- video.playbackRate = rate;
1722
- }
1723
- },
1724
- get muted() {
1725
- var _getVideo$muted, _getVideo5;
1726
- return (_getVideo$muted = (_getVideo5 = getVideo()) === null || _getVideo5 === void 0 ? void 0 : _getVideo5.muted) !== null && _getVideo$muted !== void 0 ? _getVideo$muted : false;
1727
- },
1728
- set muted(value) {
1729
- var video = getVideo();
1730
- if (video) {
1731
- video.muted = value;
1732
- }
1733
- },
1734
- get volume() {
1735
- var _getVideo$volume, _getVideo6;
1736
- return (_getVideo$volume = (_getVideo6 = getVideo()) === null || _getVideo6 === void 0 ? void 0 : _getVideo6.volume) !== null && _getVideo$volume !== void 0 ? _getVideo$volume : 1;
1737
- },
1738
- set volume(value) {
1739
- var video = getVideo();
1740
- if (video) {
1741
- video.volume = Math.max(0, Math.min(1, value));
1742
- }
1743
- },
1744
- get videoWidth() {
1745
- var _getVideo$videoWidth, _getVideo7;
1746
- return (_getVideo$videoWidth = (_getVideo7 = getVideo()) === null || _getVideo7 === void 0 ? void 0 : _getVideo7.videoWidth) !== null && _getVideo$videoWidth !== void 0 ? _getVideo$videoWidth : 0;
1747
- },
1748
- get videoHeight() {
1749
- var _getVideo$videoHeight, _getVideo8;
1750
- return (_getVideo$videoHeight = (_getVideo8 = getVideo()) === null || _getVideo8 === void 0 ? void 0 : _getVideo8.videoHeight) !== null && _getVideo$videoHeight !== void 0 ? _getVideo$videoHeight : 0;
1751
- },
1752
- get video() {
1753
- return getVideo();
1754
- }
1755
- };
1756
- }
1757
- React.useImperativeHandle(ref, function () {
1758
- return apiRef.current;
1759
- }, []);
1760
- var renderedChildren = React.useMemo(function () {
1761
- if (!apiRef.current) {
1762
- return null;
1763
- }
1764
- var sharedProps = _extends({}, props, {
1765
- video: apiRef.current
1766
- });
1767
- return React__default.Children.toArray(children).filter(isVideoChild).map(function (child) {
1768
- var element = child;
1769
- if (typeof element.type === 'string') {
1770
- if (element.type === 'source') {
1771
- var childProps = _extends({}, element.props);
1772
- var originalOnError = childProps.onError;
1773
- childProps.onError = function () {
1774
- if (originalOnError) {
1775
- originalOnError.apply(void 0, arguments);
1776
- }
1777
- actions.handleError(getVideoProperties());
1778
- };
1779
- return React__default.cloneElement(element, childProps);
1780
- }
1781
- return element;
1782
- }
1783
- return React__default.cloneElement(element, sharedProps);
1784
- });
1785
- }, [actions, children, getVideoProperties, props]);
1786
- return React__default.createElement("video", {
1787
- className: classnames('video-react-player-video', className),
1788
- id: videoId,
1789
- crossOrigin: crossOrigin,
1790
- ref: videoRef,
1791
- muted: muted,
1792
- preload: preload,
1793
- loop: loop,
1794
- playsInline: playsInline,
1795
- autoPlay: autoPlay,
1796
- poster: poster,
1797
- src: src,
1798
- onLoadStart: handleLoadStart,
1799
- onWaiting: handleWaiting,
1800
- onCanPlay: handleCanPlay,
1801
- onCanPlayThrough: handleCanPlayThrough,
1802
- onPlaying: handlePlaying,
1803
- onEnded: handleEnd,
1804
- onSeeking: handleSeeking,
1805
- onSeeked: handleSeeked,
1806
- onPlay: handlePlay,
1807
- onPause: handlePause,
1808
- onProgress: handleProgress,
1809
- onDurationChange: handleDurationChange,
1810
- onError: handleError,
1811
- onSuspend: handleSuspend,
1812
- onAbort: handleAbort,
1813
- onEmptied: handleEmptied,
1814
- onStalled: handleStalled,
1815
- onLoadedMetadata: handleLoadedMetadata,
1816
- onLoadedData: handleLoadedData,
1817
- onTimeUpdate: handleTimeUpdate,
1818
- onRateChange: handleRateChange,
1819
- onVolumeChange: handleVolumeChange,
1820
- onResize: handleResize,
1821
- tabIndex: -1
1822
- }, renderedChildren);
1823
- });
1824
- Video.displayName = 'Video';
1825
-
1826
- var Bezel = /*#__PURE__*/function (_Component) {
1827
- _inheritsLoose(Bezel, _Component);
1828
- function Bezel(props, context) {
1829
- var _this;
1830
- _this = _Component.call(this, props, context) || this;
1831
- _this.timer = null;
1832
- props.manager.subscribeToOperationStateChange(_this.handleStateChange.bind(_assertThisInitialized(_this)));
1833
- _this.state = {
1834
- hidden: true,
1835
- operation: {
1836
- action: '',
1837
- source: ''
1838
- },
1839
- count: 0
1840
- };
1841
- return _this;
1842
- }
1843
- var _proto = Bezel.prototype;
1844
- _proto.handleStateChange = function handleStateChange(state, prevState) {
1845
- var _this2 = this;
1846
- if (state.count !== prevState.count && state.operation.source === 'shortcut') {
1847
- if (this.timer) {
1848
- // previous animation is not finished
1849
- clearTimeout(this.timer); // cancel it
1850
- this.timer = null;
1851
- }
1852
-
1853
- // show it
1854
- // update operation
1855
- this.setState({
1856
- hidden: false,
1857
- count: state.count,
1858
- operation: state.operation
1859
- });
1860
-
1861
- // hide it after 0.5s
1862
- this.timer = window.setTimeout(function () {
1863
- _this2.setState({
1864
- hidden: true
1865
- });
1866
- _this2.timer = null;
1867
- }, 500);
1868
- }
1869
- };
1870
- _proto.render = function render() {
1871
- // only displays for shortcut so far
1872
- if (this.state.operation.source !== 'shortcut') {
1873
- return null;
1874
- }
1875
- var style = this.state.hidden ? {
1876
- display: 'none'
1877
- } : null;
1878
- return React__default.createElement("div", {
1879
- className: classnames({
1880
- 'video-react-player-bezel': true,
1881
- 'video-react-player-bezel-animation': this.state.count % 2 === 0,
1882
- 'video-react-player-bezel-animation-alt': this.state.count % 2 === 1
1883
- }, this.props.className),
1884
- style: style,
1885
- role: "status",
1886
- "aria-label": this.state.operation.action
1887
- }, React__default.createElement("div", {
1888
- className: classnames('video-react-player-bezel-icon', "video-react-player-bezel-icon-" + this.state.operation.action)
1889
- }));
1890
- };
1891
- return Bezel;
1892
- }(React.Component);
1893
- Bezel.displayName = 'Bezel';
1894
-
1895
- /**
1896
- * Offset Left
1897
- * getBoundingClientRect technique from
1898
- * John Resig http://ejohn.org/blog/getboundingclientrect-is-awesome/
1899
- *
1900
- * @function findElPosition
1901
- * @param {ReactNodeRef} el React Node ref from which to get offset
1902
- * @return {Object}
1903
- */
1904
- function findElPosition(el) {
1905
- var box;
1906
- if (el.getBoundingClientRect && el.parentNode) {
1907
- box = el.getBoundingClientRect();
1908
- }
1909
- if (!box) {
1910
- return {
1911
- left: 0,
1912
- top: 0
1913
- };
1914
- }
1915
- var _document = document,
1916
- body = _document.body,
1917
- docEl = _document.documentElement;
1918
- var clientLeft = docEl.clientLeft || body.clientLeft || 0;
1919
- var scrollLeft = window.pageXOffset || body.scrollLeft;
1920
- var left = box.left + scrollLeft - clientLeft;
1921
- var clientTop = docEl.clientTop || body.clientTop || 0;
1922
- var scrollTop = window.pageYOffset || body.scrollTop;
1923
- var top = box.top + scrollTop - clientTop;
1924
-
1925
- // Android sometimes returns slightly off decimal values, so need to round
1926
- return {
1927
- left: Math.round(left),
1928
- top: Math.round(top)
1929
- };
1930
- }
1931
-
1932
- /**
1933
- * Get pointer position in a React Node ref
1934
- * Returns an object with x and y coordinates.
1935
- * The base on the coordinates are the bottom left of the element.
1936
- *
1937
- * @function getPointerPosition
1938
- * @param {ReactNodeRef} el React Node ref on which to get the pointer position on
1939
- * @param {Event} event Event object
1940
- * @return {Object} This object will have x and y coordinates corresponding to the mouse position
1941
- */
1942
- function getPointerPosition(el, event) {
1943
- var position = {};
1944
- var box = findElPosition(el);
1945
- var boxW = el.offsetWidth;
1946
- var boxH = el.offsetHeight;
1947
- var boxY = box.top;
1948
- var boxX = box.left;
1949
- var evtPageY = event.pageY;
1950
- var evtPageX = event.pageX;
1951
- if ('changedTouches' in event && event.changedTouches.length) {
1952
- evtPageX = event.changedTouches[0].pageX;
1953
- evtPageY = event.changedTouches[0].pageY;
1954
- }
1955
- position.y = Math.max(0, Math.min(1, (boxY - evtPageY + boxH) / boxH));
1956
- position.x = Math.max(0, Math.min(1, (evtPageX - boxX) / boxW));
1957
- return position;
1958
- }
1959
-
1960
- // focus an element
1961
- function focusNode(reactNode) {
1962
- if (reactNode && reactNode.focus) {
1963
- reactNode.focus();
1964
- }
1965
- }
1966
-
1967
- // check if an element has a class name
1968
- function hasClass(elm, cls) {
1969
- var classes = elm.className.split(' ');
1970
- for (var i = 0; i < classes.length; i += 1) {
1971
- if (classes[i].toLowerCase() === cls.toLowerCase()) {
1972
- return true;
1973
- }
1974
- }
1975
- return false;
1976
- }
1977
-
1978
- var Shortcut = /*#__PURE__*/function (_Component) {
1979
- _inheritsLoose(Shortcut, _Component);
1980
- function Shortcut(props, context) {
1981
- var _this;
1982
- _this = _Component.call(this, props, context) || this;
1983
- _this.defaultShortcuts = void 0;
1984
- _this.shortcuts = [];
1985
- _this.defaultShortcuts = [{
1986
- keyCode: 32,
1987
- // spacebar
1988
- handle: _this.togglePlay
1989
- }, {
1990
- keyCode: 75,
1991
- // k
1992
- handle: _this.togglePlay
1993
- }, {
1994
- keyCode: 70,
1995
- // f
1996
- handle: _this.toggleFullscreen
1997
- }, {
1998
- keyCode: 37,
1999
- // Left arrow
2000
- handle: function handle(player, actions) {
2001
- if (!player.hasStarted) {
2002
- return;
2003
- }
2004
- actions.replay(5, {
2005
- action: 'replay-5',
2006
- source: 'shortcut'
2007
- }); // Go back 5 seconds
2008
- }
2009
- }, {
2010
- keyCode: 74,
2011
- // j
2012
- handle: function handle(player, actions) {
2013
- if (!player.hasStarted) {
2014
- return;
2015
- }
2016
- actions.replay(10, {
2017
- action: 'replay-10',
2018
- source: 'shortcut'
2019
- }); // Go back 10 seconds
2020
- }
2021
- }, {
2022
- keyCode: 39,
2023
- // Right arrow
2024
- handle: function handle(player, actions) {
2025
- if (!player.hasStarted) {
2026
- return;
2027
- }
2028
- actions.forward(5, {
2029
- action: 'forward-5',
2030
- source: 'shortcut'
2031
- }); // Go forward 5 seconds
2032
- }
2033
- }, {
2034
- keyCode: 76,
2035
- // l
2036
- handle: function handle(player, actions) {
2037
- if (!player.hasStarted) {
2038
- return;
2039
- }
2040
- actions.forward(10, {
2041
- action: 'forward-10',
2042
- source: 'shortcut'
2043
- }); // Go forward 10 seconds
2044
- }
2045
- }, {
2046
- keyCode: 36,
2047
- // Home
2048
- handle: function handle(player, actions) {
2049
- if (!player.hasStarted) {
2050
- return;
2051
- }
2052
- actions.seek(0); // Go to beginning of video
2053
- }
2054
- }, {
2055
- keyCode: 35,
2056
- // End
2057
- handle: function handle(player, actions) {
2058
- if (!player.hasStarted) {
2059
- return;
2060
- }
2061
- // Go to end of video
2062
- actions.seek(player.duration);
2063
- }
2064
- }, {
2065
- keyCode: 38,
2066
- // Up arrow
2067
- handle: function handle(player, actions) {
2068
- // Increase volume 5%
2069
- var v = player.volume + 0.05;
2070
- if (v > 1) {
2071
- v = 1;
2072
- }
2073
- actions.changeVolume(v, {
2074
- action: 'volume-up',
2075
- source: 'shortcut'
2076
- });
2077
- }
2078
- }, {
2079
- keyCode: 40,
2080
- // Down arrow
2081
- handle: function handle(player, actions) {
2082
- // Decrease volume 5%
2083
- var v = player.volume - 0.05;
2084
- if (v < 0) {
2085
- v = 0;
2086
- }
2087
- var action = v > 0 ? 'volume-down' : 'volume-off';
2088
- actions.changeVolume(v, {
2089
- action: action,
2090
- source: 'shortcut'
2091
- });
2092
- }
2093
- }, {
2094
- keyCode: 190,
2095
- // Shift + >
2096
- shift: true,
2097
- handle: function handle(player, actions) {
2098
- // Increase speed
2099
- var playbackRate = player.playbackRate;
2100
- if (playbackRate >= 1.5) {
2101
- playbackRate = 2;
2102
- } else if (playbackRate >= 1.25) {
2103
- playbackRate = 1.5;
2104
- } else if (playbackRate >= 1.0) {
2105
- playbackRate = 1.25;
2106
- } else if (playbackRate >= 0.5) {
2107
- playbackRate = 1.0;
2108
- } else if (playbackRate >= 0.25) {
2109
- playbackRate = 0.5;
2110
- } else if (playbackRate >= 0) {
2111
- playbackRate = 0.25;
2112
- }
2113
- actions.changeRate(playbackRate, {
2114
- action: 'fast-forward',
2115
- source: 'shortcut'
2116
- });
2117
- }
2118
- }, {
2119
- keyCode: 188,
2120
- // Shift + <
2121
- shift: true,
2122
- handle: function handle(player, actions) {
2123
- // Decrease speed
2124
- var playbackRate = player.playbackRate;
2125
- if (playbackRate <= 0.5) {
2126
- playbackRate = 0.25;
2127
- } else if (playbackRate <= 1.0) {
2128
- playbackRate = 0.5;
2129
- } else if (playbackRate <= 1.25) {
2130
- playbackRate = 1.0;
2131
- } else if (playbackRate <= 1.5) {
2132
- playbackRate = 1.25;
2133
- } else if (playbackRate <= 2) {
2134
- playbackRate = 1.5;
2135
- }
2136
- actions.changeRate(playbackRate, {
2137
- action: 'fast-rewind',
2138
- source: 'shortcut'
2139
- });
2140
- }
2141
- }];
2142
- _this.shortcuts = [].concat(_this.defaultShortcuts);
2143
- _this.mergeShortcuts = _this.mergeShortcuts.bind(_assertThisInitialized(_this));
2144
- _this.handleKeyPress = _this.handleKeyPress.bind(_assertThisInitialized(_this));
2145
- _this.handleClick = _this.handleClick.bind(_assertThisInitialized(_this));
2146
- _this.handleDoubleClick = _this.handleDoubleClick.bind(_assertThisInitialized(_this));
2147
- return _this;
2148
- }
2149
- var _proto = Shortcut.prototype;
2150
- _proto.componentDidMount = function componentDidMount() {
2151
- this.mergeShortcuts();
2152
- document.addEventListener('keydown', this.handleKeyPress);
2153
- document.addEventListener('click', this.handleClick);
2154
- document.addEventListener('dblclick', this.handleDoubleClick);
2155
- };
2156
- _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
2157
- if (prevProps.shortcuts !== this.props.shortcuts) {
2158
- this.mergeShortcuts();
2159
- }
2160
- };
2161
- _proto.componentWillUnmount = function componentWillUnmount() {
2162
- document.removeEventListener('keydown', this.handleKeyPress);
2163
- document.removeEventListener('click', this.handleClick);
2164
- document.removeEventListener('dblclick', this.handleDoubleClick);
2165
- }
2166
-
2167
- // merge the shortcuts from props
2168
- ;
2169
- _proto.mergeShortcuts = function mergeShortcuts() {
2170
- var getShortcutKey = function getShortcutKey(_ref) {
2171
- var _ref$keyCode = _ref.keyCode,
2172
- keyCode = _ref$keyCode === void 0 ? 0 : _ref$keyCode,
2173
- _ref$ctrl = _ref.ctrl,
2174
- ctrl = _ref$ctrl === void 0 ? false : _ref$ctrl,
2175
- _ref$shift = _ref.shift,
2176
- shift = _ref$shift === void 0 ? false : _ref$shift,
2177
- _ref$alt = _ref.alt,
2178
- alt = _ref$alt === void 0 ? false : _ref$alt;
2179
- return keyCode + ":" + ctrl + ":" + shift + ":" + alt;
2180
- };
2181
- var defaultShortcuts = this.defaultShortcuts.reduce(function (shortcuts, shortcut) {
2182
- var _extends2;
2183
- return _extends({}, shortcuts, (_extends2 = {}, _extends2[getShortcutKey(shortcut)] = shortcut, _extends2));
2184
- }, {});
2185
- var mergedShortcuts = (this.props.shortcuts || []).reduce(function (shortcuts, shortcut) {
2186
- var keyCode = shortcut.keyCode,
2187
- handle = shortcut.handle;
2188
- if (keyCode && typeof handle === 'function') {
2189
- var _extends3;
2190
- return _extends({}, shortcuts, (_extends3 = {}, _extends3[getShortcutKey(shortcut)] = shortcut, _extends3));
2191
- }
2192
- return shortcuts;
2193
- }, defaultShortcuts);
2194
- var gradeShortcut = function gradeShortcut(shortcut) {
2195
- var score = 0;
2196
- ['ctrl', 'shift', 'alt'].forEach(function (key) {
2197
- if (shortcut[key]) {
2198
- score += 1;
2199
- }
2200
- });
2201
- return score;
2202
- };
2203
- this.shortcuts = Object.values(mergedShortcuts).sort(function (a, b) {
2204
- return gradeShortcut(b) - gradeShortcut(a);
2205
- });
2206
- };
2207
- _proto.togglePlay = function togglePlay(player, actions) {
2208
- if (player.paused) {
2209
- actions.play({
2210
- action: 'play',
2211
- source: 'shortcut'
2212
- });
2213
- } else {
2214
- actions.pause({
2215
- action: 'pause',
2216
- source: 'shortcut'
2217
- });
2218
- }
2219
- };
2220
- _proto.toggleFullscreen = function toggleFullscreen(player, actions) {
2221
- actions.toggleFullscreen(player);
2222
- };
2223
- _proto.handleKeyPress = function handleKeyPress(e) {
2224
- var _this$props = this.props,
2225
- player = _this$props.player,
2226
- actions = _this$props.actions;
2227
- if (!player.isActive) {
2228
- return;
2229
- }
2230
- var activeElement = document.activeElement;
2231
- if (activeElement && activeElement instanceof HTMLElement && (hasClass(activeElement, 'video-react-player-control') || hasClass(activeElement, 'video-react-player-menu-button-active') || hasClass(activeElement, 'video-react-player-big-play-button'))) {
2232
- return;
2233
- }
2234
- var keyCode = e.keyCode || e.which;
2235
- var ctrl = e.ctrlKey || e.metaKey;
2236
- var shift = e.shiftKey;
2237
- var alt = e.altKey;
2238
- var shortcut = this.shortcuts.find(function (s) {
2239
- if (!s.keyCode || s.keyCode - keyCode !== 0) {
2240
- return false;
2241
- }
2242
- if (s.ctrl !== undefined && s.ctrl !== ctrl || s.shift !== undefined && s.shift !== shift || s.alt !== undefined && s.alt !== alt) {
2243
- return false;
2244
- }
2245
- return true;
2246
- });
2247
- if (shortcut) {
2248
- shortcut.handle(player, actions);
2249
- e.preventDefault();
2250
- }
2251
- }
2252
-
2253
- // only if player is active and player is ready
2254
- ;
2255
- _proto.canBeClicked = function canBeClicked(player, e) {
2256
- if (!player.isActive || player.readyState !== 4 || !(e.target instanceof HTMLVideoElement)) {
2257
- return false;
2258
- }
2259
- return true;
2260
- };
2261
- _proto.handleClick = function handleClick(e) {
2262
- var _this$props2 = this.props,
2263
- player = _this$props2.player,
2264
- actions = _this$props2.actions,
2265
- clickable = _this$props2.clickable;
2266
- if (!this.canBeClicked(player, e) || !clickable) {
2267
- return;
2268
- }
2269
- this.togglePlay(player, actions);
2270
- // e.preventDefault();
2271
- };
2272
- _proto.handleDoubleClick = function handleDoubleClick(e) {
2273
- var _this$props3 = this.props,
2274
- player = _this$props3.player,
2275
- actions = _this$props3.actions,
2276
- dblclickable = _this$props3.dblclickable;
2277
- if (!this.canBeClicked(player, e) || !dblclickable) {
2278
- return;
2279
- }
2280
- this.toggleFullscreen(player, actions);
2281
- // e.preventDefault();
2282
- }
2283
-
2284
- // this component dose not render anything
2285
- // it's just for the key down event
2286
- ;
2287
- _proto.render = function render() {
2288
- return null;
2289
- };
2290
- return Shortcut;
2291
- }(React.Component);
2292
- Shortcut.defaultProps = {
2293
- clickable: true,
2294
- dblclickable: true
2295
- };
2296
- Shortcut.displayName = 'Shortcut';
2297
-
2298
- var reactIs_production_min = createCommonjsModule(function (module, exports) {
2299
-
2300
- Object.defineProperty(exports, "__esModule", {
2301
- value: !0
2302
- });
2303
- var b = "function" === typeof Symbol && Symbol.for,
2304
- c = b ? Symbol.for("react.element") : 60103,
2305
- d = b ? Symbol.for("react.portal") : 60106,
2306
- e = b ? Symbol.for("react.fragment") : 60107,
2307
- f = b ? Symbol.for("react.strict_mode") : 60108,
2308
- g = b ? Symbol.for("react.profiler") : 60114,
2309
- h = b ? Symbol.for("react.provider") : 60109,
2310
- k = b ? Symbol.for("react.context") : 60110,
2311
- l = b ? Symbol.for("react.async_mode") : 60111,
2312
- m = b ? Symbol.for("react.concurrent_mode") : 60111,
2313
- n = b ? Symbol.for("react.forward_ref") : 60112,
2314
- p = b ? Symbol.for("react.suspense") : 60113,
2315
- q = b ? Symbol.for("react.memo") : 60115,
2316
- r = b ? Symbol.for("react.lazy") : 60116;
2317
- function t(a) {
2318
- if ("object" === typeof a && null !== a) {
2319
- var u = a.$$typeof;
2320
- switch (u) {
2321
- case c:
2322
- switch (a = a.type, a) {
2323
- case l:
2324
- case m:
2325
- case e:
2326
- case g:
2327
- case f:
2328
- case p:
2329
- return a;
2330
- default:
2331
- switch (a = a && a.$$typeof, a) {
2332
- case k:
2333
- case n:
2334
- case h:
2335
- return a;
2336
- default:
2337
- return u;
2338
- }
2339
- }
2340
- case r:
2341
- case q:
2342
- case d:
2343
- return u;
2344
- }
2345
- }
2346
- }
2347
- function v(a) {
2348
- return t(a) === m;
2349
- }
2350
- exports.typeOf = t;
2351
- exports.AsyncMode = l;
2352
- exports.ConcurrentMode = m;
2353
- exports.ContextConsumer = k;
2354
- exports.ContextProvider = h;
2355
- exports.Element = c;
2356
- exports.ForwardRef = n;
2357
- exports.Fragment = e;
2358
- exports.Lazy = r;
2359
- exports.Memo = q;
2360
- exports.Portal = d;
2361
- exports.Profiler = g;
2362
- exports.StrictMode = f;
2363
- exports.Suspense = p;
2364
- exports.isValidElementType = function (a) {
2365
- return "string" === typeof a || "function" === typeof a || a === e || a === m || a === g || a === f || a === p || "object" === typeof a && null !== a && (a.$$typeof === r || a.$$typeof === q || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n);
2366
- };
2367
- exports.isAsyncMode = function (a) {
2368
- return v(a) || t(a) === l;
2369
- };
2370
- exports.isConcurrentMode = v;
2371
- exports.isContextConsumer = function (a) {
2372
- return t(a) === k;
2373
- };
2374
- exports.isContextProvider = function (a) {
2375
- return t(a) === h;
2376
- };
2377
- exports.isElement = function (a) {
2378
- return "object" === typeof a && null !== a && a.$$typeof === c;
2379
- };
2380
- exports.isForwardRef = function (a) {
2381
- return t(a) === n;
2382
- };
2383
- exports.isFragment = function (a) {
2384
- return t(a) === e;
2385
- };
2386
- exports.isLazy = function (a) {
2387
- return t(a) === r;
2388
- };
2389
- exports.isMemo = function (a) {
2390
- return t(a) === q;
2391
- };
2392
- exports.isPortal = function (a) {
2393
- return t(a) === d;
2394
- };
2395
- exports.isProfiler = function (a) {
2396
- return t(a) === g;
2397
- };
2398
- exports.isStrictMode = function (a) {
2399
- return t(a) === f;
2400
- };
2401
- exports.isSuspense = function (a) {
2402
- return t(a) === p;
2403
- };
2404
- });
2405
- unwrapExports(reactIs_production_min);
2406
- var reactIs_production_min_1 = reactIs_production_min.typeOf;
2407
- var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
2408
- var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
2409
- var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
2410
- var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
2411
- var reactIs_production_min_6 = reactIs_production_min.Element;
2412
- var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
2413
- var reactIs_production_min_8 = reactIs_production_min.Fragment;
2414
- var reactIs_production_min_9 = reactIs_production_min.Lazy;
2415
- var reactIs_production_min_10 = reactIs_production_min.Memo;
2416
- var reactIs_production_min_11 = reactIs_production_min.Portal;
2417
- var reactIs_production_min_12 = reactIs_production_min.Profiler;
2418
- var reactIs_production_min_13 = reactIs_production_min.StrictMode;
2419
- var reactIs_production_min_14 = reactIs_production_min.Suspense;
2420
- var reactIs_production_min_15 = reactIs_production_min.isValidElementType;
2421
- var reactIs_production_min_16 = reactIs_production_min.isAsyncMode;
2422
- var reactIs_production_min_17 = reactIs_production_min.isConcurrentMode;
2423
- var reactIs_production_min_18 = reactIs_production_min.isContextConsumer;
2424
- var reactIs_production_min_19 = reactIs_production_min.isContextProvider;
2425
- var reactIs_production_min_20 = reactIs_production_min.isElement;
2426
- var reactIs_production_min_21 = reactIs_production_min.isForwardRef;
2427
- var reactIs_production_min_22 = reactIs_production_min.isFragment;
2428
- var reactIs_production_min_23 = reactIs_production_min.isLazy;
2429
- var reactIs_production_min_24 = reactIs_production_min.isMemo;
2430
- var reactIs_production_min_25 = reactIs_production_min.isPortal;
2431
- var reactIs_production_min_26 = reactIs_production_min.isProfiler;
2432
- var reactIs_production_min_27 = reactIs_production_min.isStrictMode;
2433
- var reactIs_production_min_28 = reactIs_production_min.isSuspense;
2434
-
2435
- var reactIs_development = createCommonjsModule(function (module, exports) {
2436
- });
2437
- unwrapExports(reactIs_development);
2438
- var reactIs_development_1 = reactIs_development.typeOf;
2439
- var reactIs_development_2 = reactIs_development.AsyncMode;
2440
- var reactIs_development_3 = reactIs_development.ConcurrentMode;
2441
- var reactIs_development_4 = reactIs_development.ContextConsumer;
2442
- var reactIs_development_5 = reactIs_development.ContextProvider;
2443
- var reactIs_development_6 = reactIs_development.Element;
2444
- var reactIs_development_7 = reactIs_development.ForwardRef;
2445
- var reactIs_development_8 = reactIs_development.Fragment;
2446
- var reactIs_development_9 = reactIs_development.Lazy;
2447
- var reactIs_development_10 = reactIs_development.Memo;
2448
- var reactIs_development_11 = reactIs_development.Portal;
2449
- var reactIs_development_12 = reactIs_development.Profiler;
2450
- var reactIs_development_13 = reactIs_development.StrictMode;
2451
- var reactIs_development_14 = reactIs_development.Suspense;
2452
- var reactIs_development_15 = reactIs_development.isValidElementType;
2453
- var reactIs_development_16 = reactIs_development.isAsyncMode;
2454
- var reactIs_development_17 = reactIs_development.isConcurrentMode;
2455
- var reactIs_development_18 = reactIs_development.isContextConsumer;
2456
- var reactIs_development_19 = reactIs_development.isContextProvider;
2457
- var reactIs_development_20 = reactIs_development.isElement;
2458
- var reactIs_development_21 = reactIs_development.isForwardRef;
2459
- var reactIs_development_22 = reactIs_development.isFragment;
2460
- var reactIs_development_23 = reactIs_development.isLazy;
2461
- var reactIs_development_24 = reactIs_development.isMemo;
2462
- var reactIs_development_25 = reactIs_development.isPortal;
2463
- var reactIs_development_26 = reactIs_development.isProfiler;
2464
- var reactIs_development_27 = reactIs_development.isStrictMode;
2465
- var reactIs_development_28 = reactIs_development.isSuspense;
2466
-
2467
- var reactIs = createCommonjsModule(function (module) {
2468
-
2469
- {
2470
- module.exports = reactIs_production_min;
2471
- }
2472
- });
2473
-
2474
- /*
2475
- object-assign
2476
- (c) Sindre Sorhus
2477
- @license MIT
2478
- */
2479
-
2480
- /* eslint-disable no-unused-vars */
2481
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
2482
- var hasOwnProperty = Object.prototype.hasOwnProperty;
2483
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
2484
- function toObject(val) {
2485
- if (val === null || val === undefined) {
2486
- throw new TypeError('Object.assign cannot be called with null or undefined');
2487
- }
2488
- return Object(val);
2489
- }
2490
- function shouldUseNative() {
2491
- try {
2492
- if (!Object.assign) {
2493
- return false;
2494
- }
2495
-
2496
- // Detect buggy property enumeration order in older V8 versions.
2497
-
2498
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
2499
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
2500
- test1[5] = 'de';
2501
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
2502
- return false;
2503
- }
2504
-
2505
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
2506
- var test2 = {};
2507
- for (var i = 0; i < 10; i++) {
2508
- test2['_' + String.fromCharCode(i)] = i;
2509
- }
2510
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
2511
- return test2[n];
2512
- });
2513
- if (order2.join('') !== '0123456789') {
2514
- return false;
2515
- }
2516
-
2517
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
2518
- var test3 = {};
2519
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
2520
- test3[letter] = letter;
2521
- });
2522
- if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
2523
- return false;
2524
- }
2525
- return true;
2526
- } catch (err) {
2527
- // We don't expect any of the above to throw, but better to be safe.
2528
- return false;
2529
- }
2530
- }
2531
- var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
2532
- var from;
2533
- var to = toObject(target);
2534
- var symbols;
2535
- for (var s = 1; s < arguments.length; s++) {
2536
- from = Object(arguments[s]);
2537
- for (var key in from) {
2538
- if (hasOwnProperty.call(from, key)) {
2539
- to[key] = from[key];
2540
- }
2541
- }
2542
- if (getOwnPropertySymbols) {
2543
- symbols = getOwnPropertySymbols(from);
2544
- for (var i = 0; i < symbols.length; i++) {
2545
- if (propIsEnumerable.call(from, symbols[i])) {
2546
- to[symbols[i]] = from[symbols[i]];
2547
- }
2548
- }
2549
- }
2550
- }
2551
- return to;
2552
- };
2553
-
2554
- /**
2555
- * Copyright (c) 2013-present, Facebook, Inc.
2556
- *
2557
- * This source code is licensed under the MIT license found in the
2558
- * LICENSE file in the root directory of this source tree.
2559
- */
2560
-
2561
- var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
2562
- var ReactPropTypesSecret_1 = ReactPropTypesSecret;
2563
-
2564
- var has = Function.call.bind(Object.prototype.hasOwnProperty);
2565
-
2566
- function emptyFunction() {}
2567
- function emptyFunctionWithReset() {}
2568
- emptyFunctionWithReset.resetWarningCache = emptyFunction;
2569
- var factoryWithThrowingShims = function factoryWithThrowingShims() {
2570
- function shim(props, propName, componentName, location, propFullName, secret) {
2571
- if (secret === ReactPropTypesSecret_1) {
2572
- // It is still safe when called from React.
2573
- return;
2574
- }
2575
- var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
2576
- err.name = 'Invariant Violation';
2577
- throw err;
2578
- }
2579
- shim.isRequired = shim;
2580
- function getShim() {
2581
- return shim;
2582
- }
2583
- // Important!
2584
- // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
2585
- var ReactPropTypes = {
2586
- array: shim,
2587
- bool: shim,
2588
- func: shim,
2589
- number: shim,
2590
- object: shim,
2591
- string: shim,
2592
- symbol: shim,
2593
- any: shim,
2594
- arrayOf: getShim,
2595
- element: shim,
2596
- elementType: shim,
2597
- instanceOf: getShim,
2598
- node: shim,
2599
- objectOf: getShim,
2600
- oneOf: getShim,
2601
- oneOfType: getShim,
2602
- shape: getShim,
2603
- exact: getShim,
2604
- checkPropTypes: emptyFunctionWithReset,
2605
- resetWarningCache: emptyFunction
2606
- };
2607
- ReactPropTypes.PropTypes = ReactPropTypes;
2608
- return ReactPropTypes;
2609
- };
2610
-
2611
- var propTypes = createCommonjsModule(function (module) {
2612
- /**
2613
- * Copyright (c) 2013-present, Facebook, Inc.
2614
- *
2615
- * This source code is licensed under the MIT license found in the
2616
- * LICENSE file in the root directory of this source tree.
2617
- */
2618
-
2619
- {
2620
- // By explicitly using `prop-types` you are opting into new production behavior.
2621
- // http://fb.me/prop-types-in-prod
2622
- module.exports = factoryWithThrowingShims();
2623
- }
2624
- });
2625
-
2626
- /**
2627
-
2628
- * Copyright (c) 2016 Video-React contributors
2629
- * Copyright (c) 2025 ZingMe.Vn
2630
- *
2631
- * This source code is licensed under the MIT license found in the
2632
- * LICENSE file in the root directory of this source tree.
2633
- */
2634
- var propTypes$1 = {
2635
- player: propTypes.object,
2636
- className: propTypes.string
2637
- };
2638
- function CurrentTimeDisplay(_ref) {
2639
- var player = _ref.player,
2640
- className = _ref.className;
2641
- var formattedTime = formatTime(player.currentTime, player.duration);
2642
- return React__default.createElement("div", {
2643
- className: classnames('video-react-player-current-time video-react-player-time-control video-react-player-control', className)
2644
- }, React__default.createElement("div", {
2645
- className: "video-react-player-current-time-display",
2646
- "aria-live": "off"
2647
- }, React__default.createElement("span", {
2648
- className: "video-react-player-control-text"
2649
- }, "Current Time "), formattedTime));
2650
- }
2651
- CurrentTimeDisplay.propTypes = propTypes$1;
2652
- CurrentTimeDisplay.displayName = 'CurrentTimeDisplay';
2653
-
2654
- /**
2655
-
2656
- * Copyright (c) 2016 Video-React contributors
2657
- * Copyright (c) 2025 ZingMe.Vn
2658
- *
2659
- * This source code is licensed under the MIT license found in the
2660
- * LICENSE file in the root directory of this source tree.
2661
- */
2662
- function DurationDisplay(_ref) {
2663
- var player = _ref.player,
2664
- className = _ref.className;
2665
- var formattedTime = formatTime(player.duration);
2666
- return React__default.createElement("div", {
2667
- className: classnames(className, 'video-react-player-duration video-react-player-time-control video-react-player-control')
2668
- }, React__default.createElement("div", {
2669
- className: "video-react-player-duration-display",
2670
- "aria-live": "off"
2671
- }, React__default.createElement("span", {
2672
- className: "video-react-player-control-text"
2673
- }, "Duration Time "), formattedTime));
2674
- }
2675
- DurationDisplay.displayName = 'DurationDisplay';
2676
-
2677
- /**
2678
-
2679
- * Copyright (c) 2016 Video-React contributors
2680
- * Copyright (c) 2025 ZingMe.Vn
2681
- *
2682
- * This source code is licensed under the MIT license found in the
2683
- * LICENSE file in the root directory of this source tree.
2684
- */
2685
- function TimeDivider(_ref) {
2686
- var separator = _ref.separator,
2687
- className = _ref.className;
2688
- var separatorText = separator || '/';
2689
- return React__default.createElement("div", {
2690
- className: classnames('video-react-player-time-control video-react-player-time-divider', className),
2691
- dir: "ltr"
2692
- }, React__default.createElement("div", null, React__default.createElement("span", null, separatorText)));
2693
- }
2694
- TimeDivider.displayName = 'TimeDivider';
2695
-
2696
- /**
2697
-
2698
- * Copyright (c) 2016 Video-React contributors
2699
- * Copyright (c) 2025 ZingMe.Vn
2700
- *
2701
- * This source code is licensed under the MIT license found in the
2702
- * LICENSE file in the root directory of this source tree.
2703
- */
2704
- var FullscreenToggle = React.forwardRef(function (_ref, ref) {
2705
- var actions = _ref.actions,
2706
- player = _ref.player,
2707
- className = _ref.className;
2708
- var handleClick = React.useCallback(function () {
2709
- actions.toggleFullscreen(player);
2710
- }, [actions, player]);
2711
- return React__default.createElement("button", {
2712
- className: classnames(className, {
2713
- 'video-react-player-icon-fullscreen-exit': player.isFullscreen,
2714
- 'video-react-player-icon-fullscreen': !player.isFullscreen
2715
- }, 'video-react-player-fullscreen-control video-react-player-control video-react-player-button video-react-player-icon'),
2716
- ref: ref,
2717
- type: "button",
2718
- tabIndex: 0,
2719
- onClick: handleClick
2720
- }, React__default.createElement("span", {
2721
- className: "video-react-player-control-text"
2722
- }, "Non-Fullscreen"));
2723
- });
2724
- FullscreenToggle.displayName = 'FullscreenToggle';
2725
-
2726
- var PlayToggle = React.forwardRef(function (_ref, ref) {
2727
- var _player$paused;
2728
- var actions = _ref.actions,
2729
- player = _ref.player,
2730
- className = _ref.className;
2731
- var paused = (_player$paused = player === null || player === void 0 ? void 0 : player.paused) !== null && _player$paused !== void 0 ? _player$paused : true;
2732
- var handleClick = React.useCallback(function () {
2733
- if (!actions) return;
2734
- if (paused) {
2735
- actions.play();
2736
- } else {
2737
- actions.pause();
2738
- }
2739
- }, [actions, paused]);
2740
- var controlText = paused ? 'Play' : 'Pause';
2741
- return React__default.createElement("button", {
2742
- ref: ref,
2743
- className: classnames(className, {
2744
- 'video-react-player-play-control': true,
2745
- 'video-react-player-control': true,
2746
- 'video-react-player-button': true,
2747
- 'video-react-player-paused': paused,
2748
- 'video-react-player-playing': !paused
2749
- }),
2750
- type: "button",
2751
- tabIndex: 0,
2752
- onClick: handleClick
2753
- }, React__default.createElement("span", {
2754
- className: "video-react-player-control-text"
2755
- }, controlText));
2756
- });
2757
- PlayToggle.displayName = 'PlayToggle';
2758
-
2759
- var Slider = /*#__PURE__*/function (_Component) {
2760
- _inheritsLoose(Slider, _Component);
2761
- function Slider() {
2762
- var _this;
2763
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2764
- args[_key] = arguments[_key];
2765
- }
2766
- _this = _Component.call.apply(_Component, [this].concat(args)) || this;
2767
- _this.slider = null;
2768
- _this.state = {
2769
- active: false
2770
- };
2771
- _this.getProgress = function () {
2772
- var getPercent = _this.props.getPercent;
2773
- if (!getPercent) {
2774
- return 0;
2775
- }
2776
- var progress = getPercent();
2777
- if (typeof progress !== 'number' || progress < 0 || progress === Infinity) {
2778
- progress = 0;
2779
- }
2780
- return progress;
2781
- };
2782
- _this.handleMouseDown = function (event) {
2783
- var _this$props$sliderAct, _this$props;
2784
- var onMouseDown = _this.props.onMouseDown;
2785
- document.addEventListener('mousemove', _this.handleMouseMove, true);
2786
- document.addEventListener('mouseup', _this.handleMouseUp, true);
2787
- document.addEventListener('touchmove', _this.handleMouseMove, true);
2788
- document.addEventListener('touchend', _this.handleMouseUp, true);
2789
- _this.setState({
2790
- active: true
2791
- });
2792
- (_this$props$sliderAct = (_this$props = _this.props).sliderActive) === null || _this$props$sliderAct === void 0 ? void 0 : _this$props$sliderAct.call(_this$props, event);
2793
- _this.handleMouseMove(event);
2794
- if (onMouseDown) {
2795
- onMouseDown(event);
2796
- }
2797
- };
2798
- _this.handleMouseMove = function (event) {
2799
- var onMouseMove = _this.props.onMouseMove;
2800
- if (onMouseMove) {
2801
- onMouseMove(event);
2802
- }
2803
- };
2804
- _this.handleMouseUp = function (event) {
2805
- var _this$props$sliderIna, _this$props2;
2806
- event.preventDefault();
2807
- var onMouseUp = _this.props.onMouseUp;
2808
- document.removeEventListener('mousemove', _this.handleMouseMove, true);
2809
- document.removeEventListener('mouseup', _this.handleMouseUp, true);
2810
- document.removeEventListener('touchmove', _this.handleMouseMove, true);
2811
- document.removeEventListener('touchend', _this.handleMouseUp, true);
2812
- _this.setState({
2813
- active: false
2814
- });
2815
- (_this$props$sliderIna = (_this$props2 = _this.props).sliderInactive) === null || _this$props$sliderIna === void 0 ? void 0 : _this$props$sliderIna.call(_this$props2, event);
2816
- if (onMouseUp) {
2817
- onMouseUp(event);
2818
- }
2819
- };
2820
- _this.handleFocus = function (event) {
2821
- var _this$props$onFocus, _this$props3;
2822
- document.addEventListener('keydown', _this.handleKeyPress, true);
2823
- (_this$props$onFocus = (_this$props3 = _this.props).onFocus) === null || _this$props$onFocus === void 0 ? void 0 : _this$props$onFocus.call(_this$props3, event);
2824
- };
2825
- _this.handleBlur = function (event) {
2826
- document.removeEventListener('keydown', _this.handleKeyPress, true);
2827
- if (event) {
2828
- var _this$props$onBlur, _this$props4;
2829
- (_this$props$onBlur = (_this$props4 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props4, event);
2830
- }
2831
- };
2832
- _this.handleClick = function (event) {
2833
- var _this$props$onClick, _this$props5;
2834
- event.preventDefault();
2835
- (_this$props$onClick = (_this$props5 = _this.props).onClick) === null || _this$props$onClick === void 0 ? void 0 : _this$props$onClick.call(_this$props5, event);
2836
- };
2837
- _this.handleKeyPress = function (event) {
2838
- if (event.which === 37 || event.which === 40) {
2839
- event.preventDefault();
2840
- event.stopPropagation();
2841
- _this.stepBack();
2842
- } else if (event.which === 38 || event.which === 39) {
2843
- event.preventDefault();
2844
- event.stopPropagation();
2845
- _this.stepForward();
2846
- }
2847
- };
2848
- _this.stepForward = function () {
2849
- var _this$props$stepForwa, _this$props6;
2850
- (_this$props$stepForwa = (_this$props6 = _this.props).stepForward) === null || _this$props$stepForwa === void 0 ? void 0 : _this$props$stepForwa.call(_this$props6);
2851
- };
2852
- _this.stepBack = function () {
2853
- var _this$props$stepBack, _this$props7;
2854
- (_this$props$stepBack = (_this$props7 = _this.props).stepBack) === null || _this$props$stepBack === void 0 ? void 0 : _this$props$stepBack.call(_this$props7);
2855
- };
2856
- _this.renderChildren = function () {
2857
- var _this$props$onPercent, _this$props8;
2858
- var progress = _this.getProgress();
2859
- var percentage = (progress * 100).toFixed(2) + "%";
2860
- (_this$props$onPercent = (_this$props8 = _this.props).onPercentageChange) === null || _this$props$onPercent === void 0 ? void 0 : _this$props$onPercent.call(_this$props8, percentage);
2861
- return React__default.Children.map(_this.props.children, function (child) {
2862
- return React__default.isValidElement(child) ? React__default.cloneElement(child, {
2863
- progress: progress,
2864
- percentage: percentage
2865
- }) : child;
2866
- });
2867
- };
2868
- return _this;
2869
- }
2870
- var _proto = Slider.prototype;
2871
- _proto.componentWillUnmount = function componentWillUnmount() {
2872
- document.removeEventListener('mousemove', this.handleMouseMove, true);
2873
- document.removeEventListener('mouseup', this.handleMouseUp, true);
2874
- document.removeEventListener('touchmove', this.handleMouseMove, true);
2875
- document.removeEventListener('touchend', this.handleMouseUp, true);
2876
- document.removeEventListener('keydown', this.handleKeyPress, true);
2877
- };
2878
- _proto.calculateDistance = function calculateDistance(event) {
2879
- var _position$x;
2880
- if (!this.slider) {
2881
- return 0;
2882
- }
2883
- var position = getPointerPosition(this.slider, event);
2884
- if (this.props.vertical) {
2885
- var _position$y;
2886
- return (_position$y = position.y) !== null && _position$y !== void 0 ? _position$y : 0;
2887
- }
2888
- return (_position$x = position.x) !== null && _position$x !== void 0 ? _position$x : 0;
2889
- };
2890
- _proto.render = function render() {
2891
- var _this2 = this;
2892
- var _this$props9 = this.props,
2893
- vertical = _this$props9.vertical,
2894
- label = _this$props9.label,
2895
- valuenow = _this$props9.valuenow,
2896
- valuetext = _this$props9.valuetext;
2897
- var ariaValueNow = typeof valuenow === 'number' ? valuenow : Number(valuenow !== null && valuenow !== void 0 ? valuenow : 0);
2898
- return React__default.createElement("div", {
2899
- className: classnames(this.props.className, {
2900
- 'video-react-player-slider-vertical': vertical,
2901
- 'video-react-player-slider-horizontal': !vertical,
2902
- 'video-react-player-sliding': this.state.active
2903
- }, 'video-react-player-slider'),
2904
- ref: function ref(node) {
2905
- _this2.slider = node;
2906
- },
2907
- tabIndex: 0,
2908
- role: "slider",
2909
- onMouseDown: this.handleMouseDown,
2910
- onTouchStart: this.handleMouseDown,
2911
- onFocus: this.handleFocus,
2912
- onBlur: this.handleBlur,
2913
- onClick: this.handleClick,
2914
- "aria-label": label || '',
2915
- "aria-valuenow": ariaValueNow,
2916
- "aria-valuetext": valuetext || '',
2917
- "aria-valuemin": 0,
2918
- "aria-valuemax": 100
2919
- }, this.renderChildren());
2920
- };
2921
- return Slider;
2922
- }(React.Component);
2923
- Slider.displayName = 'Slider';
2924
-
2925
- /**
2926
-
2927
- * Copyright (c) 2016 Video-React contributors
2928
- * Copyright (c) 2025 ZingMe.Vn
2929
- *
2930
- * This source code is licensed under the MIT license found in the
2931
- * LICENSE file in the root directory of this source tree.
2932
- */
2933
- // Shows play progress
2934
- function PlayProgressBar(_ref) {
2935
- var currentTime = _ref.currentTime,
2936
- duration = _ref.duration,
2937
- percentage = _ref.percentage,
2938
- className = _ref.className;
2939
- return React__default.createElement("div", {
2940
- "data-current-time": formatTime(currentTime, duration),
2941
- className: classnames('video-react-player-play-progress video-react-player-slider-bar', className),
2942
- style: {
2943
- width: percentage
2944
- }
2945
- }, React__default.createElement("span", {
2946
- className: "video-react-player-control-text"
2947
- }, "Progress: " + percentage));
2948
- }
2949
- PlayProgressBar.displayName = 'PlayProgressBar';
2950
-
2951
- /**
2952
-
2953
- * Copyright (c) 2016 Video-React contributors
2954
- * Copyright (c) 2025 ZingMe.Vn
2955
- *
2956
- * This source code is licensed under the MIT license found in the
2957
- * LICENSE file in the root directory of this source tree.
2958
- */
2959
- var percentify = function percentify(time, end) {
2960
- var percent = time / end || 0;
2961
- return (percent >= 1 ? 1 : percent) * 100 + "%";
2962
- };
2963
- var LoadProgressBar = function LoadProgressBar(_ref) {
2964
- var buffered = _ref.buffered,
2965
- duration = _ref.duration,
2966
- className = _ref.className;
2967
- if (!buffered || buffered.length === 0) {
2968
- return null;
2969
- }
2970
- var bufferedEnd = buffered.end(buffered.length - 1);
2971
- if (bufferedEnd > duration) {
2972
- bufferedEnd = duration;
2973
- }
2974
- var style = {
2975
- width: percentify(bufferedEnd, duration)
2976
- };
2977
- var parts = [];
2978
- for (var i = 0; i < buffered.length; i += 1) {
2979
- var start = buffered.start(i);
2980
- var end = buffered.end(i);
2981
- parts.push(React__default.createElement("div", {
2982
- style: {
2983
- left: percentify(start, bufferedEnd),
2984
- width: percentify(end - start, bufferedEnd)
2985
- },
2986
- key: "part-" + i
2987
- }));
2988
- }
2989
- return React__default.createElement("div", {
2990
- style: style,
2991
- className: classnames('video-react-player-load-progress', className)
2992
- }, React__default.createElement("span", {
2993
- className: "video-react-player-control-text"
2994
- }, "Loaded: 0%"), parts);
2995
- };
2996
- LoadProgressBar.displayName = 'LoadProgressBar';
2997
-
2998
- /**
2999
-
3000
- * Copyright (c) 2016 Video-React contributors
3001
- * Copyright (c) 2025 ZingMe.Vn
3002
- *
3003
- * This source code is licensed under the MIT license found in the
3004
- * LICENSE file in the root directory of this source tree.
3005
- */
3006
- var MouseTimeDisplay = function MouseTimeDisplay(_ref) {
3007
- var duration = _ref.duration,
3008
- mouseTime = _ref.mouseTime,
3009
- className = _ref.className,
3010
- text = _ref.text;
3011
- if (!mouseTime.time) {
3012
- return null;
3013
- }
3014
- var time = text || formatTime(mouseTime.time, duration);
3015
- return React__default.createElement("div", {
3016
- className: classnames('video-react-player-mouse-display', className),
3017
- style: {
3018
- left: mouseTime.position + "px"
3019
- },
3020
- "data-current-time": time
3021
- });
3022
- };
3023
- MouseTimeDisplay.displayName = 'MouseTimeDisplay';
3024
-
3025
- /**
3026
-
3027
- * Copyright (c) 2016 Video-React contributors
3028
- * Copyright (c) 2025 ZingMe.Vn
3029
- *
3030
- * This source code is licensed under the MIT license found in the
3031
- * LICENSE file in the root directory of this source tree.
3032
- */
3033
- var SeekBar = function SeekBar(_ref) {
3034
- var player = _ref.player,
3035
- actions = _ref.actions,
3036
- mouseTime = _ref.mouseTime,
3037
- className = _ref.className;
3038
- var sliderRef = React.useRef(null);
3039
- var getPercent = React.useCallback(function () {
3040
- var currentTime = player.currentTime,
3041
- seekingTime = player.seekingTime,
3042
- duration = player.duration;
3043
- var time = seekingTime || currentTime;
3044
- if (!duration) {
3045
- return 0;
3046
- }
3047
- var percent = time / duration;
3048
- return percent >= 1 ? 1 : percent;
3049
- }, [player]);
3050
- var getNewTime = React.useCallback(function (event) {
3051
- var duration = player.duration || 0;
3052
- var distance = sliderRef.current ? sliderRef.current.calculateDistance(event) : 0;
3053
- var newTime = distance * duration;
3054
- return newTime === duration ? newTime - 0.1 : newTime;
3055
- }, [player.duration]);
3056
- var handleMouseMove = React.useCallback(function (event) {
3057
- var newTime = getNewTime(event);
3058
- actions.handleSeekingTime(newTime);
3059
- }, [actions, getNewTime]);
3060
- var handleMouseUp = React.useCallback(function (event) {
3061
- var newTime = getNewTime(event);
3062
- actions.seek(newTime);
3063
- actions.handleEndSeeking(newTime);
3064
- }, [actions, getNewTime]);
3065
- var stepForward = React.useCallback(function () {
3066
- actions.forward(5);
3067
- }, [actions]);
3068
- var stepBack = React.useCallback(function () {
3069
- actions.replay(5);
3070
- }, [actions]);
3071
- var time = player.seekingTime || player.currentTime;
3072
- var percent = getPercent();
3073
- var valueText = React.useMemo(function () {
3074
- return formatTime(time, player.duration);
3075
- }, [player.duration, time]);
3076
- return React__default.createElement(Slider, {
3077
- ref: function ref(instance) {
3078
- sliderRef.current = instance;
3079
- },
3080
- label: "video progress bar",
3081
- className: classnames('video-react-player-progress-holder', className),
3082
- valuenow: Number((percent * 100).toFixed(2)),
3083
- valuetext: valueText,
3084
- onMouseMove: handleMouseMove,
3085
- onMouseUp: handleMouseUp,
3086
- getPercent: getPercent,
3087
- stepForward: stepForward,
3088
- stepBack: stepBack
3089
- }, React__default.createElement(LoadProgressBar, {
3090
- buffered: player.buffered,
3091
- currentTime: time,
3092
- duration: player.duration
3093
- }), React__default.createElement(MouseTimeDisplay, {
3094
- duration: player.duration,
3095
- mouseTime: mouseTime
3096
- }), React__default.createElement(PlayProgressBar, {
3097
- percentage: (percent * 100).toFixed(2) + "%",
3098
- currentTime: time,
3099
- duration: player.duration
3100
- }));
3101
- };
3102
- SeekBar.displayName = 'SeekBar';
3103
-
3104
- var ProgressControl = function ProgressControl(_ref) {
3105
- var className = _ref.className,
3106
- playerProps = _objectWithoutPropertiesLoose(_ref, ["className"]);
3107
- var _useState = React.useState({
3108
- time: null,
3109
- position: 0
3110
- }),
3111
- mouseTime = _useState[0],
3112
- setMouseTime = _useState[1];
3113
- var handleMouseMove = React.useCallback(function (event) {
3114
- if (!event.pageX) {
3115
- return;
3116
- }
3117
- var target = event.currentTarget;
3118
- if (!target) {
3119
- return;
3120
- }
3121
- var _Dom$getPointerPositi = getPointerPosition(target, event.nativeEvent),
3122
- _Dom$getPointerPositi2 = _Dom$getPointerPositi.x,
3123
- x = _Dom$getPointerPositi2 === void 0 ? 0 : _Dom$getPointerPositi2;
3124
- var newTime = x * playerProps.player.duration;
3125
- var position = event.pageX - findElPosition(target).left;
3126
- setMouseTime({
3127
- time: newTime,
3128
- position: position
3129
- });
3130
- }, [playerProps.player.duration]);
3131
- return React__default.createElement("div", {
3132
- onMouseMove: handleMouseMove,
3133
- className: classnames('video-react-player-progress-control video-react-player-control', className)
3134
- }, React__default.createElement(SeekBar, _extends({
3135
- mouseTime: mouseTime
3136
- }, playerProps)));
3137
- };
3138
- ProgressControl.displayName = 'ProgressControl';
3139
-
3140
- var ClickableComponent = /*#__PURE__*/function (_Component) {
3141
- _inheritsLoose(ClickableComponent, _Component);
3142
- function ClickableComponent() {
3143
- var _this;
3144
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3145
- args[_key] = arguments[_key];
3146
- }
3147
- _this = _Component.call.apply(_Component, [this].concat(args)) || this;
3148
- _this.handleKeypress = function (event) {
3149
- if (event.which === 32 || event.which === 13) {
3150
- event.preventDefault();
3151
- _this.handleClick(event);
3152
- }
3153
- };
3154
- _this.handleClick = function (event) {
3155
- _this.props.onClick(event);
3156
- };
3157
- _this.handleFocus = function (event) {
3158
- var _this$props$onFocus, _this$props;
3159
- document.addEventListener('keydown', _this.handleKeypress);
3160
- (_this$props$onFocus = (_this$props = _this.props).onFocus) === null || _this$props$onFocus === void 0 ? void 0 : _this$props$onFocus.call(_this$props, event);
3161
- };
3162
- _this.handleBlur = function (event) {
3163
- document.removeEventListener('keydown', _this.handleKeypress);
3164
- if (event) {
3165
- var _this$props$onBlur, _this$props2;
3166
- (_this$props$onBlur = (_this$props2 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props2, event);
3167
- }
3168
- };
3169
- return _this;
3170
- }
3171
- var _proto = ClickableComponent.prototype;
3172
- _proto.componentWillUnmount = function componentWillUnmount() {
3173
- this.handleBlur();
3174
- };
3175
- _proto.render = function render() {
3176
- var _this$props3 = this.props,
3177
- _this$props3$tagName = _this$props3.tagName,
3178
- tagName = _this$props3$tagName === void 0 ? 'div' : _this$props3$tagName,
3179
- className = _this$props3.className,
3180
- children = _this$props3.children,
3181
- onClick = _this$props3.onClick,
3182
- onFocus = _this$props3.onFocus,
3183
- onBlur = _this$props3.onBlur,
3184
- rest = _objectWithoutPropertiesLoose(_this$props3, ["tagName", "className", "children", "onClick", "onFocus", "onBlur"]);
3185
- var Tag = tagName;
3186
- return React__default.createElement(Tag, _extends({}, rest, {
3187
- className: classnames(className),
3188
- role: "button",
3189
- tabIndex: 0,
3190
- onClick: this.handleClick,
3191
- onFocus: this.handleFocus,
3192
- onBlur: this.handleBlur
3193
- }), children);
3194
- };
3195
- return ClickableComponent;
3196
- }(React.Component);
3197
- ClickableComponent.defaultProps = {
3198
- tagName: 'div'
3199
- };
3200
- ClickableComponent.displayName = 'ClickableComponent';
3201
-
3202
- /**
3203
-
3204
- * Copyright (c) 2016 Video-React contributors
3205
- * Copyright (c) 2025 ZingMe.Vn
3206
- *
3207
- * This source code is licensed under the MIT license found in the
3208
- * LICENSE file in the root directory of this source tree.
3209
- */
3210
- var Popup = function Popup(_ref) {
3211
- var children = _ref.children;
3212
- var handleClick = function handleClick(event) {
3213
- event.preventDefault();
3214
- };
3215
- return React__default.createElement("div", {
3216
- className: "video-react-player-menu",
3217
- onClick: handleClick
3218
- }, React__default.createElement("div", {
3219
- className: "video-react-player-menu-content"
3220
- }, children));
3221
- };
3222
- Popup.displayName = 'Popup';
3223
-
3224
- var PopupButton = function PopupButton(_ref) {
3225
- var _ref$inline = _ref.inline,
3226
- inline = _ref$inline === void 0 ? true : _ref$inline,
3227
- className = _ref.className,
3228
- children = _ref.children,
3229
- rest = _objectWithoutPropertiesLoose(_ref, ["inline", "className", "children"]);
3230
- return React__default.createElement(ClickableComponent, _extends({}, rest, {
3231
- className: classnames(className, {
3232
- 'video-react-player-menu-button-inline': !!inline,
3233
- 'video-react-player-menu-button-popup': !inline
3234
- }, 'video-react-player-control video-react-player-button video-react-player-menu-button')
3235
- }), React__default.createElement(Popup, null, children));
3236
- };
3237
- PopupButton.displayName = 'PopupButton';
3238
-
3239
- var VolumeLevel = function VolumeLevel(_ref) {
3240
- var _ref$percentage = _ref.percentage,
3241
- percentage = _ref$percentage === void 0 ? '100%' : _ref$percentage,
3242
- _ref$vertical = _ref.vertical,
3243
- vertical = _ref$vertical === void 0 ? false : _ref$vertical,
3244
- className = _ref.className;
3245
- var style = {};
3246
- if (vertical) {
3247
- style.height = percentage;
3248
- } else {
3249
- style.width = percentage;
3250
- }
3251
- return React__default.createElement("div", {
3252
- className: classnames(className, 'video-react-player-volume-level'),
3253
- style: style
3254
- }, React__default.createElement("span", {
3255
- className: "video-react-player-control-text"
3256
- }));
3257
- };
3258
- VolumeLevel.displayName = 'VolumeLevel';
3259
-
3260
- var VolumeBar = /*#__PURE__*/function (_Component) {
3261
- _inheritsLoose(VolumeBar, _Component);
3262
- function VolumeBar() {
3263
- var _this;
3264
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3265
- args[_key] = arguments[_key];
3266
- }
3267
- _this = _Component.call.apply(_Component, [this].concat(args)) || this;
3268
- _this.slider = null;
3269
- _this.state = {
3270
- percentage: '0%'
3271
- };
3272
- _this.getPercent = function () {
3273
- var player = _this.props.player;
3274
- return player.muted ? 0 : player.volume;
3275
- };
3276
- _this.checkMuted = function () {
3277
- var _this$props = _this.props,
3278
- player = _this$props.player,
3279
- actions = _this$props.actions;
3280
- if (player.muted) {
3281
- actions.mute(false);
3282
- }
3283
- };
3284
- _this.handleMouseMove = function (event) {
3285
- var actions = _this.props.actions;
3286
- _this.checkMuted();
3287
- var distance = _this.slider ? _this.slider.calculateDistance(event) : 0;
3288
- actions.changeVolume(distance);
3289
- };
3290
- _this.stepForward = function () {
3291
- var _this$props2 = _this.props,
3292
- player = _this$props2.player,
3293
- actions = _this$props2.actions;
3294
- _this.checkMuted();
3295
- actions.changeVolume(player.volume + 0.1);
3296
- };
3297
- _this.stepBack = function () {
3298
- var _this$props3 = _this.props,
3299
- player = _this$props3.player,
3300
- actions = _this$props3.actions;
3301
- _this.checkMuted();
3302
- actions.changeVolume(player.volume - 0.1);
3303
- };
3304
- _this.handleFocus = function (event) {
3305
- var _this$props$onFocus, _this$props4;
3306
- (_this$props$onFocus = (_this$props4 = _this.props).onFocus) === null || _this$props$onFocus === void 0 ? void 0 : _this$props$onFocus.call(_this$props4, event);
3307
- };
3308
- _this.handleBlur = function (event) {
3309
- var _this$props$onBlur, _this$props5;
3310
- (_this$props$onBlur = (_this$props5 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props5, event);
3311
- };
3312
- _this.handleSliderActivate = function (event) {
3313
- if (event.type === 'focus') {
3314
- _this.handleFocus(event);
3315
- }
3316
- };
3317
- _this.handleSliderDeactivate = function (event) {
3318
- if (event.type === 'blur') {
3319
- _this.handleBlur(event);
3320
- }
3321
- };
3322
- _this.handlePercentageChange = function (percentage) {
3323
- if (percentage !== _this.state.percentage) {
3324
- _this.setState({
3325
- percentage: percentage
3326
- });
3327
- }
3328
- };
3329
- _this.handleClick = function (event) {
3330
- event.stopPropagation();
3331
- };
3332
- return _this;
3333
- }
3334
- var _proto = VolumeBar.prototype;
3335
- _proto.render = function render() {
3336
- var _this2 = this;
3337
- var _this$props6 = this.props,
3338
- player = _this$props6.player,
3339
- className = _this$props6.className,
3340
- vertical = _this$props6.vertical;
3341
- var volume = Number((player.volume * 100).toFixed(2));
3342
- return React__default.createElement(Slider, {
3343
- order: 1,
3344
- ref: function ref(instance) {
3345
- _this2.slider = instance;
3346
- },
3347
- label: "volume level",
3348
- valuenow: volume,
3349
- valuetext: volume + "%",
3350
- onMouseMove: this.handleMouseMove,
3351
- onFocus: this.handleFocus,
3352
- onBlur: this.handleBlur,
3353
- onClick: this.handleClick,
3354
- sliderActive: this.handleSliderActivate,
3355
- sliderInactive: this.handleSliderDeactivate,
3356
- getPercent: this.getPercent,
3357
- onPercentageChange: this.handlePercentageChange,
3358
- stepForward: this.stepForward,
3359
- stepBack: this.stepBack,
3360
- vertical: vertical,
3361
- className: classnames(className, 'video-react-player-volume-bar', 'video-react-player-slider-bar')
3362
- }, React__default.createElement(VolumeLevel, {
3363
- className: "video-react-player-volume-level"
3364
- }));
3365
- };
3366
- return VolumeBar;
3367
- }(React.Component);
3368
- VolumeBar.displayName = 'VolumeBar';
3369
-
3370
- var VolumeMenuButton = function VolumeMenuButton(_ref) {
3371
- var player = _ref.player,
3372
- actions = _ref.actions,
3373
- _ref$vertical = _ref.vertical,
3374
- vertical = _ref$vertical === void 0 ? false : _ref$vertical,
3375
- className = _ref.className,
3376
- alwaysShowVolume = _ref.alwaysShowVolume,
3377
- buttonProps = _objectWithoutPropertiesLoose(_ref, ["player", "actions", "vertical", "className", "alwaysShowVolume"]);
3378
- var _useState = React.useState(false),
3379
- active = _useState[0],
3380
- setActive = _useState[1];
3381
- var volumeLevel = React.useMemo(function () {
3382
- if (player.muted || player.volume === 0) {
3383
- return 0;
3384
- }
3385
- if (player.volume < 0.33) {
3386
- return 1;
3387
- }
3388
- if (player.volume < 0.67) {
3389
- return 2;
3390
- }
3391
- return 3;
3392
- }, [player.muted, player.volume]);
3393
- var handleClick = React.useCallback(function () {
3394
- actions.mute(!player.muted);
3395
- }, [actions, player.muted]);
3396
- var handleFocus = React.useCallback(function () {
3397
- setActive(true);
3398
- }, []);
3399
- var handleBlur = React.useCallback(function () {
3400
- setActive(false);
3401
- }, []);
3402
- var inline = !vertical;
3403
- return React__default.createElement(PopupButton, _extends({}, buttonProps, {
3404
- className: classnames(className, {
3405
- 'video-react-player-volume-menu-button-vertical': vertical,
3406
- 'video-react-player-volume-menu-button-horizontal': !vertical,
3407
- 'video-react-player-vol-muted': player.muted,
3408
- 'video-react-player-vol-0': volumeLevel === 0 && !player.muted,
3409
- 'video-react-player-vol-1': volumeLevel === 1,
3410
- 'video-react-player-vol-2': volumeLevel === 2,
3411
- 'video-react-player-vol-3': volumeLevel === 3,
3412
- 'video-react-player-slider-active': alwaysShowVolume || active,
3413
- 'video-react-player-lock-showing': alwaysShowVolume || active
3414
- }, 'video-react-player-volume-menu-button'),
3415
- onClick: handleClick,
3416
- inline: inline
3417
- }), React__default.createElement(VolumeBar, {
3418
- onFocus: handleFocus,
3419
- onBlur: handleBlur,
3420
- player: player,
3421
- actions: actions,
3422
- vertical: vertical
3423
- }));
3424
- };
3425
- VolumeMenuButton.displayName = 'VolumeMenuButton';
3426
-
3427
- var asDefaultChild = function asDefaultChild(element) {
3428
- return element;
3429
- };
3430
- var getDefaultChildren = function getDefaultChildren() {
3431
- return [asDefaultChild(React__default.createElement(PlayToggle, {
3432
- key: 'play-toggle',
3433
- order: 1
3434
- })), asDefaultChild(React__default.createElement(VolumeMenuButton, {
3435
- key: 'volume-menu-button',
3436
- order: 4
3437
- })), asDefaultChild(React__default.createElement(CurrentTimeDisplay, {
3438
- key: 'current-time-display',
3439
- order: 5.1
3440
- })), asDefaultChild(React__default.createElement(TimeDivider, {
3441
- key: 'time-divider',
3442
- order: 5.2
3443
- })), asDefaultChild(React__default.createElement(DurationDisplay, {
3444
- key: 'duration-display',
3445
- order: 5.3
3446
- })), asDefaultChild(React__default.createElement(ProgressControl, {
3447
- key: 'progress-control',
3448
- order: 6
3449
- })), asDefaultChild(React__default.createElement(FullscreenToggle, {
3450
- key: 'fullscreen-toggle',
3451
- order: 8
3452
- }))];
3453
- };
3454
- var ControlBar = function ControlBar(_ref) {
3455
- var _ref$autoHide = _ref.autoHide,
3456
- autoHide = _ref$autoHide === void 0 ? true : _ref$autoHide,
3457
- className = _ref.className,
3458
- _ref$disableCompletel = _ref.disableCompletely,
3459
- disableCompletely = _ref$disableCompletel === void 0 ? false : _ref$disableCompletel,
3460
- disableDefaultControls = _ref.disableDefaultControls,
3461
- children = _ref.children,
3462
- parentProps = _objectWithoutPropertiesLoose(_ref, ["autoHide", "className", "disableCompletely", "disableDefaultControls", "children"]);
3463
- if (disableCompletely || !parentProps.actions || !parentProps.player) {
3464
- return null;
3465
- }
3466
- var hasCoreProps = Boolean(parentProps.actions && parentProps.player);
3467
- var defaultChildren = disableDefaultControls || !hasCoreProps ? [] : getDefaultChildren();
3468
- var mergedChildren = mergeAndSortChildren(defaultChildren, children, parentProps);
3469
- return React__default.createElement("div", {
3470
- className: classnames('video-react-player-control-bar', {
3471
- 'video-react-player-control-bar-auto-hide': autoHide
3472
- }, className)
3473
- }, mergedChildren);
3474
- };
3475
- ControlBar.displayName = 'ControlBar';
3476
-
3477
- var USER_AGENT = typeof window !== 'undefined' && window.navigator ? window.navigator.userAgent : '';
3478
- // const webkitVersionMap = (/AppleWebKit\/([\d.]+)/i).exec(USER_AGENT);
3479
- // const appleWebkitVersion = webkitVersionMap ? parseFloat(webkitVersionMap.pop()) : null;
3480
-
3481
- /*
3482
- * Device is an iPhone
3483
- *
3484
- * @type {Boolean}
3485
- * @constant
3486
- * @private
3487
- */
3488
- var IS_IPAD = /iPad/i.test(USER_AGENT);
3489
-
3490
- // The Facebook app's UIWebView identifies as both an iPhone and iPad, so
3491
- // to identify iPhones, we need to exclude iPads.
3492
- // http://artsy.github.io/blog/2012/10/18/the-perils-of-ios-user-agent-sniffing/
3493
- var IS_IPHONE = /iPhone/i.test(USER_AGENT) && !IS_IPAD;
3494
- var IS_IPOD = /iPod/i.test(USER_AGENT);
3495
- var IS_IOS = IS_IPHONE || IS_IPAD || IS_IPOD;
3496
-
3497
- var defaultProps = {
3498
- fluid: true,
3499
- muted: false,
3500
- playsInline: false,
3501
- preload: 'auto',
3502
- aspectRatio: 'auto'
3503
- };
3504
- var Player = React.forwardRef(function (incomingProps, ref) {
3505
- var props = _extends({}, defaultProps, incomingProps);
3506
- var children = props.children,
3507
- width = props.width,
3508
- height = props.height,
3509
- fluid = props.fluid,
3510
- bigPlayButtonPosition = props.bigPlayButtonPosition,
3511
- hideDefaultBigPlayButton = props.hideDefaultBigPlayButton,
3512
- aspectRatio = props.aspectRatio,
3513
- className = props.className,
3514
- store = props.store,
3515
- passThroughProps = _objectWithoutPropertiesLoose(props, ["children", "width", "height", "fluid", "bigPlayButtonPosition", "hideDefaultBigPlayButton", "aspectRatio", "className", "store"]);
3516
- var managerRef = React.useRef();
3517
- if (!managerRef.current) {
3518
- managerRef.current = new Manager(store);
3519
- }
3520
- var manager = managerRef.current;
3521
- var actionsRef = React.useRef(manager.getActions());
3522
- var actions = actionsRef.current;
3523
- var videoComponentRef = React.useRef(null);
3524
- var controlsHideTimerRef = React.useRef(null);
3525
- var _useState = React.useState(manager.getState().player),
3526
- playerState = _useState[0],
3527
- setPlayerState = _useState[1];
3528
- var handleResize = React.useCallback(function () {}, []);
3529
- React.useEffect(function () {
3530
- var unsubscribe = manager.subscribeToPlayerStateChange(function (state, prevState) {
3531
- if (state.isFullscreen !== prevState.isFullscreen) {
3532
- handleResize();
3533
- focusNode(manager.rootElement);
3534
- }
3535
- setPlayerState(state);
3536
- });
3537
- return unsubscribe;
3538
- }, [handleResize, manager]);
3539
- React.useEffect(function () {
3540
- handleResize();
3541
- window.addEventListener('resize', handleResize);
3542
- return function () {
3543
- window.removeEventListener('resize', handleResize);
3544
- };
3545
- }, [handleResize]);
3546
- var handleFullScreenChange = React.useCallback(function (event) {
3547
- if (event.target === manager.rootElement) {
3548
- actions.handleFullscreenChange(Boolean(fullscreen.isFullscreen));
3549
- }
3550
- }, [actions, manager]);
3551
- React.useEffect(function () {
3552
- fullscreen.addEventListener(handleFullScreenChange);
3553
- return function () {
3554
- return fullscreen.removeEventListener(handleFullScreenChange);
3555
- };
3556
- }, [handleFullScreenChange]);
3557
- React.useEffect(function () {
3558
- return function () {
3559
- if (controlsHideTimerRef.current) {
3560
- clearTimeout(controlsHideTimerRef.current);
3561
- }
3562
- };
3563
- }, []);
3564
- var handleVideoRef = React.useCallback(function (instance) {
3565
- videoComponentRef.current = instance;
3566
- manager.video = instance;
3567
- }, [manager]);
3568
- var getDefaultChildren = React.useCallback(function (originalChildren, includeBigPlayButton, bigPlayPos) {
3569
- if (includeBigPlayButton === void 0) {
3570
- includeBigPlayButton = true;
3571
- }
3572
- return [React__default.createElement(Video, {
3573
- ref: handleVideoRef,
3574
- key: "video",
3575
- order: 0,
3576
- actions: actions,
3577
- player: playerState
3578
- }, originalChildren), React__default.createElement(PosterImage, {
3579
- key: "poster-image",
3580
- order: 1,
3581
- actions: actions,
3582
- player: playerState
3583
- }), React__default.createElement(LoadingSpinner, {
3584
- key: "loading-spinner",
3585
- order: 2,
3586
- actions: actions,
3587
- player: playerState
3588
- }), React__default.createElement(Bezel, {
3589
- key: "bezel",
3590
- order: 3,
3591
- manager: manager
3592
- }), includeBigPlayButton && React__default.createElement(BigPlayButton, {
3593
- key: "big-play-button",
3594
- order: 4,
3595
- actions: actions,
3596
- player: playerState,
3597
- position: bigPlayPos
3598
- }), React__default.createElement(ControlBar, {
3599
- key: "control-bar",
3600
- order: 5,
3601
- actions: actions,
3602
- player: playerState
3603
- }), React__default.createElement(Shortcut, {
3604
- key: "shortcut",
3605
- order: 99,
3606
- actions: actions,
3607
- player: playerState,
3608
- manager: manager
3609
- })];
3610
- }, [actions, handleVideoRef, manager, playerState]);
3611
- var containsBigPlayButton = React.useCallback(function (nodes) {
3612
- var found = false;
3613
- React__default.Children.forEach(nodes, function (child) {
3614
- if (found) {
3615
- return;
3616
- }
3617
- if (!React__default.isValidElement(child)) {
3618
- return;
3619
- }
3620
- var t = child.type;
3621
- var name = t.displayName || t.name;
3622
- if (child.type === BigPlayButton || name === 'BigPlayButton' || child.props['data-big-play-button'] === true) {
3623
- found = true;
3624
- return;
3625
- }
3626
- if (child.props && child.props.children) {
3627
- if (containsBigPlayButton(child.props.children)) {
3628
- found = true;
3629
- }
3630
- }
3631
- });
3632
- return found;
3633
- }, []);
3634
- var getChildren = React.useCallback(function (propsForChildren) {
3635
- // Do not forward layout-only props like `fluid` to children to avoid DOM attribute warnings.
3636
- var _ignored = propsForChildren.className,
3637
- originalChildren = propsForChildren.children,
3638
- _fluid = propsForChildren.fluid,
3639
- _bp = propsForChildren.bigPlayButtonPosition,
3640
- _hide = propsForChildren.hideDefaultBigPlayButton,
3641
- rest = _objectWithoutPropertiesLoose(propsForChildren, ["className", "children", "fluid", "bigPlayButtonPosition", "hideDefaultBigPlayButton"]);
3642
- var userChildren = React__default.Children.toArray(children).filter(function (child) {
3643
- return !isVideoChild(child);
3644
- });
3645
- var hasUserBigPlayButton = containsBigPlayButton(children);
3646
- var includeDefaultBigPlay = !hideDefaultBigPlayButton && !hasUserBigPlayButton;
3647
- var defaultChildren = getDefaultChildren(originalChildren, includeDefaultBigPlay, bigPlayButtonPosition);
3648
- var parentProps = _extends({}, rest, {
3649
- actions: actions,
3650
- player: playerState,
3651
- manager: manager
3652
- });
3653
- return mergeAndSortChildren(defaultChildren, userChildren, parentProps);
3654
- }, [actions, bigPlayButtonPosition, children, containsBigPlayButton, getDefaultChildren, hideDefaultBigPlayButton, manager, playerState]);
3655
- var setWidthOrHeight = React.useCallback(function (style, name, value) {
3656
- var styleVal;
3657
- if (typeof value === 'string') {
3658
- if (value === 'auto') {
3659
- styleVal = 'auto';
3660
- } else if (/\d+%/.test(value)) {
3661
- styleVal = value;
3662
- }
3663
- } else if (typeof value === 'number') {
3664
- styleVal = value + "px";
3665
- }
3666
- if (styleVal) {
3667
- style[name] = styleVal;
3668
- }
3669
- }, []);
3670
- var playerStyle = React.useMemo(function () {
3671
- var style = {};
3672
- var resolvedAspectRatio = aspectRatio;
3673
- if (resolvedAspectRatio === undefined || resolvedAspectRatio === 'auto') {
3674
- if (playerState.videoWidth) {
3675
- resolvedAspectRatio = playerState.videoWidth + ":" + playerState.videoHeight;
3676
- } else {
3677
- resolvedAspectRatio = '16:9';
3678
- }
3679
- }
3680
- var _resolvedAspectRatio$ = resolvedAspectRatio.split(':').map(Number),
3681
- ratioWidth = _resolvedAspectRatio$[0],
3682
- ratioHeight = _resolvedAspectRatio$[1];
3683
- var ratioMultiplier = ratioHeight / ratioWidth;
3684
- var resolvedWidth = width;
3685
- if (resolvedWidth === undefined) {
3686
- if (typeof height === 'number') {
3687
- resolvedWidth = height / ratioMultiplier;
3688
- } else if (typeof height === 'string' && height !== 'auto') {
3689
- resolvedWidth = parseFloat(height) / ratioMultiplier;
3690
- } else {
3691
- resolvedWidth = playerState.videoWidth || 400;
3692
- }
3693
- }
3694
- var resolvedHeight = height;
3695
- if (resolvedHeight === undefined) {
3696
- if (typeof resolvedWidth === 'number') {
3697
- resolvedHeight = resolvedWidth * ratioMultiplier;
3698
- } else if (typeof resolvedWidth === 'string' && resolvedWidth !== 'auto') {
3699
- resolvedHeight = parseFloat(resolvedWidth) * ratioMultiplier;
3700
- }
3701
- }
3702
- if (fluid) {
3703
- style.paddingTop = ratioMultiplier * 100 + "%";
3704
- } else {
3705
- if (resolvedWidth !== undefined) {
3706
- setWidthOrHeight(style, 'width', resolvedWidth);
3707
- }
3708
- if (resolvedHeight !== undefined) {
3709
- setWidthOrHeight(style, 'height', resolvedHeight);
3710
- }
3711
- }
3712
- return style;
3713
- }, [aspectRatio, fluid, height, playerState.videoHeight, playerState.videoWidth, setWidthOrHeight, width]);
3714
- var startControlsTimer = React.useCallback(function () {
3715
- var controlBarActiveTime = 3000;
3716
- React__default.Children.forEach(children, function (element) {
3717
- if (!React__default.isValidElement(element) || element.type !== ControlBar) {
3718
- return;
3719
- }
3720
- var _ref = element.props,
3721
- autoHideTime = _ref.autoHideTime;
3722
- if (typeof autoHideTime === 'number') {
3723
- controlBarActiveTime = autoHideTime;
3724
- }
3725
- });
3726
- actions.userActivate(true);
3727
- if (controlsHideTimerRef.current) {
3728
- clearTimeout(controlsHideTimerRef.current);
3729
- }
3730
- controlsHideTimerRef.current = window.setTimeout(function () {
3731
- actions.userActivate(false);
3732
- }, controlBarActiveTime);
3733
- }, [actions, children]);
3734
- var throttledMouseMove = React.useMemo(function () {
3735
- return throttle(function () {
3736
- startControlsTimer();
3737
- }, 250);
3738
- }, [startControlsTimer]);
3739
- var handleMouseDown = React.useCallback(function () {
3740
- startControlsTimer();
3741
- }, [startControlsTimer]);
3742
- var handleMouseMove = React.useCallback(function () {
3743
- throttledMouseMove();
3744
- }, [throttledMouseMove]);
3745
- var handleKeyDown = React.useCallback(function () {
3746
- startControlsTimer();
3747
- }, [startControlsTimer]);
3748
- var handleFocus = React.useCallback(function () {
3749
- actions.activate(true);
3750
- }, [actions]);
3751
- var handleBlur = React.useCallback(function () {
3752
- actions.activate(false);
3753
- }, [actions]);
3754
- var rootRef = React.useCallback(function (node) {
3755
- manager.rootElement = node;
3756
- }, [manager]);
3757
- var childProps = React.useMemo(function () {
3758
- var _videoComponentRef$cu, _videoComponentRef$cu2;
3759
- return _extends({}, passThroughProps, {
3760
- fluid: fluid,
3761
- bigPlayButtonPosition: bigPlayButtonPosition,
3762
- hideDefaultBigPlayButton: hideDefaultBigPlayButton,
3763
- player: playerState,
3764
- actions: actions,
3765
- manager: manager,
3766
- store: manager.store,
3767
- video: (_videoComponentRef$cu = (_videoComponentRef$cu2 = videoComponentRef.current) === null || _videoComponentRef$cu2 === void 0 ? void 0 : _videoComponentRef$cu2.video) !== null && _videoComponentRef$cu !== void 0 ? _videoComponentRef$cu : null
3768
- });
3769
- }, [actions, bigPlayButtonPosition, fluid, hideDefaultBigPlayButton, manager, passThroughProps, playerState]);
3770
- var childElements = React.useMemo(function () {
3771
- return getChildren(childProps);
3772
- }, [childProps, getChildren]);
3773
- React.useImperativeHandle(ref, function () {
3774
- return {
3775
- manager: manager,
3776
- actions: actions,
3777
- video: videoComponentRef.current,
3778
- getState: function getState() {
3779
- return manager.getState();
3780
- },
3781
- get playbackRate() {
3782
- var _videoComponentRef$cu3, _videoComponentRef$cu4;
3783
- return (_videoComponentRef$cu3 = (_videoComponentRef$cu4 = videoComponentRef.current) === null || _videoComponentRef$cu4 === void 0 ? void 0 : _videoComponentRef$cu4.playbackRate) !== null && _videoComponentRef$cu3 !== void 0 ? _videoComponentRef$cu3 : 1;
3784
- },
3785
- set playbackRate(rate) {
3786
- if (videoComponentRef.current) {
3787
- videoComponentRef.current.playbackRate = rate;
3788
- }
3789
- },
3790
- get muted() {
3791
- var _videoComponentRef$cu5, _videoComponentRef$cu6;
3792
- return (_videoComponentRef$cu5 = (_videoComponentRef$cu6 = videoComponentRef.current) === null || _videoComponentRef$cu6 === void 0 ? void 0 : _videoComponentRef$cu6.muted) !== null && _videoComponentRef$cu5 !== void 0 ? _videoComponentRef$cu5 : false;
3793
- },
3794
- set muted(value) {
3795
- if (videoComponentRef.current) {
3796
- videoComponentRef.current.muted = value;
3797
- }
3798
- },
3799
- get volume() {
3800
- var _videoComponentRef$cu7, _videoComponentRef$cu8;
3801
- return (_videoComponentRef$cu7 = (_videoComponentRef$cu8 = videoComponentRef.current) === null || _videoComponentRef$cu8 === void 0 ? void 0 : _videoComponentRef$cu8.volume) !== null && _videoComponentRef$cu7 !== void 0 ? _videoComponentRef$cu7 : 1;
3802
- },
3803
- set volume(value) {
3804
- if (videoComponentRef.current) {
3805
- videoComponentRef.current.volume = value;
3806
- }
3807
- },
3808
- get videoWidth() {
3809
- var _videoComponentRef$cu9, _videoComponentRef$cu0;
3810
- return (_videoComponentRef$cu9 = (_videoComponentRef$cu0 = videoComponentRef.current) === null || _videoComponentRef$cu0 === void 0 ? void 0 : _videoComponentRef$cu0.videoWidth) !== null && _videoComponentRef$cu9 !== void 0 ? _videoComponentRef$cu9 : 0;
3811
- },
3812
- get videoHeight() {
3813
- var _videoComponentRef$cu1, _videoComponentRef$cu10;
3814
- return (_videoComponentRef$cu1 = (_videoComponentRef$cu10 = videoComponentRef.current) === null || _videoComponentRef$cu10 === void 0 ? void 0 : _videoComponentRef$cu10.videoHeight) !== null && _videoComponentRef$cu1 !== void 0 ? _videoComponentRef$cu1 : 0;
3815
- },
3816
- play: function play() {
3817
- var _videoComponentRef$cu11;
3818
- (_videoComponentRef$cu11 = videoComponentRef.current) === null || _videoComponentRef$cu11 === void 0 ? void 0 : _videoComponentRef$cu11.play();
3819
- },
3820
- pause: function pause() {
3821
- var _videoComponentRef$cu12;
3822
- (_videoComponentRef$cu12 = videoComponentRef.current) === null || _videoComponentRef$cu12 === void 0 ? void 0 : _videoComponentRef$cu12.pause();
3823
- },
3824
- load: function load() {
3825
- var _videoComponentRef$cu13;
3826
- (_videoComponentRef$cu13 = videoComponentRef.current) === null || _videoComponentRef$cu13 === void 0 ? void 0 : _videoComponentRef$cu13.load();
3827
- },
3828
- addTextTrack: function addTextTrack() {
3829
- var _videoComponentRef$cu14, _videoComponentRef$cu15;
3830
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3831
- args[_key] = arguments[_key];
3832
- }
3833
- return (_videoComponentRef$cu14 = (_videoComponentRef$cu15 = videoComponentRef.current) === null || _videoComponentRef$cu15 === void 0 ? void 0 : _videoComponentRef$cu15.addTextTrack.apply(_videoComponentRef$cu15, args)) !== null && _videoComponentRef$cu14 !== void 0 ? _videoComponentRef$cu14 : {};
3834
- },
3835
- canPlayType: function canPlayType() {
3836
- var _videoComponentRef$cu16, _videoComponentRef$cu17;
3837
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3838
- args[_key2] = arguments[_key2];
3839
- }
3840
- return (_videoComponentRef$cu16 = (_videoComponentRef$cu17 = videoComponentRef.current) === null || _videoComponentRef$cu17 === void 0 ? void 0 : _videoComponentRef$cu17.canPlayType.apply(_videoComponentRef$cu17, args)) !== null && _videoComponentRef$cu16 !== void 0 ? _videoComponentRef$cu16 : '';
3841
- },
3842
- seek: function seek(time) {
3843
- var _videoComponentRef$cu18;
3844
- (_videoComponentRef$cu18 = videoComponentRef.current) === null || _videoComponentRef$cu18 === void 0 ? void 0 : _videoComponentRef$cu18.seek(time);
3845
- },
3846
- forward: function forward(seconds) {
3847
- var _videoComponentRef$cu19;
3848
- (_videoComponentRef$cu19 = videoComponentRef.current) === null || _videoComponentRef$cu19 === void 0 ? void 0 : _videoComponentRef$cu19.forward(seconds);
3849
- },
3850
- replay: function replay(seconds) {
3851
- var _videoComponentRef$cu20;
3852
- (_videoComponentRef$cu20 = videoComponentRef.current) === null || _videoComponentRef$cu20 === void 0 ? void 0 : _videoComponentRef$cu20.replay(seconds);
3853
- },
3854
- toggleFullscreen: function toggleFullscreen() {
3855
- var _videoComponentRef$cu21;
3856
- (_videoComponentRef$cu21 = videoComponentRef.current) === null || _videoComponentRef$cu21 === void 0 ? void 0 : _videoComponentRef$cu21.toggleFullscreen();
3857
- },
3858
- subscribeToStateChange: function subscribeToStateChange(listener) {
3859
- return manager.subscribeToPlayerStateChange(listener);
3860
- }
3861
- };
3862
- }, [actions, manager]);
3863
- var paused = playerState.paused,
3864
- hasStarted = playerState.hasStarted,
3865
- waiting = playerState.waiting,
3866
- seeking = playerState.seeking,
3867
- isFullscreen = playerState.isFullscreen,
3868
- userActivity = playerState.userActivity;
3869
- return React__default.createElement("div", {
3870
- className: classnames({
3871
- 'video-react-player-controls-enabled': true,
3872
- 'video-react-player-has-started': hasStarted,
3873
- 'video-react-player-paused': paused,
3874
- 'video-react-player-playing': !paused,
3875
- 'video-react-player-waiting': waiting,
3876
- 'video-react-player-seeking': seeking,
3877
- 'video-react-player-fluid': fluid,
3878
- 'video-react-player-fullscreen': isFullscreen,
3879
- 'video-react-player-user-inactive': !userActivity,
3880
- 'video-react-player-user-active': userActivity,
3881
- 'video-react-player-workinghover': !IS_IOS
3882
- }, 'video-react-player', className),
3883
- style: playerStyle,
3884
- ref: rootRef,
3885
- role: "region",
3886
- onTouchStart: handleMouseDown,
3887
- onMouseDown: handleMouseDown,
3888
- onTouchMove: handleMouseMove,
3889
- onMouseMove: handleMouseMove,
3890
- onKeyDown: handleKeyDown,
3891
- onFocus: handleFocus,
3892
- onBlur: handleBlur,
3893
- tabIndex: -1
3894
- }, childElements);
3895
- });
3896
- Player.displayName = 'Player';
3897
-
3898
- /**
3899
-
3900
- * Copyright (c) 2016 Video-React contributors
3901
- * Copyright (c) 2025 ZingMe.Vn
3902
- *
3903
- * This source code is licensed under the MIT license found in the
3904
- * LICENSE file in the root directory of this source tree.
3905
- */
3906
- var createForwardReplayControl = function createForwardReplayControl(mode) {
3907
- var ForwardReplayControl = React.forwardRef(function (_ref, ref) {
3908
- var actions = _ref.actions,
3909
- _ref$seconds = _ref.seconds,
3910
- seconds = _ref$seconds === void 0 ? 10 : _ref$seconds,
3911
- className = _ref.className;
3912
- var handleClick = React.useCallback(function () {
3913
- if (mode === 'forward') {
3914
- actions.forward(seconds);
3915
- } else {
3916
- actions.replay(seconds);
3917
- }
3918
- }, [actions, seconds]);
3919
- var classNames = ['video-react-player-control', 'video-react-player-button', 'video-react-player-icon', "video-react-player-icon-" + mode + "-" + seconds, "video-react-player-" + mode + "-control"];
3920
- if (className) {
3921
- classNames.push(className);
3922
- }
3923
- return React__default.createElement("button", {
3924
- ref: ref,
3925
- className: classNames.join(' '),
3926
- type: "button",
3927
- onClick: handleClick
3928
- }, React__default.createElement("span", {
3929
- className: "video-react-player-control-text"
3930
- }, mode + " " + seconds + " seconds"));
3931
- });
3932
- ForwardReplayControl.displayName = "ForwardReplayControl(" + mode + ")";
3933
- return ForwardReplayControl;
3934
- };
3935
-
3936
- /**
3937
-
3938
- * Copyright (c) 2016 Video-React contributors
3939
- * Copyright (c) 2025 ZingMe.Vn
3940
- *
3941
- * This source code is licensed under the MIT license found in the
3942
- * LICENSE file in the root directory of this source tree.
3943
- */
3944
-
3945
- // Pass mode into parent function
3946
- var ForwardControl = createForwardReplayControl('forward');
3947
- ForwardControl.displayName = 'ForwardControl';
3948
-
3949
- /**
3950
-
3951
- * Copyright (c) 2016 Video-React contributors
3952
- * Copyright (c) 2025 ZingMe.Vn
3953
- *
3954
- * This source code is licensed under the MIT license found in the
3955
- * LICENSE file in the root directory of this source tree.
3956
- */
3957
-
3958
- // Pass mode into parent function
3959
- var ReplayControl = createForwardReplayControl('replay');
3960
- ReplayControl.displayName = 'ReplayControl';
3961
-
3962
- /**
3963
-
3964
- * Copyright (c) 2016 Video-React contributors
3965
- * Copyright (c) 2025 ZingMe.Vn
3966
- *
3967
- * This source code is licensed under the MIT license found in the
3968
- * LICENSE file in the root directory of this source tree.
3969
- */
3970
- var Menu = function Menu(_ref) {
3971
- var children = _ref.children;
3972
- var handleClick = function handleClick(event) {
3973
- event.preventDefault();
3974
- };
3975
- return React__default.createElement("div", {
3976
- className: "video-react-player-menu video-react-player-lock-showing",
3977
- role: "presentation",
3978
- onClick: handleClick
3979
- }, React__default.createElement("ul", {
3980
- className: "video-react-player-menu-content"
3981
- }, children));
3982
- };
3983
- Menu.displayName = 'Menu';
3984
-
3985
- /**
3986
-
3987
- * Copyright (c) 2016 Video-React contributors
3988
- * Copyright (c) 2025 ZingMe.Vn
3989
- *
3990
- * This source code is licensed under the MIT license found in the
3991
- * LICENSE file in the root directory of this source tree.
3992
- */
3993
- var MenuItem = function MenuItem(_ref) {
3994
- var item = _ref.item,
3995
- index = _ref.index,
3996
- activateIndex = _ref.activateIndex,
3997
- onSelectItem = _ref.onSelectItem;
3998
- var handleClick = function handleClick() {
3999
- onSelectItem(index);
4000
- };
4001
- return React__default.createElement("li", {
4002
- className: classnames({
4003
- 'video-react-player-menu-item': true,
4004
- 'video-react-player-selected': index === activateIndex
4005
- }),
4006
- role: "menuitem",
4007
- onClick: handleClick
4008
- }, item.label, React__default.createElement("span", {
4009
- className: "video-react-player-control-text"
4010
- }));
4011
- };
4012
- MenuItem.displayName = 'MenuItem';
4013
-
4014
- var MenuButton = /*#__PURE__*/function (_Component) {
4015
- _inheritsLoose(MenuButton, _Component);
4016
- function MenuButton() {
4017
- var _this$props$selectedI;
4018
- var _this;
4019
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4020
- args[_key] = arguments[_key];
4021
- }
4022
- _this = _Component.call.apply(_Component, [this].concat(args)) || this;
4023
- _this.state = {
4024
- active: false,
4025
- activateIndex: (_this$props$selectedI = _this.props.selectedIndex) !== null && _this$props$selectedI !== void 0 ? _this$props$selectedI : 0
4026
- };
4027
- _this.commitSelection = function (index) {
4028
- _this.setState({
4029
- activateIndex: index
4030
- });
4031
- _this.handleIndexChange(index);
4032
- };
4033
- _this.activateMenuItem = function (index) {
4034
- if (index === void 0) {
4035
- index = 0;
4036
- }
4037
- _this.setState({
4038
- activateIndex: index
4039
- });
4040
- _this.handleIndexChange(index);
4041
- };
4042
- _this.handleIndexChange = function (index) {
4043
- _this.props.onSelectItem(index);
4044
- };
4045
- _this.handleClick = function () {
4046
- _this.setState(function (prevState) {
4047
- return {
4048
- active: !prevState.active
4049
- };
4050
- });
4051
- };
4052
- _this.handleFocus = function () {
4053
- document.addEventListener('keydown', _this.handleKeyPress);
4054
- };
4055
- _this.handleBlur = function () {
4056
- _this.setState({
4057
- active: false
4058
- });
4059
- document.removeEventListener('keydown', _this.handleKeyPress);
4060
- };
4061
- _this.handleUpArrow = function (event) {
4062
- var _this$props$items;
4063
- var items = (_this$props$items = _this.props.items) !== null && _this$props$items !== void 0 ? _this$props$items : [];
4064
- if (_this.state.active && items.length) {
4065
- event.preventDefault();
4066
- var newIndex = (_this.state.activateIndex - 1 + items.length) % items.length;
4067
- _this.activateMenuItem(newIndex);
4068
- }
4069
- };
4070
- _this.handleDownArrow = function (event) {
4071
- var _this$props$items2;
4072
- var items = (_this$props$items2 = _this.props.items) !== null && _this$props$items2 !== void 0 ? _this$props$items2 : [];
4073
- if (_this.state.active && items.length) {
4074
- event.preventDefault();
4075
- var newIndex = (_this.state.activateIndex + 1) % items.length;
4076
- _this.activateMenuItem(newIndex);
4077
- }
4078
- };
4079
- _this.handleTab = function (event) {
4080
- if (_this.state.active) {
4081
- event.preventDefault();
4082
- _this.commitSelection(_this.state.activateIndex);
4083
- }
4084
- };
4085
- _this.handleReturn = function (event) {
4086
- event.preventDefault();
4087
- if (_this.state.active) {
4088
- _this.commitSelection(_this.state.activateIndex);
4089
- } else {
4090
- _this.setState({
4091
- active: true
4092
- });
4093
- }
4094
- };
4095
- _this.handleEscape = function () {
4096
- _this.setState({
4097
- active: false,
4098
- activateIndex: 0
4099
- });
4100
- };
4101
- _this.handleKeyPress = function (event) {
4102
- if (event.which === 27) {
4103
- _this.handleEscape();
4104
- } else if (event.which === 9) {
4105
- _this.handleTab(event);
4106
- } else if (event.which === 13) {
4107
- _this.handleReturn(event);
4108
- } else if (event.which === 38) {
4109
- _this.handleUpArrow(event);
4110
- } else if (event.which === 40) {
4111
- _this.handleDownArrow(event);
4112
- }
4113
- };
4114
- _this.handleSelectItem = function (index) {
4115
- _this.commitSelection(index);
4116
- };
4117
- return _this;
4118
- }
4119
- var _proto = MenuButton.prototype;
4120
- _proto.componentWillUnmount = function componentWillUnmount() {
4121
- document.removeEventListener('keydown', this.handleKeyPress);
4122
- };
4123
- _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
4124
- if (prevProps.selectedIndex !== this.props.selectedIndex && typeof this.props.selectedIndex === 'number') {
4125
- this.activateMenuItem(this.props.selectedIndex);
4126
- }
4127
- };
4128
- _proto.renderMenu = function renderMenu() {
4129
- var _this$props$items3,
4130
- _this2 = this;
4131
- if (!this.state.active) {
4132
- return null;
4133
- }
4134
- var items = (_this$props$items3 = this.props.items) !== null && _this$props$items3 !== void 0 ? _this$props$items3 : [];
4135
- return React__default.createElement(Menu, null, items.map(function (item, index) {
4136
- return React__default.createElement(MenuItem, {
4137
- item: item,
4138
- index: index,
4139
- onSelectItem: _this2.handleSelectItem,
4140
- activateIndex: _this2.state.activateIndex,
4141
- key: "item-" + index
4142
- });
4143
- }));
4144
- };
4145
- _proto.render = function render() {
4146
- var _this$props = this.props,
4147
- inline = _this$props.inline,
4148
- className = _this$props.className,
4149
- children = _this$props.children;
4150
- return React__default.createElement(ClickableComponent, {
4151
- className: classnames(className, {
4152
- 'video-react-player-menu-button-inline': !!inline,
4153
- 'video-react-player-menu-button-popup': !inline,
4154
- 'video-react-player-menu-button-active': this.state.active
4155
- }, 'video-react-player-control video-react-player-button video-react-player-menu-button'),
4156
- onClick: this.handleClick,
4157
- onFocus: this.handleFocus,
4158
- onBlur: this.handleBlur
4159
- }, children, this.renderMenu());
4160
- };
4161
- return MenuButton;
4162
- }(React.Component);
4163
- MenuButton.displayName = 'MenuButton';
4164
- MenuButton.defaultProps = {
4165
- items: [],
4166
- selectedIndex: 0
4167
- };
4168
-
4169
- /**
4170
-
4171
- * Copyright (c) 2016 Video-React contributors
4172
- * Copyright (c) 2025 ZingMe.Vn
4173
- *
4174
- * This source code is licensed under the MIT license found in the
4175
- * LICENSE file in the root directory of this source tree.
4176
- */
4177
- var DEFAULT_RATES = [2, 1.5, 1.25, 1, 0.5, 0.25];
4178
- var PlaybackRateMenuButton = function PlaybackRateMenuButton(_ref) {
4179
- var actions = _ref.actions,
4180
- player = _ref.player,
4181
- _ref$rates = _ref.rates,
4182
- rates = _ref$rates === void 0 ? DEFAULT_RATES : _ref$rates,
4183
- className = _ref.className;
4184
- var items = React.useMemo(function () {
4185
- return rates.map(function (rate) {
4186
- return {
4187
- label: rate + "x",
4188
- value: rate
4189
- };
4190
- });
4191
- }, [rates]);
4192
- var selectedIndex = React.useMemo(function () {
4193
- var index = rates.indexOf(player.playbackRate);
4194
- if (index >= 0) {
4195
- return index;
4196
- }
4197
- var fallback = rates.indexOf(1);
4198
- return fallback >= 0 ? fallback : 0;
4199
- }, [player.playbackRate, rates]);
4200
- var handleSelectItem = React.useCallback(function (index) {
4201
- if (index >= 0 && index < rates.length) {
4202
- actions.changeRate(rates[index]);
4203
- }
4204
- }, [actions, rates]);
4205
- return React__default.createElement(MenuButton, {
4206
- className: classnames('video-react-player-playback-rate', className),
4207
- onSelectItem: handleSelectItem,
4208
- items: items,
4209
- selectedIndex: selectedIndex
4210
- }, React__default.createElement("span", {
4211
- className: "video-react-player-control-text"
4212
- }, "Playback Rate"), React__default.createElement("div", {
4213
- className: "video-react-player-playback-rate-value"
4214
- }, player.playbackRate.toFixed(2) + "x"));
4215
- };
4216
- PlaybackRateMenuButton.displayName = 'PlaybackRateMenuButton';
4217
-
4218
- /**
4219
-
4220
- * Copyright (c) 2016 Video-React contributors
4221
- * Copyright (c) 2025 ZingMe.Vn
4222
- *
4223
- * This source code is licensed under the MIT license found in the
4224
- * LICENSE file in the root directory of this source tree.
4225
- */
4226
- var PlaybackRate = function PlaybackRate(props) {
4227
- React.useEffect(function () {
4228
- deprecatedWarning('PlaybackRate', 'PlaybackRateMenuButton');
4229
- }, []);
4230
- return React__default.createElement(PlaybackRateMenuButton, props);
4231
- };
4232
- PlaybackRate.displayName = 'PlaybackRate';
4233
-
4234
- /**
4235
-
4236
- * Copyright (c) 2016 Video-React contributors
4237
- * Copyright (c) 2025 ZingMe.Vn
4238
- *
4239
- * This source code is licensed under the MIT license found in the
4240
- * LICENSE file in the root directory of this source tree.
4241
- */
4242
- var DEFAULT_KINDS = ['captions', 'subtitles'];
4243
- var ClosedCaptionButton = function ClosedCaptionButton(_ref) {
4244
- var player = _ref.player,
4245
- actions = _ref.actions,
4246
- className = _ref.className,
4247
- _ref$offMenuText = _ref.offMenuText,
4248
- offMenuText = _ref$offMenuText === void 0 ? 'Off' : _ref$offMenuText,
4249
- _ref$showOffMenu = _ref.showOffMenu,
4250
- showOffMenu = _ref$showOffMenu === void 0 ? true : _ref$showOffMenu,
4251
- _ref$kinds = _ref.kinds,
4252
- kinds = _ref$kinds === void 0 ? DEFAULT_KINDS : _ref$kinds;
4253
- var textTrackItems = React.useMemo(function () {
4254
- var items = [];
4255
- var tracks = Array.from(player.textTracks || []);
4256
- if (showOffMenu) {
4257
- items.push({
4258
- label: offMenuText,
4259
- value: null
4260
- });
4261
- }
4262
- tracks.forEach(function (textTrack) {
4263
- if (kinds.length && !kinds.includes(textTrack.kind)) {
4264
- return;
4265
- }
4266
- items.push({
4267
- label: textTrack.label || textTrack.language || 'Unknown',
4268
- value: textTrack.language || null
4269
- });
4270
- });
4271
- var selectedIndex = items.findIndex(function (item) {
4272
- return player.activeTextTrack && item.value !== null && player.activeTextTrack.language === item.value;
4273
- });
4274
- return {
4275
- items: items,
4276
- selectedIndex: selectedIndex >= 0 ? selectedIndex : 0
4277
- };
4278
- }, [kinds, offMenuText, player.activeTextTrack, player.textTracks, showOffMenu]);
4279
- var handleSelectItem = React.useCallback(function (index) {
4280
- Array.from(player.textTracks || []).forEach(function (textTrack, trackIndex) {
4281
- var normalizedIndex = showOffMenu ? trackIndex + 1 : trackIndex;
4282
- if (index === normalizedIndex) {
4283
- textTrack.mode = 'showing';
4284
- actions.activateTextTrack(textTrack);
4285
- } else {
4286
- textTrack.mode = 'hidden';
4287
- }
4288
- });
4289
- if (showOffMenu && index === 0) {
4290
- actions.activateTextTrack(null);
4291
- }
4292
- }, [actions, player.textTracks, showOffMenu]);
4293
- return React__default.createElement(MenuButton, {
4294
- className: classnames('video-react-player-closed-caption', className),
4295
- onSelectItem: handleSelectItem,
4296
- items: textTrackItems.items,
4297
- selectedIndex: textTrackItems.selectedIndex
4298
- }, React__default.createElement("span", {
4299
- className: "video-react-player-control-text"
4300
- }, "Closed Caption"));
4301
- };
4302
- ClosedCaptionButton.displayName = 'ClosedCaptionButton';
4303
-
4304
- /**
4305
-
4306
- * Copyright (c) 2016 Video-React contributors
4307
- * Copyright (c) 2025 ZingMe.Vn
4308
- *
4309
- * This source code is licensed under the MIT license found in the
4310
- * LICENSE file in the root directory of this source tree.
4311
- */
4312
- var PictureInPictureToggle = function PictureInPictureToggle(_ref) {
4313
- var _player$isPictureInPi;
4314
- var actions = _ref.actions,
4315
- player = _ref.player,
4316
- className = _ref.className;
4317
- var handleClick = React.useCallback(function () {
4318
- actions.togglePictureInPicture();
4319
- }, [actions]);
4320
- var isPip = (_player$isPictureInPi = player.isPictureInPicture) !== null && _player$isPictureInPi !== void 0 ? _player$isPictureInPi : false;
4321
- return React__default.createElement("button", {
4322
- className: classnames(className, {
4323
- 'video-react-player-icon-picture-in-picture-exit': isPip,
4324
- 'video-react-player-icon-picture-in-picture': !isPip
4325
- }, 'video-react-player-picture-in-picture-control video-react-player-control video-react-player-button video-react-player-icon'),
4326
- type: "button",
4327
- tabIndex: 0,
4328
- onClick: handleClick
4329
- }, React__default.createElement("span", {
4330
- className: "video-react-player-control-text"
4331
- }, "Picture-in-Picture"));
4332
- };
4333
- PictureInPictureToggle.displayName = 'PictureInPictureToggle';
4334
-
4335
- /**
4336
-
4337
- * Copyright (c) 2016 Video-React contributors
4338
- * Copyright (c) 2025 ZingMe.Vn
4339
- *
4340
- * This source code is licensed under the MIT license found in the
4341
- * LICENSE file in the root directory of this source tree.
4342
- */
4343
- var LoopToggle = React.forwardRef(function (_ref, ref) {
4344
- var actions = _ref.actions,
4345
- player = _ref.player,
4346
- className = _ref.className;
4347
- var isLoop = !!player.loop;
4348
- var handleClick = React.useCallback(function () {
4349
- actions.handleLoopChange(!isLoop);
4350
- }, [actions, isLoop]);
4351
- return React__default.createElement("button", {
4352
- className: classnames(className, {
4353
- 'video-react-player-icon-loop-active': isLoop,
4354
- 'video-react-player-icon-loop': !isLoop
4355
- }, 'video-react-player-loop-control video-react-player-control video-react-player-button video-react-player-icon'),
4356
- ref: ref,
4357
- type: "button",
4358
- tabIndex: 0,
4359
- onClick: handleClick
4360
- }, React__default.createElement("span", {
4361
- className: "video-react-player-control-text"
4362
- }, isLoop ? 'Loop On' : 'Loop Off'));
4363
- });
4364
- LoopToggle.displayName = 'LoopToggle';
4365
-
4366
- /**
4367
-
4368
- * Copyright (c) 2016 Video-React contributors
4369
- * Copyright (c) 2025 ZingMe.Vn
4370
- *
4371
- * This source code is licensed under the MIT license found in the
4372
- * LICENSE file in the root directory of this source tree.
4373
- */
4374
- var TheaterModeToggle = function TheaterModeToggle(_ref) {
4375
- var _player$isTheater;
4376
- var actions = _ref.actions,
4377
- player = _ref.player,
4378
- className = _ref.className;
4379
- var handleClick = React.useCallback(function () {
4380
- actions.toggleTheaterMode(!player.isTheater);
4381
- }, [actions, player.isTheater]);
4382
- var isTheater = (_player$isTheater = player.isTheater) !== null && _player$isTheater !== void 0 ? _player$isTheater : false;
4383
- return React__default.createElement("button", {
4384
- className: classnames(className, {
4385
- 'video-react-player-icon-theater-exit': isTheater,
4386
- 'video-react-player-icon-theater': !isTheater
4387
- }, 'video-react-player-theater-control video-react-player-control video-react-player-button video-react-player-icon'),
4388
- type: "button",
4389
- tabIndex: 0,
4390
- onClick: handleClick
4391
- }, React__default.createElement("span", {
4392
- className: "video-react-player-control-text"
4393
- }, isTheater ? 'Exit Theater Mode' : 'Theater Mode'));
4394
- };
4395
- TheaterModeToggle.displayName = 'TheaterModeToggle';
4396
-
4397
- /**
4398
-
4399
- * Copyright (c) 2016 Video-React contributors
4400
- * Copyright (c) 2025 ZingMe.Vn
4401
- *
4402
- * This source code is licensed under the MIT license found in the
4403
- * LICENSE file in the root directory of this source tree.
4404
- */
4405
- var DownloadButton = function DownloadButton(_ref) {
4406
- var player = _ref.player,
4407
- className = _ref.className,
4408
- _ref$filename = _ref.filename,
4409
- filename = _ref$filename === void 0 ? 'video' : _ref$filename;
4410
- var handleClick = React.useCallback(function () {
4411
- if (!player.currentSrc) {
4412
- return;
4413
- }
4414
- var link = document.createElement('a');
4415
- link.href = player.currentSrc;
4416
- link.download = filename;
4417
- link.click();
4418
- }, [filename, player.currentSrc]);
4419
- return React__default.createElement("button", {
4420
- className: classnames(className, 'video-react-player-icon-download', 'video-react-player-download-control video-react-player-control video-react-player-button video-react-player-icon'),
4421
- type: "button",
4422
- tabIndex: 0,
4423
- onClick: handleClick
4424
- }, React__default.createElement("span", {
4425
- className: "video-react-player-control-text"
4426
- }, "Download"));
4427
- };
4428
- DownloadButton.displayName = 'DownloadButton';
4429
-
4430
- /**
4431
-
4432
- * Copyright (c) 2016 Video-React contributors
4433
- * Copyright (c) 2025 ZingMe.Vn
4434
- *
4435
- * This source code is licensed under the MIT license found in the
4436
- * LICENSE file in the root directory of this source tree.
4437
- */
4438
- var ScreenshotButton = function ScreenshotButton(_ref) {
4439
- var actions = _ref.actions,
4440
- className = _ref.className;
4441
- var handleClick = React.useCallback(function () {
4442
- actions.takeScreenshot();
4443
- }, [actions]);
4444
- return React__default.createElement("button", {
4445
- className: classnames(className, 'video-react-player-icon-camera', 'video-react-player-screenshot-control video-react-player-control video-react-player-button video-react-player-icon'),
4446
- type: "button",
4447
- tabIndex: 0,
4448
- onClick: handleClick
4449
- }, React__default.createElement("span", {
4450
- className: "video-react-player-control-text"
4451
- }, "Screenshot"));
4452
- };
4453
- ScreenshotButton.displayName = 'ScreenshotButton';
4454
-
4455
- /**
4456
-
4457
- * Copyright (c) 2016 Video-React contributors
4458
- * Copyright (c) 2025 ZingMe.Vn
4459
- *
4460
- * This source code is licensed under the MIT license found in the
4461
- * LICENSE file in the root directory of this source tree.
4462
- */
4463
- var DEFAULT_QUALITIES = ['auto', '1080p', '720p', '480p', '360p', '240p'];
4464
- var QualityMenuButton = function QualityMenuButton(_ref) {
4465
- var _ref$qualities = _ref.qualities,
4466
- qualities = _ref$qualities === void 0 ? DEFAULT_QUALITIES : _ref$qualities,
4467
- actions = _ref.actions,
4468
- player = _ref.player,
4469
- className = _ref.className;
4470
- var items = React.useMemo(function () {
4471
- return qualities.map(function (quality) {
4472
- return {
4473
- label: quality,
4474
- value: quality
4475
- };
4476
- });
4477
- }, [qualities]);
4478
- var currentQuality = player.quality || 'auto';
4479
- var selectedIndex = React.useMemo(function () {
4480
- var index = qualities.indexOf(currentQuality);
4481
- return index >= 0 ? index : 0;
4482
- }, [currentQuality, qualities]);
4483
- var handleSelectItem = React.useCallback(function (index) {
4484
- if (index >= 0 && index < qualities.length) {
4485
- actions.changeQuality(qualities[index]);
4486
- }
4487
- }, [actions, qualities]);
4488
- return React__default.createElement(MenuButton, {
4489
- className: classnames('video-react-player-quality-menu', className),
4490
- onSelectItem: handleSelectItem,
4491
- items: items,
4492
- selectedIndex: selectedIndex
4493
- }, React__default.createElement("span", {
4494
- className: "video-react-player-control-text"
4495
- }, "Quality"), React__default.createElement("div", {
4496
- className: "video-react-player-quality-value"
4497
- }, currentQuality));
4498
- };
4499
- QualityMenuButton.displayName = 'QualityMenuButton';
4500
-
4501
- function RemainingTimeDisplay(_ref) {
4502
- var _ref$player = _ref.player,
4503
- currentTime = _ref$player.currentTime,
4504
- duration = _ref$player.duration,
4505
- className = _ref.className;
4506
- var remainingTime = duration - currentTime;
4507
- var formattedTime = formatTime(remainingTime);
4508
- return React__default.createElement("div", {
4509
- className: classnames('video-react-player-remaining-time video-react-player-time-control video-react-player-control', className)
4510
- }, React__default.createElement("div", {
4511
- className: "video-react-player-remaining-time-display",
4512
- "aria-live": "off"
4513
- }, React__default.createElement("span", {
4514
- className: "video-react-player-control-text"
4515
- }, "Remaining Time "), "-" + formattedTime));
4516
- }
4517
- RemainingTimeDisplay.displayName = 'RemainingTimeDisplay';
4518
-
4519
- /**
4520
-
4521
- * Copyright (c) 2016 Video-React contributors
4522
- * Copyright (c) 2025 ZingMe.Vn
4523
- *
4524
- * This source code is licensed under the MIT license found in the
4525
- * LICENSE file in the root directory of this source tree.
4526
- */
4527
-
4528
- /**
4529
-
4530
- * Copyright (c) 2016 Video-React contributors
4531
- * Copyright (c) 2025 ZingMe.Vn
4532
- *
4533
- * This source code is licensed under the MIT license found in the
4534
- * LICENSE file in the root directory of this source tree.
4535
- */
4536
-
4537
- exports.Bezel = Bezel;
4538
- exports.BigPlayButton = BigPlayButton;
4539
- exports.ClosedCaptionButton = ClosedCaptionButton;
4540
- exports.ControlBar = ControlBar;
4541
- exports.CurrentTimeDisplay = CurrentTimeDisplay;
4542
- exports.DownloadButton = DownloadButton;
4543
- exports.DurationDisplay = DurationDisplay;
4544
- exports.ForwardControl = ForwardControl;
4545
- exports.FullscreenToggle = FullscreenToggle;
4546
- exports.LoadProgressBar = LoadProgressBar;
4547
- exports.LoadingSpinner = LoadingSpinner;
4548
- exports.LoopToggle = LoopToggle;
4549
- exports.MenuButton = MenuButton;
4550
- exports.MouseTimeDisplay = MouseTimeDisplay;
4551
- exports.PictureInPictureToggle = PictureInPictureToggle;
4552
- exports.PlayProgressBar = PlayProgressBar;
4553
- exports.PlayToggle = PlayToggle;
4554
- exports.PlaybackRate = PlaybackRate;
4555
- exports.PlaybackRateMenuButton = PlaybackRateMenuButton;
4556
- exports.Player = Player;
4557
- exports.PosterImage = PosterImage;
4558
- exports.ProgressControl = ProgressControl;
4559
- exports.QualityMenuButton = QualityMenuButton;
4560
- exports.RemainingTimeDisplay = RemainingTimeDisplay;
4561
- exports.ReplayControl = ReplayControl;
4562
- exports.ScreenshotButton = ScreenshotButton;
4563
- exports.SeekBar = SeekBar;
4564
- exports.Shortcut = Shortcut;
4565
- exports.Slider = Slider;
4566
- exports.TheaterModeToggle = TheaterModeToggle;
4567
- exports.TimeDivider = TimeDivider;
4568
- exports.Video = Video;
4569
- exports.VolumeMenuButton = VolumeMenuButton;
4570
- exports.operationReducer = operationReducer;
4571
- exports.playerActions = playerActions;
4572
- exports.playerReducer = playerReducer;
4573
- exports.videoActions = videoActions;
4574
-
4575
- Object.defineProperty(exports, '__esModule', { value: true });
4576
-
4577
- }));
4578
- //# sourceMappingURL=video-react-player.full.js.map