@uncinc/uncinc-react-kitchen-sink 2.16.15 → 2.17.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.
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import 'videojs-vimeo-tech';
|
|
3
|
-
import 'videojs-youtube';
|
|
4
2
|
import { MediaPlayerProps } from './types';
|
|
5
|
-
import 'video.js/dist/video-js.css';
|
|
6
|
-
import './style.scss';
|
|
7
3
|
declare const MediaPlayer: React.FC<MediaPlayerProps>;
|
|
8
4
|
export default MediaPlayer;
|
|
@@ -1,153 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import React, { useEffect, useMemo } from 'react';
|
|
8
|
-
import c from 'classnames';
|
|
9
|
-
import { useVideoJS } from 'react-hook-videojs';
|
|
10
|
-
import { useTranslation } from 'react-i18next';
|
|
11
|
-
// VideoJS plugins:
|
|
12
|
-
import 'videojs-vimeo-tech';
|
|
13
|
-
import 'videojs-youtube';
|
|
14
|
-
import 'video.js/dist/video-js.css';
|
|
15
|
-
import './style.scss';
|
|
16
|
-
var MediaPlayer = function MediaPlayer(_ref) {
|
|
17
|
-
var src = _ref.src,
|
|
18
|
-
type = _ref.type,
|
|
19
|
-
controls = _ref.controls,
|
|
20
|
-
posterUrl = _ref.posterUrl,
|
|
21
|
-
customOptions = _ref.options,
|
|
22
|
-
captions = _ref.captions,
|
|
23
|
-
audioOnly = _ref.audioOnly,
|
|
24
|
-
notSupportedMessage = _ref.notSupportedMessage,
|
|
25
|
-
className = _ref.className,
|
|
26
|
-
onPlay = _ref.onPlay,
|
|
27
|
-
_ref$autoPlay = _ref.autoPlay,
|
|
28
|
-
autoPlay = _ref$autoPlay === void 0 ? false : _ref$autoPlay,
|
|
29
|
-
onPause = _ref.onPause,
|
|
30
|
-
onEnded = _ref.onEnded,
|
|
31
|
-
onSeeking = _ref.onSeeking,
|
|
32
|
-
onVolumeChange = _ref.onVolumeChange,
|
|
33
|
-
onFullscreenChange = _ref.onFullscreenChange,
|
|
34
|
-
onError = _ref.onError;
|
|
35
|
-
var _useTranslation = useTranslation(),
|
|
36
|
-
t = _useTranslation.t;
|
|
37
|
-
var classNames = c('MediaPlayer', 'video-js', 'vjs-default-skin', 'vjs-big-play-centered', className);
|
|
38
|
-
var audioOnlyMode = useMemo(function () {
|
|
39
|
-
return audioOnly || type.startsWith('audio');
|
|
40
|
-
}, [type, audioOnly]);
|
|
41
|
-
var controlBar = useMemo(function () {
|
|
42
|
-
var videoJSControls = {
|
|
43
|
-
play: 'playToggle',
|
|
44
|
-
currentTime: 'currentTimeDisplay',
|
|
45
|
-
timeDivider: 'timeDivider',
|
|
46
|
-
duration: 'durationDisplay',
|
|
47
|
-
seekbar: 'progressControl',
|
|
48
|
-
captions: 'subsCapsButton',
|
|
49
|
-
volume: 'volumePanel',
|
|
50
|
-
fullscreen: 'fullscreenToggle'
|
|
51
|
-
};
|
|
52
|
-
var controlMapped = function controlMapped(control) {
|
|
53
|
-
return {
|
|
54
|
-
name: videoJSControls[control],
|
|
55
|
-
className: "MediaPlayer__control MediaPlayer__control--".concat(control)
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
if (controls === false || _typeof(controls) === 'object' && controls.length === 0) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
if (_typeof(controls) === 'object' && controls.length > 0) {
|
|
62
|
-
return {
|
|
63
|
-
children: controls.map(controlMapped)
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
var controlKeys = Object.keys(videoJSControls);
|
|
67
|
-
return {
|
|
68
|
-
children: controlKeys.map(controlMapped)
|
|
69
|
-
};
|
|
70
|
-
}, [controls]);
|
|
71
|
-
|
|
72
|
-
// Can be overridden by the custom options prop.
|
|
73
|
-
var defaultOptions = {
|
|
74
|
-
controls: true,
|
|
75
|
-
aspectRatio: '16:9',
|
|
76
|
-
audioOnlyMode: audioOnlyMode,
|
|
77
|
-
fluid: true,
|
|
78
|
-
notSupportedMessage: notSupportedMessage || t('organisms.media_player.not_supported_message'),
|
|
79
|
-
techOrder: ['html5', 'youtube', 'vimeo'],
|
|
80
|
-
poster: posterUrl,
|
|
81
|
-
controlBar: controlBar,
|
|
82
|
-
autoplay: autoPlay,
|
|
83
|
-
sources: [{
|
|
84
|
-
src: src,
|
|
85
|
-
type: type
|
|
86
|
-
}]
|
|
87
|
-
};
|
|
88
|
-
var options = _objectSpread(_objectSpread({}, defaultOptions), customOptions);
|
|
89
|
-
var videoJS = useVideoJS(options);
|
|
90
|
-
var _ref2 = videoJS,
|
|
91
|
-
Video = _ref2.Video,
|
|
92
|
-
player = _ref2.player,
|
|
93
|
-
ready = _ref2.ready;
|
|
94
|
-
|
|
95
|
-
// Passing down the VideoJS events.
|
|
96
|
-
useEffect(function () {
|
|
97
|
-
if (ready) {
|
|
98
|
-
if (autoPlay && onPlay) {
|
|
99
|
-
player.one('play', function (event) {
|
|
100
|
-
return onPlay(player, event);
|
|
101
|
-
});
|
|
102
|
-
} else if (!autoPlay && onPlay) {
|
|
103
|
-
player.on('play', function (event) {
|
|
104
|
-
return onPlay(player, event);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
if (onPause) {
|
|
108
|
-
player.one('pause', function (event) {
|
|
109
|
-
return onPause(player, event);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
if (onEnded) {
|
|
113
|
-
player.one('ended', function (event) {
|
|
114
|
-
return onEnded(player, event);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
if (onSeeking) {
|
|
118
|
-
player.one('seeking', function (event) {
|
|
119
|
-
return onSeeking(player, event);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
if (onVolumeChange) {
|
|
123
|
-
player.one('volumechange', function (event) {
|
|
124
|
-
return onVolumeChange(player, event);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
if (onFullscreenChange) {
|
|
128
|
-
player.one('fullscreenchange', function (event) {
|
|
129
|
-
return onFullscreenChange(player, event);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
if (onError) {
|
|
133
|
-
player.one('error', function (event) {
|
|
134
|
-
return onError(player, event);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
// eslint-disable-next-line max-len
|
|
139
|
-
}, [onEnded, onError, onFullscreenChange, onPause, onPlay, onSeeking, onVolumeChange, player, ready]);
|
|
140
|
-
return /*#__PURE__*/React.createElement(Video, {
|
|
141
|
-
className: classNames
|
|
142
|
-
}, !audioOnlyMode && captions && captions.map(function (caption) {
|
|
143
|
-
return /*#__PURE__*/React.createElement("track", {
|
|
144
|
-
key: "caption:".concat(caption.language),
|
|
145
|
-
kind: "captions",
|
|
146
|
-
src: caption.src,
|
|
147
|
-
srcLang: caption.language,
|
|
148
|
-
label: caption.label || caption.language,
|
|
149
|
-
default: caption.default
|
|
150
|
-
});
|
|
151
|
-
}));
|
|
1
|
+
import React, { lazy, Suspense } from 'react';
|
|
2
|
+
var MediaPlayerLazy = /*#__PURE__*/lazy(function () {
|
|
3
|
+
return import('./index.lazy');
|
|
4
|
+
});
|
|
5
|
+
var MediaPlayer = function MediaPlayer(props) {
|
|
6
|
+
return /*#__PURE__*/React.createElement(Suspense, null, /*#__PURE__*/React.createElement(MediaPlayerLazy, props));
|
|
152
7
|
};
|
|
153
8
|
export default MediaPlayer;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import 'videojs-vimeo-tech';
|
|
3
|
+
import 'videojs-youtube';
|
|
4
|
+
import { MediaPlayerProps } from './types';
|
|
5
|
+
import 'video.js/dist/video-js.css';
|
|
6
|
+
import './style.scss';
|
|
7
|
+
declare const MediaPlayer: React.FC<MediaPlayerProps>;
|
|
8
|
+
export default MediaPlayer;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
5
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
7
|
+
import React, { useEffect, useMemo } from 'react';
|
|
8
|
+
import c from 'classnames';
|
|
9
|
+
import { useVideoJS } from 'react-hook-videojs';
|
|
10
|
+
import { useTranslation } from 'react-i18next';
|
|
11
|
+
// VideoJS plugins:
|
|
12
|
+
import 'videojs-vimeo-tech';
|
|
13
|
+
import 'videojs-youtube';
|
|
14
|
+
import 'video.js/dist/video-js.css';
|
|
15
|
+
import './style.scss';
|
|
16
|
+
var MediaPlayer = function MediaPlayer(_ref) {
|
|
17
|
+
var src = _ref.src,
|
|
18
|
+
type = _ref.type,
|
|
19
|
+
controls = _ref.controls,
|
|
20
|
+
posterUrl = _ref.posterUrl,
|
|
21
|
+
customOptions = _ref.options,
|
|
22
|
+
captions = _ref.captions,
|
|
23
|
+
audioOnly = _ref.audioOnly,
|
|
24
|
+
notSupportedMessage = _ref.notSupportedMessage,
|
|
25
|
+
className = _ref.className,
|
|
26
|
+
onPlay = _ref.onPlay,
|
|
27
|
+
_ref$autoPlay = _ref.autoPlay,
|
|
28
|
+
autoPlay = _ref$autoPlay === void 0 ? false : _ref$autoPlay,
|
|
29
|
+
onPause = _ref.onPause,
|
|
30
|
+
onEnded = _ref.onEnded,
|
|
31
|
+
onSeeking = _ref.onSeeking,
|
|
32
|
+
onVolumeChange = _ref.onVolumeChange,
|
|
33
|
+
onFullscreenChange = _ref.onFullscreenChange,
|
|
34
|
+
onError = _ref.onError;
|
|
35
|
+
var _useTranslation = useTranslation(),
|
|
36
|
+
t = _useTranslation.t;
|
|
37
|
+
var classNames = c('MediaPlayer', 'video-js', 'vjs-default-skin', 'vjs-big-play-centered', className);
|
|
38
|
+
var audioOnlyMode = useMemo(function () {
|
|
39
|
+
return audioOnly || type.startsWith('audio');
|
|
40
|
+
}, [type, audioOnly]);
|
|
41
|
+
var controlBar = useMemo(function () {
|
|
42
|
+
var videoJSControls = {
|
|
43
|
+
play: 'playToggle',
|
|
44
|
+
currentTime: 'currentTimeDisplay',
|
|
45
|
+
timeDivider: 'timeDivider',
|
|
46
|
+
duration: 'durationDisplay',
|
|
47
|
+
seekbar: 'progressControl',
|
|
48
|
+
captions: 'subsCapsButton',
|
|
49
|
+
volume: 'volumePanel',
|
|
50
|
+
fullscreen: 'fullscreenToggle'
|
|
51
|
+
};
|
|
52
|
+
var controlMapped = function controlMapped(control) {
|
|
53
|
+
return {
|
|
54
|
+
name: videoJSControls[control],
|
|
55
|
+
className: "MediaPlayer__control MediaPlayer__control--".concat(control)
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
if (controls === false || _typeof(controls) === 'object' && controls.length === 0) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
if (_typeof(controls) === 'object' && controls.length > 0) {
|
|
62
|
+
return {
|
|
63
|
+
children: controls.map(controlMapped)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
var controlKeys = Object.keys(videoJSControls);
|
|
67
|
+
return {
|
|
68
|
+
children: controlKeys.map(controlMapped)
|
|
69
|
+
};
|
|
70
|
+
}, [controls]);
|
|
71
|
+
|
|
72
|
+
// Can be overridden by the custom options prop.
|
|
73
|
+
var defaultOptions = {
|
|
74
|
+
controls: true,
|
|
75
|
+
aspectRatio: '16:9',
|
|
76
|
+
audioOnlyMode: audioOnlyMode,
|
|
77
|
+
fluid: true,
|
|
78
|
+
notSupportedMessage: notSupportedMessage || t('organisms.media_player.not_supported_message'),
|
|
79
|
+
techOrder: ['html5', 'youtube', 'vimeo'],
|
|
80
|
+
poster: posterUrl,
|
|
81
|
+
controlBar: controlBar,
|
|
82
|
+
autoplay: autoPlay,
|
|
83
|
+
sources: [{
|
|
84
|
+
src: src,
|
|
85
|
+
type: type
|
|
86
|
+
}]
|
|
87
|
+
};
|
|
88
|
+
var options = _objectSpread(_objectSpread({}, defaultOptions), customOptions);
|
|
89
|
+
var videoJS = useVideoJS(options);
|
|
90
|
+
var _ref2 = videoJS,
|
|
91
|
+
Video = _ref2.Video,
|
|
92
|
+
player = _ref2.player,
|
|
93
|
+
ready = _ref2.ready;
|
|
94
|
+
|
|
95
|
+
// Passing down the VideoJS events.
|
|
96
|
+
useEffect(function () {
|
|
97
|
+
if (ready) {
|
|
98
|
+
if (autoPlay && onPlay) {
|
|
99
|
+
player.one('play', function (event) {
|
|
100
|
+
return onPlay(player, event);
|
|
101
|
+
});
|
|
102
|
+
} else if (!autoPlay && onPlay) {
|
|
103
|
+
player.on('play', function (event) {
|
|
104
|
+
return onPlay(player, event);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (onPause) {
|
|
108
|
+
player.one('pause', function (event) {
|
|
109
|
+
return onPause(player, event);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (onEnded) {
|
|
113
|
+
player.one('ended', function (event) {
|
|
114
|
+
return onEnded(player, event);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (onSeeking) {
|
|
118
|
+
player.one('seeking', function (event) {
|
|
119
|
+
return onSeeking(player, event);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (onVolumeChange) {
|
|
123
|
+
player.one('volumechange', function (event) {
|
|
124
|
+
return onVolumeChange(player, event);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (onFullscreenChange) {
|
|
128
|
+
player.one('fullscreenchange', function (event) {
|
|
129
|
+
return onFullscreenChange(player, event);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
if (onError) {
|
|
133
|
+
player.one('error', function (event) {
|
|
134
|
+
return onError(player, event);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// eslint-disable-next-line max-len
|
|
139
|
+
}, [onEnded, onError, onFullscreenChange, onPause, onPlay, onSeeking, onVolumeChange, player, ready]);
|
|
140
|
+
return /*#__PURE__*/React.createElement(Video, {
|
|
141
|
+
className: classNames
|
|
142
|
+
}, !audioOnlyMode && captions && captions.map(function (caption) {
|
|
143
|
+
return /*#__PURE__*/React.createElement("track", {
|
|
144
|
+
key: "caption:".concat(caption.language),
|
|
145
|
+
kind: "captions",
|
|
146
|
+
src: caption.src,
|
|
147
|
+
srcLang: caption.language,
|
|
148
|
+
label: caption.label || caption.language,
|
|
149
|
+
default: caption.default
|
|
150
|
+
});
|
|
151
|
+
}));
|
|
152
|
+
};
|
|
153
|
+
export default MediaPlayer;
|