video-react-player 0.1.0

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