@telus-uds/components-web 2.21.1 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -2
- package/lib/Badge/Badge.js +2 -14
- package/lib/Badge/index.js +0 -3
- package/lib/BlockQuote/BlockQuote.js +4 -25
- package/lib/BlockQuote/index.js +0 -3
- package/lib/Breadcrumbs/Breadcrumbs.js +9 -36
- package/lib/Breadcrumbs/Item/Item.js +15 -25
- package/lib/Breadcrumbs/index.js +0 -2
- package/lib/Callout/Callout.js +2 -24
- package/lib/Callout/index.js +0 -3
- package/lib/Card/Card.js +15 -29
- package/lib/Card/CardContent.js +5 -18
- package/lib/Card/CardFooter.js +7 -19
- package/lib/Card/index.js +0 -3
- package/lib/Countdown/Countdown.js +5 -24
- package/lib/Countdown/Segment.js +3 -15
- package/lib/Countdown/index.js +0 -3
- package/lib/Countdown/types.js +2 -7
- package/lib/Countdown/useCountdown.js +0 -7
- package/lib/DatePicker/CalendarContainer.js +0 -5
- package/lib/DatePicker/DatePicker.js +9 -61
- package/lib/DatePicker/dictionary.js +0 -8
- package/lib/DatePicker/index.js +0 -3
- package/lib/DatePicker/reactDatesCss.js +0 -2
- package/lib/Disclaimer/Disclaimer.js +5 -14
- package/lib/Disclaimer/index.js +0 -2
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +6 -17
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +12 -25
- package/lib/ExpandCollapseMini/index.js +0 -3
- package/lib/Footnote/Footnote.js +17 -63
- package/lib/Footnote/FootnoteLink.js +3 -24
- package/lib/Footnote/index.js +0 -4
- package/lib/IconButton/IconButton.js +4 -14
- package/lib/IconButton/index.js +0 -3
- package/lib/Image/Image.js +5 -24
- package/lib/Image/index.js +0 -3
- package/lib/List/List.js +0 -2
- package/lib/List/ListItem.js +0 -8
- package/lib/List/index.js +0 -4
- package/lib/NavigationBar/NavigationBar.js +10 -35
- package/lib/NavigationBar/NavigationItem.js +5 -17
- package/lib/NavigationBar/NavigationSubMenu.js +3 -19
- package/lib/NavigationBar/collapseItems.js +6 -9
- package/lib/NavigationBar/index.js +0 -3
- package/lib/NavigationBar/resolveItemSelection.js +2 -3
- package/lib/OptimizeImage/OptimizeImage.js +6 -27
- package/lib/OptimizeImage/index.js +0 -3
- package/lib/OptimizeImage/utils/getFallbackUrl.js +0 -4
- package/lib/OptimizeImage/utils/getOptimizedUrl.js +0 -8
- package/lib/OptimizeImage/utils/hasWebpSupport.js +1 -5
- package/lib/OptimizeImage/utils/index.js +0 -4
- package/lib/OptimizeImage/utils/isSvgUrl.js +0 -1
- package/lib/OrderedList/Item.js +4 -21
- package/lib/OrderedList/ItemBase.js +2 -9
- package/lib/OrderedList/OrderedList.js +11 -22
- package/lib/OrderedList/OrderedListBase.js +3 -13
- package/lib/OrderedList/index.js +0 -4
- package/lib/Paragraph/Paragraph.js +3 -18
- package/lib/Paragraph/index.js +0 -3
- package/lib/PreviewCard/AuthorDate.js +1 -10
- package/lib/PreviewCard/PreviewCard.js +15 -35
- package/lib/PreviewCard/index.js +0 -3
- package/lib/PriceLockup/PriceLockup.js +78 -75
- package/lib/PriceLockup/index.js +0 -3
- package/lib/PriceLockup/tokens.js +0 -2
- package/lib/Progress/ProgressBar.js +5 -16
- package/lib/Progress/index.js +0 -4
- package/lib/QuantitySelector/QuantitySelector.js +8 -42
- package/lib/QuantitySelector/SideButton.js +4 -11
- package/lib/QuantitySelector/index.js +0 -3
- package/lib/QuantitySelector/styles.js +0 -6
- package/lib/ResponsiveImage/ResponsiveImage.js +5 -20
- package/lib/ResponsiveImage/index.js +0 -3
- package/lib/Ribbon/Ribbon.js +4 -20
- package/lib/Ribbon/index.js +0 -3
- package/lib/SkeletonProvider/SkeletonImage.js +0 -10
- package/lib/SkeletonProvider/SkeletonProvider.js +4 -22
- package/lib/SkeletonProvider/SkeletonTypography.js +0 -10
- package/lib/SkeletonProvider/index.js +0 -3
- package/lib/Span/Span.js +3 -17
- package/lib/Span/index.js +0 -3
- package/lib/Spinner/Spinner.js +11 -39
- package/lib/Spinner/SpinnerContent.js +2 -18
- package/lib/Spinner/index.js +0 -3
- package/lib/StoryCard/StoryCard.js +11 -31
- package/lib/StoryCard/index.js +0 -3
- package/lib/Table/Body.js +0 -6
- package/lib/Table/Cell.js +4 -24
- package/lib/Table/Header.js +0 -9
- package/lib/Table/Row.js +0 -8
- package/lib/Table/SubHeading.js +0 -9
- package/lib/Table/Table.js +5 -23
- package/lib/Table/index.js +0 -8
- package/lib/TermsAndConditions/ExpandCollapse.js +4 -14
- package/lib/TermsAndConditions/TermsAndConditions.js +7 -29
- package/lib/TermsAndConditions/index.js +0 -2
- package/lib/Testimonial/Testimonial.js +2 -26
- package/lib/Testimonial/index.js +0 -3
- package/lib/Toast/Toast.js +4 -25
- package/lib/Toast/index.js +0 -3
- package/lib/Video/ControlBar/ControlBar.js +2 -25
- package/lib/Video/ControlBar/Controls/VideoButton/VideoButton.js +4 -17
- package/lib/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +4 -20
- package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +12 -26
- package/lib/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +8 -23
- package/lib/Video/MiddleControlButton/MiddleControlButton.js +2 -12
- package/lib/Video/Video.js +122 -194
- package/lib/Video/index.js +0 -3
- package/lib/VideoPicker/VideoPicker.js +6 -32
- package/lib/VideoPicker/VideoPickerPlayer.js +2 -10
- package/lib/VideoPicker/VideoPickerThumbnail.js +7 -28
- package/lib/VideoPicker/VideoSlider.js +7 -17
- package/lib/VideoPicker/index.js +0 -3
- package/lib/VideoPicker/videoPropType.js +2 -8
- package/lib/WaffleGrid/WaffleGrid.js +11 -28
- package/lib/WaffleGrid/index.js +0 -3
- package/lib/WebPortal/WebPortal.js +1 -5
- package/lib/WebPortal/index.js +0 -3
- package/lib/WebVideo/WebVideo.js +4 -30
- package/lib/WebVideo/index.js +0 -3
- package/lib/baseExports.js +6 -1
- package/lib/index.js +0 -49
- package/lib/shared/FullBleedContent/FullBleedContent.js +5 -17
- package/lib/shared/FullBleedContent/getFullBleedBorderRadius.js +0 -11
- package/lib/shared/FullBleedContent/index.js +0 -5
- package/lib/shared/FullBleedContent/useFullBleedContentProps.js +1 -12
- package/lib/shared/VideoSplash/SplashButton/SplashButton.js +2 -12
- package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +7 -23
- package/lib/shared/VideoSplash/VideoSplash.js +4 -17
- package/lib/shared/VideoSplash/helpers.js +0 -6
- package/lib/utils/index.js +0 -9
- package/lib/utils/logger.js +0 -6
- package/lib/utils/media.js +2 -11
- package/lib/utils/renderStructuredContent.js +14 -31
- package/lib/utils/ssr.js +0 -6
- package/lib/utils/transforms.js +0 -2
- package/lib/utils/useOverlaidPosition.js +6 -28
- package/lib/utils/useTypographyTheme.js +4 -5
- package/lib-module/Badge/Badge.js +2 -5
- package/lib-module/BlockQuote/BlockQuote.js +4 -15
- package/lib-module/Breadcrumbs/Breadcrumbs.js +9 -25
- package/lib-module/Breadcrumbs/Item/Item.js +15 -12
- package/lib-module/Callout/Callout.js +2 -16
- package/lib-module/Card/Card.js +14 -17
- package/lib-module/Card/CardContent.js +5 -8
- package/lib-module/Card/CardFooter.js +7 -9
- package/lib-module/Countdown/Countdown.js +6 -11
- package/lib-module/Countdown/Segment.js +6 -8
- package/lib-module/Countdown/types.js +2 -1
- package/lib-module/Countdown/useCountdown.js +0 -6
- package/lib-module/DatePicker/CalendarContainer.js +3 -1
- package/lib-module/DatePicker/DatePicker.js +9 -39
- package/lib-module/DatePicker/dictionary.js +0 -8
- package/lib-module/Disclaimer/Disclaimer.js +5 -4
- package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +6 -8
- package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +13 -19
- package/lib-module/Footnote/Footnote.js +17 -41
- package/lib-module/Footnote/FootnoteLink.js +3 -12
- package/lib-module/IconButton/IconButton.js +4 -6
- package/lib-module/Image/Image.js +5 -14
- package/lib-module/NavigationBar/NavigationBar.js +10 -20
- package/lib-module/NavigationBar/NavigationItem.js +5 -5
- package/lib-module/NavigationBar/NavigationSubMenu.js +3 -8
- package/lib-module/NavigationBar/collapseItems.js +6 -8
- package/lib-module/NavigationBar/resolveItemSelection.js +2 -2
- package/lib-module/OptimizeImage/OptimizeImage.js +6 -16
- package/lib-module/OptimizeImage/utils/getFallbackUrl.js +0 -1
- package/lib-module/OptimizeImage/utils/getOptimizedUrl.js +0 -5
- package/lib-module/OptimizeImage/utils/hasWebpSupport.js +1 -5
- package/lib-module/OrderedList/Item.js +4 -7
- package/lib-module/OrderedList/ItemBase.js +2 -3
- package/lib-module/OrderedList/OrderedList.js +11 -9
- package/lib-module/OrderedList/OrderedListBase.js +3 -3
- package/lib-module/Paragraph/Paragraph.js +3 -8
- package/lib-module/PreviewCard/AuthorDate.js +1 -4
- package/lib-module/PreviewCard/PreviewCard.js +16 -19
- package/lib-module/PriceLockup/PriceLockup.js +78 -57
- package/lib-module/Progress/ProgressBar.js +7 -8
- package/lib-module/QuantitySelector/QuantitySelector.js +8 -30
- package/lib-module/QuantitySelector/SideButton.js +4 -6
- package/lib-module/ResponsiveImage/ResponsiveImage.js +5 -12
- package/lib-module/Ribbon/Ribbon.js +4 -9
- package/lib-module/SkeletonProvider/SkeletonImage.js +0 -5
- package/lib-module/SkeletonProvider/SkeletonProvider.js +4 -12
- package/lib-module/SkeletonProvider/SkeletonTypography.js +0 -5
- package/lib-module/Span/Span.js +3 -7
- package/lib-module/Spinner/Spinner.js +11 -24
- package/lib-module/Spinner/SpinnerContent.js +2 -8
- package/lib-module/StoryCard/StoryCard.js +12 -17
- package/lib-module/Table/Body.js +0 -2
- package/lib-module/Table/Cell.js +4 -14
- package/lib-module/Table/Header.js +0 -2
- package/lib-module/Table/Row.js +0 -2
- package/lib-module/Table/SubHeading.js +0 -2
- package/lib-module/Table/Table.js +5 -6
- package/lib-module/TermsAndConditions/ExpandCollapse.js +4 -2
- package/lib-module/TermsAndConditions/TermsAndConditions.js +7 -9
- package/lib-module/Testimonial/Testimonial.js +2 -11
- package/lib-module/Toast/Toast.js +4 -15
- package/lib-module/Video/ControlBar/ControlBar.js +2 -9
- package/lib-module/Video/ControlBar/Controls/VideoButton/VideoButton.js +4 -8
- package/lib-module/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +4 -8
- package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +12 -13
- package/lib-module/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +8 -10
- package/lib-module/Video/MiddleControlButton/MiddleControlButton.js +2 -3
- package/lib-module/Video/Video.js +122 -173
- package/lib-module/VideoPicker/VideoPicker.js +6 -15
- package/lib-module/VideoPicker/VideoPickerPlayer.js +2 -3
- package/lib-module/VideoPicker/VideoPickerThumbnail.js +7 -13
- package/lib-module/VideoPicker/VideoSlider.js +6 -9
- package/lib-module/VideoPicker/videoPropType.js +2 -1
- package/lib-module/WaffleGrid/WaffleGrid.js +11 -15
- package/lib-module/WebPortal/WebPortal.js +1 -1
- package/lib-module/WebVideo/WebVideo.js +4 -15
- package/lib-module/baseExports.js +3 -2
- package/lib-module/index.js +0 -1
- package/lib-module/shared/FullBleedContent/FullBleedContent.js +5 -10
- package/lib-module/shared/FullBleedContent/getFullBleedBorderRadius.js +0 -10
- package/lib-module/shared/FullBleedContent/useFullBleedContentProps.js +1 -11
- package/lib-module/shared/VideoSplash/SplashButton/SplashButton.js +2 -3
- package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +7 -12
- package/lib-module/shared/VideoSplash/VideoSplash.js +4 -4
- package/lib-module/utils/logger.js +2 -2
- package/lib-module/utils/media.js +2 -9
- package/lib-module/utils/renderStructuredContent.js +14 -25
- package/lib-module/utils/ssr.js +0 -4
- package/lib-module/utils/useOverlaidPosition.js +8 -27
- package/lib-module/utils/useTypographyTheme.js +4 -4
- package/package.json +3 -3
- package/src/PriceLockup/PriceLockup.jsx +36 -11
- package/src/baseExports.js +1 -0
- package/src/index.js +0 -1
- package/lib/Modal/Modal.js +0 -146
- package/lib/Modal/ModalContent.js +0 -203
- package/lib/Modal/index.js +0 -13
- package/lib-module/Modal/Modal.js +0 -132
- package/lib-module/Modal/ModalContent.js +0 -181
- package/lib-module/Modal/index.js +0 -2
- package/src/Modal/Modal.jsx +0 -121
- package/src/Modal/ModalContent.jsx +0 -167
- package/src/Modal/index.js +0 -3
package/lib/Video/Video.js
CHANGED
|
@@ -4,39 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
-
|
|
14
10
|
var _fscreen = _interopRequireDefault(require("fscreen"));
|
|
15
|
-
|
|
16
11
|
var _componentsBase = require("@telus-uds/components-base");
|
|
17
|
-
|
|
18
12
|
var _Spinner = _interopRequireDefault(require("../Spinner"));
|
|
19
|
-
|
|
20
13
|
var _utils = require("../utils");
|
|
21
|
-
|
|
22
14
|
var _VideoSplash = _interopRequireDefault(require("../shared/VideoSplash/VideoSplash"));
|
|
23
|
-
|
|
24
15
|
var _MiddleControlButton = _interopRequireDefault(require("./MiddleControlButton/MiddleControlButton"));
|
|
25
|
-
|
|
26
16
|
var _ControlBar = _interopRequireDefault(require("./ControlBar/ControlBar"));
|
|
27
|
-
|
|
28
17
|
var _videoText = _interopRequireDefault(require("./videoText"));
|
|
29
|
-
|
|
30
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
|
-
|
|
32
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
|
|
34
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
|
-
|
|
36
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
|
|
37
23
|
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
// TODO: replace with the actual spinner component from UDS
|
|
40
25
|
const VideoPlayerContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
41
26
|
displayName: "Video__VideoPlayerContainer",
|
|
42
27
|
componentId: "components-web__sc-12ltnuw-0"
|
|
@@ -52,7 +37,6 @@ const VideoPlayerContainer = /*#__PURE__*/_styledComponents.default.div.withConf
|
|
|
52
37
|
border: videoBorder ? `20px solid ${borderColor}` : undefined
|
|
53
38
|
};
|
|
54
39
|
});
|
|
55
|
-
|
|
56
40
|
const VideoElementContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
57
41
|
displayName: "Video__VideoElementContainer",
|
|
58
42
|
componentId: "components-web__sc-12ltnuw-1"
|
|
@@ -62,7 +46,6 @@ const VideoElementContainer = /*#__PURE__*/_styledComponents.default.div.withCon
|
|
|
62
46
|
height: '100%',
|
|
63
47
|
fontSize: 0
|
|
64
48
|
});
|
|
65
|
-
|
|
66
49
|
const VideoPlayer = /*#__PURE__*/_styledComponents.default.video.withConfig({
|
|
67
50
|
displayName: "Video__VideoPlayer",
|
|
68
51
|
componentId: "components-web__sc-12ltnuw-2"
|
|
@@ -70,7 +53,6 @@ const VideoPlayer = /*#__PURE__*/_styledComponents.default.video.withConfig({
|
|
|
70
53
|
width: '100%',
|
|
71
54
|
height: '100%'
|
|
72
55
|
});
|
|
73
|
-
|
|
74
56
|
const VideoOverlayContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
75
57
|
displayName: "Video__VideoOverlayContainer",
|
|
76
58
|
componentId: "components-web__sc-12ltnuw-3"
|
|
@@ -85,7 +67,6 @@ const VideoOverlayContainer = /*#__PURE__*/_styledComponents.default.div.withCon
|
|
|
85
67
|
cursor: mouseInactive ? 'none' : 'pointer'
|
|
86
68
|
};
|
|
87
69
|
});
|
|
88
|
-
|
|
89
70
|
const VideoSplashContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
90
71
|
displayName: "Video__VideoSplashContainer",
|
|
91
72
|
componentId: "components-web__sc-12ltnuw-4"
|
|
@@ -95,7 +76,6 @@ const VideoSplashContainer = /*#__PURE__*/_styledComponents.default.div.withConf
|
|
|
95
76
|
height: '100%',
|
|
96
77
|
zIndex: 5
|
|
97
78
|
});
|
|
98
|
-
|
|
99
79
|
const VideoOverlayElementContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
100
80
|
displayName: "Video__VideoOverlayElementContainer",
|
|
101
81
|
componentId: "components-web__sc-12ltnuw-5"
|
|
@@ -108,7 +88,6 @@ const VideoOverlayElementContainer = /*#__PURE__*/_styledComponents.default.div.
|
|
|
108
88
|
width: '100%',
|
|
109
89
|
height: '100%'
|
|
110
90
|
});
|
|
111
|
-
|
|
112
91
|
const Video = props => {
|
|
113
92
|
const refVideoPlayer = (0, _react.useRef)({});
|
|
114
93
|
const refVideoPlayerContainer = (0, _react.useRef)({});
|
|
@@ -142,8 +121,8 @@ const Video = props => {
|
|
|
142
121
|
keyboardVolumeIncrement: 0.1,
|
|
143
122
|
// from 0 to 1
|
|
144
123
|
compactModeThreshold: 700 // in px
|
|
145
|
-
|
|
146
124
|
};
|
|
125
|
+
|
|
147
126
|
const [videoPlayerState, setVideoPlayerState] = (0, _react.useState)({
|
|
148
127
|
loadedSources: null,
|
|
149
128
|
loadedTracks: null,
|
|
@@ -168,7 +147,6 @@ const Video = props => {
|
|
|
168
147
|
videoPlayerWidth: 0,
|
|
169
148
|
percentageWatched: 'watched 0%'
|
|
170
149
|
});
|
|
171
|
-
|
|
172
150
|
const generateSources = videoQuality => {
|
|
173
151
|
return sources.map(source => {
|
|
174
152
|
if (source.qualityRank === videoQuality) {
|
|
@@ -178,11 +156,9 @@ const Video = props => {
|
|
|
178
156
|
key: source.source
|
|
179
157
|
});
|
|
180
158
|
}
|
|
181
|
-
|
|
182
159
|
return undefined;
|
|
183
160
|
});
|
|
184
161
|
};
|
|
185
|
-
|
|
186
162
|
const generateTracks = () => {
|
|
187
163
|
return tracks.map(track => {
|
|
188
164
|
return /*#__PURE__*/_react.default.createElement('track', {
|
|
@@ -195,96 +171,91 @@ const Video = props => {
|
|
|
195
171
|
});
|
|
196
172
|
});
|
|
197
173
|
};
|
|
198
|
-
|
|
199
174
|
const refreshMedia = () => {
|
|
200
175
|
const {
|
|
201
176
|
defaultMobileQuality
|
|
202
177
|
} = props;
|
|
203
178
|
const {
|
|
204
179
|
videoUnplayed
|
|
205
|
-
} = videoPlayerState;
|
|
180
|
+
} = videoPlayerState;
|
|
206
181
|
|
|
182
|
+
// Handle mobile check
|
|
207
183
|
const isMobile = navigator && navigator.userAgent.indexOf('Mobi') >= 0;
|
|
208
|
-
|
|
209
184
|
if (videoUnplayed && isMobile) {
|
|
210
|
-
setVideoPlayerState(prevState => ({
|
|
185
|
+
setVideoPlayerState(prevState => ({
|
|
186
|
+
...prevState,
|
|
211
187
|
isMobile,
|
|
212
188
|
videoQuality: isMobile ? defaultMobileQuality : defaultDesktopQuality
|
|
213
189
|
}));
|
|
214
|
-
}
|
|
215
|
-
|
|
190
|
+
}
|
|
216
191
|
|
|
217
|
-
|
|
192
|
+
// Load media
|
|
193
|
+
setVideoPlayerState(prevState => ({
|
|
194
|
+
...prevState,
|
|
218
195
|
loadedSources: generateSources(prevState.videoQuality),
|
|
219
196
|
loadedTracks: tracks && generateTracks()
|
|
220
197
|
}));
|
|
221
198
|
};
|
|
222
|
-
|
|
223
199
|
const percentageBucket = percentValue => {
|
|
224
200
|
if (percentValue < 25) {
|
|
225
201
|
return setVideoPlayerState(prevState => {
|
|
226
202
|
if (prevState !== 'watched 0%') {
|
|
227
|
-
return {
|
|
203
|
+
return {
|
|
204
|
+
...prevState,
|
|
228
205
|
percentageWatched: 'watched 0%'
|
|
229
206
|
};
|
|
230
207
|
}
|
|
231
|
-
|
|
232
208
|
return false;
|
|
233
209
|
});
|
|
234
210
|
}
|
|
235
|
-
|
|
236
211
|
if (percentValue < 50) {
|
|
237
212
|
return setVideoPlayerState(prevState => {
|
|
238
213
|
if (prevState !== 'watched 25%') {
|
|
239
|
-
return {
|
|
214
|
+
return {
|
|
215
|
+
...prevState,
|
|
240
216
|
percentageWatched: 'watched 25%'
|
|
241
217
|
};
|
|
242
218
|
}
|
|
243
|
-
|
|
244
219
|
return false;
|
|
245
220
|
});
|
|
246
221
|
}
|
|
247
|
-
|
|
248
222
|
if (percentValue < 75) {
|
|
249
223
|
return setVideoPlayerState(prevState => {
|
|
250
224
|
if (prevState !== 'watched 50%') {
|
|
251
|
-
return {
|
|
225
|
+
return {
|
|
226
|
+
...prevState,
|
|
252
227
|
percentageWatched: 'watched 50%'
|
|
253
228
|
};
|
|
254
229
|
}
|
|
255
|
-
|
|
256
230
|
return false;
|
|
257
231
|
});
|
|
258
232
|
}
|
|
259
|
-
|
|
260
233
|
if (percentValue < 100) {
|
|
261
234
|
return setVideoPlayerState(prevState => {
|
|
262
235
|
if (prevState !== 'watched 75%') {
|
|
263
|
-
return {
|
|
236
|
+
return {
|
|
237
|
+
...prevState,
|
|
264
238
|
percentageWatched: 'watched 75%'
|
|
265
239
|
};
|
|
266
240
|
}
|
|
267
|
-
|
|
268
241
|
return false;
|
|
269
242
|
});
|
|
270
243
|
}
|
|
271
|
-
|
|
272
244
|
if (percentValue === 100) {
|
|
273
245
|
return setVideoPlayerState(prevState => {
|
|
274
246
|
if (prevState !== 'watched 100%') {
|
|
275
|
-
return {
|
|
247
|
+
return {
|
|
248
|
+
...prevState,
|
|
276
249
|
percentageWatched: 'watched 100%'
|
|
277
250
|
};
|
|
278
251
|
}
|
|
279
|
-
|
|
280
252
|
return false;
|
|
281
253
|
});
|
|
282
254
|
}
|
|
283
|
-
|
|
284
255
|
return false;
|
|
285
|
-
};
|
|
286
|
-
|
|
256
|
+
};
|
|
287
257
|
|
|
258
|
+
// required for analytics
|
|
288
259
|
const calculatePercentageWatched = () => {
|
|
289
260
|
const {
|
|
290
261
|
videoCurrentTime,
|
|
@@ -299,7 +270,6 @@ const Video = props => {
|
|
|
299
270
|
percentValue = Math.round(percentValue);
|
|
300
271
|
const previousValue = percentageWatched;
|
|
301
272
|
percentageBucket(percentValue);
|
|
302
|
-
|
|
303
273
|
if (previousValue !== percentageWatched) {
|
|
304
274
|
const analyticsObject = {
|
|
305
275
|
name: 'video tracking',
|
|
@@ -309,20 +279,18 @@ const Video = props => {
|
|
|
309
279
|
analyticsTracking(analyticsObject);
|
|
310
280
|
}
|
|
311
281
|
};
|
|
312
|
-
|
|
313
282
|
const setPlaying = async isPlaying => {
|
|
314
283
|
const videoPlayer = refVideoPlayer.current;
|
|
315
284
|
const {
|
|
316
285
|
analyticsTracking,
|
|
317
286
|
videoTitle
|
|
318
287
|
} = props;
|
|
319
|
-
|
|
320
288
|
if (isPlaying) {
|
|
321
289
|
await videoPlayer.play();
|
|
322
|
-
|
|
323
290
|
if (analyticsTracking !== undefined && videoTitle) {
|
|
324
291
|
const intervalId = setInterval(calculatePercentageWatched, 300);
|
|
325
|
-
setVideoPlayerState(prevState => ({
|
|
292
|
+
setVideoPlayerState(prevState => ({
|
|
293
|
+
...prevState,
|
|
326
294
|
intervalId
|
|
327
295
|
}));
|
|
328
296
|
}
|
|
@@ -334,7 +302,6 @@ const Video = props => {
|
|
|
334
302
|
clearInterval(intervalId);
|
|
335
303
|
}
|
|
336
304
|
};
|
|
337
|
-
|
|
338
305
|
const updateAnalyticsData = () => {
|
|
339
306
|
const {
|
|
340
307
|
videoTitle,
|
|
@@ -349,40 +316,38 @@ const Video = props => {
|
|
|
349
316
|
details: videoTitle
|
|
350
317
|
};
|
|
351
318
|
analyticsObject.action = videoIsPlaying ? 'play' : 'pause';
|
|
352
|
-
|
|
353
319
|
if (percentageWatched !== 'watched 100%') {
|
|
354
320
|
analyticsTracking(analyticsObject);
|
|
355
321
|
}
|
|
356
322
|
};
|
|
357
|
-
|
|
358
323
|
const setSeek = seconds => {
|
|
359
324
|
refVideoPlayer.current.currentTime = seconds;
|
|
360
325
|
};
|
|
361
|
-
|
|
362
326
|
const qualitySwitchSeek = () => {
|
|
363
327
|
const {
|
|
364
328
|
videoCurrentTime
|
|
365
|
-
} = videoPlayerState;
|
|
329
|
+
} = videoPlayerState;
|
|
366
330
|
|
|
367
|
-
|
|
331
|
+
// The following setState gets the video length on the splash screen in iOS
|
|
332
|
+
setVideoPlayerState(prevState => ({
|
|
333
|
+
...prevState,
|
|
368
334
|
videoLength: refVideoPlayer.current.duration
|
|
369
335
|
}));
|
|
370
|
-
|
|
371
336
|
if (videoCurrentTime > -1) {
|
|
372
337
|
setSeek(videoCurrentTime);
|
|
373
338
|
}
|
|
374
339
|
};
|
|
375
|
-
|
|
376
340
|
const updateVideoTimestamp = () => {
|
|
377
|
-
setVideoPlayerState(prevState => ({
|
|
341
|
+
setVideoPlayerState(prevState => ({
|
|
342
|
+
...prevState,
|
|
378
343
|
videoCurrentTime: refVideoPlayer.current.currentTime
|
|
379
344
|
}));
|
|
380
345
|
};
|
|
381
|
-
|
|
382
346
|
const initializeVideoDuration = () => {
|
|
383
347
|
// This will run on every load() call, meaning it will also run when video quality is changed.
|
|
384
348
|
setVideoPlayerState(prevState => {
|
|
385
|
-
return {
|
|
349
|
+
return {
|
|
350
|
+
...prevState,
|
|
386
351
|
videoLength: refVideoPlayer.current.duration,
|
|
387
352
|
videoBufferEnd: refVideoPlayer.current.buffered.length === 0 ? 0 : refVideoPlayer.current.buffered.end(refVideoPlayer.current.buffered.length - 1),
|
|
388
353
|
videoUnplayed: refVideoPlayer.current.played.length === 0 && !prevState.videoQualityChanged
|
|
@@ -391,25 +356,26 @@ const Video = props => {
|
|
|
391
356
|
const {
|
|
392
357
|
videoQualityChanged,
|
|
393
358
|
videoIsPlaying
|
|
394
|
-
} = videoPlayerState;
|
|
359
|
+
} = videoPlayerState;
|
|
395
360
|
|
|
361
|
+
// Prevents an IE 11 bug where the video will not continue playing after a quality switch
|
|
396
362
|
if (videoQualityChanged && videoIsPlaying) {
|
|
397
363
|
setPlaying(true);
|
|
398
364
|
}
|
|
399
365
|
};
|
|
400
|
-
|
|
401
366
|
const clearInactivityTimer = () => {
|
|
402
|
-
setVideoPlayerState(prevState => ({
|
|
367
|
+
setVideoPlayerState(prevState => ({
|
|
368
|
+
...prevState,
|
|
403
369
|
mouseInactive: false
|
|
404
370
|
}));
|
|
405
371
|
clearTimeout(inactivityTimer);
|
|
406
372
|
};
|
|
407
|
-
|
|
408
373
|
const setAsBuffering = () => {
|
|
409
374
|
// Prevent IE infinite buffer bug with readyState
|
|
410
375
|
if (refVideoPlayer.current.readyState < 4) {
|
|
411
376
|
clearInactivityTimer();
|
|
412
|
-
setVideoPlayerState(prevState => ({
|
|
377
|
+
setVideoPlayerState(prevState => ({
|
|
378
|
+
...prevState,
|
|
413
379
|
videoIsPlaying: false,
|
|
414
380
|
videoIsBuffering: true,
|
|
415
381
|
mouseInactive: true
|
|
@@ -417,22 +383,20 @@ const Video = props => {
|
|
|
417
383
|
setPlaying(false);
|
|
418
384
|
}
|
|
419
385
|
};
|
|
420
|
-
|
|
421
386
|
const playAfterBuffer = () => {
|
|
422
387
|
const {
|
|
423
388
|
videoIsBuffering,
|
|
424
389
|
videoCurrentTime,
|
|
425
390
|
videoQualityChanged
|
|
426
391
|
} = videoPlayerState;
|
|
427
|
-
|
|
428
392
|
if (videoIsBuffering && videoCurrentTime !== -1 && !videoQualityChanged) {
|
|
429
393
|
setPlaying(true);
|
|
430
|
-
setVideoPlayerState(prevState => ({
|
|
394
|
+
setVideoPlayerState(prevState => ({
|
|
395
|
+
...prevState,
|
|
431
396
|
videoIsBuffering: false
|
|
432
397
|
}));
|
|
433
398
|
}
|
|
434
399
|
};
|
|
435
|
-
|
|
436
400
|
const resetInactivityTimer = () => {
|
|
437
401
|
clearInactivityTimer();
|
|
438
402
|
const {
|
|
@@ -440,20 +404,20 @@ const Video = props => {
|
|
|
440
404
|
videoIsPlaying,
|
|
441
405
|
mouseOnControlBar
|
|
442
406
|
} = videoPlayerState;
|
|
443
|
-
|
|
444
407
|
if (!videoQualityChanged && videoIsPlaying) {
|
|
445
408
|
inactivityTimer = setTimeout(() => {
|
|
446
409
|
if (!mouseOnControlBar) {
|
|
447
|
-
setVideoPlayerState(prevState => ({
|
|
410
|
+
setVideoPlayerState(prevState => ({
|
|
411
|
+
...prevState,
|
|
448
412
|
mouseInactive: true
|
|
449
413
|
}));
|
|
450
414
|
}
|
|
451
415
|
}, playerOptions.mouseTimeout);
|
|
452
416
|
}
|
|
453
417
|
};
|
|
454
|
-
|
|
455
418
|
const setAsPlaying = () => {
|
|
456
|
-
setVideoPlayerState(prevState => ({
|
|
419
|
+
setVideoPlayerState(prevState => ({
|
|
420
|
+
...prevState,
|
|
457
421
|
videoIsPlaying: true,
|
|
458
422
|
videoIsBuffering: false,
|
|
459
423
|
videoEnded: false,
|
|
@@ -463,147 +427,134 @@ const Video = props => {
|
|
|
463
427
|
const {
|
|
464
428
|
analyticsTracking
|
|
465
429
|
} = props;
|
|
466
|
-
|
|
467
430
|
if (analyticsTracking) {
|
|
468
431
|
updateAnalyticsData();
|
|
469
432
|
}
|
|
470
|
-
|
|
471
433
|
resetInactivityTimer();
|
|
472
434
|
};
|
|
473
|
-
|
|
474
435
|
const setAsPaused = () => {
|
|
475
436
|
clearInactivityTimer();
|
|
476
|
-
setVideoPlayerState(prevState => ({
|
|
437
|
+
setVideoPlayerState(prevState => ({
|
|
438
|
+
...prevState,
|
|
477
439
|
videoIsPlaying: false
|
|
478
440
|
}));
|
|
479
441
|
const {
|
|
480
442
|
analyticsTracking
|
|
481
443
|
} = props;
|
|
482
|
-
|
|
483
444
|
if (analyticsTracking) {
|
|
484
445
|
updateAnalyticsData();
|
|
485
446
|
}
|
|
486
447
|
};
|
|
487
|
-
|
|
488
448
|
const returnFromEndState = () => {
|
|
489
449
|
resetInactivityTimer();
|
|
490
|
-
setVideoPlayerState(prevState => ({
|
|
450
|
+
setVideoPlayerState(prevState => ({
|
|
451
|
+
...prevState,
|
|
491
452
|
videoEnded: false
|
|
492
453
|
}));
|
|
493
454
|
};
|
|
494
|
-
|
|
495
455
|
const setAsEnded = () => {
|
|
496
|
-
setVideoPlayerState(prevState => ({
|
|
456
|
+
setVideoPlayerState(prevState => ({
|
|
457
|
+
...prevState,
|
|
497
458
|
videoIsPlaying: false,
|
|
498
459
|
videoEnded: true
|
|
499
460
|
}));
|
|
500
461
|
clearInactivityTimer();
|
|
501
462
|
};
|
|
502
|
-
|
|
503
463
|
const updateBufferProgress = () => {
|
|
504
464
|
const {
|
|
505
465
|
videoCurrentTime,
|
|
506
466
|
videoQualityChanged
|
|
507
467
|
} = videoPlayerState;
|
|
508
468
|
const videoPlayer = refVideoPlayer.current;
|
|
509
|
-
|
|
510
469
|
if (videoPlayer && videoPlayer.readyState >= 2) {
|
|
511
470
|
const {
|
|
512
471
|
buffered
|
|
513
472
|
} = videoPlayer;
|
|
514
|
-
setVideoPlayerState(prevState => ({
|
|
473
|
+
setVideoPlayerState(prevState => ({
|
|
474
|
+
...prevState,
|
|
515
475
|
videoBufferEnd: buffered.length === 0 ? 0 : buffered.end(buffered.length - 1)
|
|
516
476
|
}));
|
|
517
477
|
} else if (videoCurrentTime !== -1 && !videoQualityChanged && !videoPlayer) {
|
|
518
|
-
setVideoPlayerState(prevState => ({
|
|
478
|
+
setVideoPlayerState(prevState => ({
|
|
479
|
+
...prevState,
|
|
519
480
|
videoIsPlaying: false,
|
|
520
481
|
videoIsBuffering: true
|
|
521
482
|
}));
|
|
522
483
|
}
|
|
523
484
|
};
|
|
524
|
-
|
|
525
485
|
const updateVolumeState = () => {
|
|
526
486
|
resetInactivityTimer();
|
|
527
487
|
const videoPlayer = refVideoPlayer.current;
|
|
528
|
-
setVideoPlayerState(prevState => ({
|
|
488
|
+
setVideoPlayerState(prevState => ({
|
|
489
|
+
...prevState,
|
|
529
490
|
videoCurrentVolume: videoPlayer.volume,
|
|
530
491
|
videoIsMuted: videoPlayer.muted
|
|
531
492
|
}));
|
|
532
493
|
};
|
|
533
|
-
|
|
534
494
|
const getPlayerWidth = () => {
|
|
535
|
-
setVideoPlayerState(prevState => ({
|
|
495
|
+
setVideoPlayerState(prevState => ({
|
|
496
|
+
...prevState,
|
|
536
497
|
videoPlayerWidth: refVideoPlayerContainer.current.offsetWidth
|
|
537
498
|
}));
|
|
538
499
|
};
|
|
539
|
-
|
|
540
500
|
const setMouseOnControlBar = isOver => {
|
|
541
|
-
setVideoPlayerState(prevState => ({
|
|
501
|
+
setVideoPlayerState(prevState => ({
|
|
502
|
+
...prevState,
|
|
542
503
|
mouseOnControlBar: isOver
|
|
543
504
|
}));
|
|
544
505
|
};
|
|
545
|
-
|
|
546
506
|
const togglePlayPause = () => {
|
|
547
507
|
const {
|
|
548
508
|
videoIsPlaying
|
|
549
509
|
} = videoPlayerState;
|
|
550
510
|
setPlaying(!videoIsPlaying);
|
|
551
511
|
};
|
|
552
|
-
|
|
553
512
|
const setTextTracks = trackNumber => {
|
|
554
513
|
const {
|
|
555
514
|
textTracks
|
|
556
515
|
} = refVideoPlayer.current;
|
|
557
|
-
|
|
558
516
|
for (let i = 0; i < textTracks.length; i += 1) {
|
|
559
517
|
textTracks[i].mode = i === trackNumber ? 'showing' : 'hidden';
|
|
560
518
|
}
|
|
561
|
-
|
|
562
|
-
|
|
519
|
+
setVideoPlayerState(prevState => ({
|
|
520
|
+
...prevState,
|
|
563
521
|
selectedTextTrack: trackNumber
|
|
564
522
|
}));
|
|
565
523
|
};
|
|
566
|
-
|
|
567
524
|
const beginVideo = () => {
|
|
568
525
|
setTextTracks(-1);
|
|
569
526
|
setPlaying(true);
|
|
570
527
|
refVideoPlayerContainer.current.focus();
|
|
571
528
|
};
|
|
572
|
-
|
|
573
529
|
const closeSubMenus = () => {
|
|
574
|
-
setVideoPlayerState(prevState => ({
|
|
530
|
+
setVideoPlayerState(prevState => ({
|
|
531
|
+
...prevState,
|
|
575
532
|
qualityMenuOpen: false,
|
|
576
533
|
captionsMenuOpen: false
|
|
577
534
|
}));
|
|
578
535
|
};
|
|
579
|
-
|
|
580
536
|
const incrementSeek = seconds => {
|
|
581
537
|
refVideoPlayer.current.currentTime += seconds;
|
|
582
538
|
};
|
|
583
|
-
|
|
584
539
|
const replayVideo = async () => {
|
|
585
540
|
setSeek(0);
|
|
586
541
|
togglePlayPause();
|
|
587
542
|
};
|
|
588
|
-
|
|
589
543
|
const incrementVolume = amount => {
|
|
590
544
|
refVideoPlayer.current.volume += amount;
|
|
591
545
|
};
|
|
592
|
-
|
|
593
546
|
const setVolume = amount => {
|
|
594
547
|
refVideoPlayer.current.volume = amount;
|
|
595
548
|
};
|
|
596
|
-
|
|
597
549
|
const toggleMute = () => {
|
|
598
550
|
refVideoPlayer.current.muted = !refVideoPlayer.current.muted;
|
|
599
551
|
};
|
|
600
|
-
|
|
601
552
|
const setCaptionsMenuOpen = isOpen => {
|
|
602
|
-
setVideoPlayerState(prevState => ({
|
|
553
|
+
setVideoPlayerState(prevState => ({
|
|
554
|
+
...prevState,
|
|
603
555
|
captionsMenuOpen: isOpen
|
|
604
556
|
}));
|
|
605
557
|
};
|
|
606
|
-
|
|
607
558
|
const toggleFullscreen = () => {
|
|
608
559
|
if (_fscreen.default.fullscreenEnabled) {
|
|
609
560
|
if (_fscreen.default.fullscreenElement === null) {
|
|
@@ -611,18 +562,18 @@ const Video = props => {
|
|
|
611
562
|
} else {
|
|
612
563
|
_fscreen.default.exitFullscreen();
|
|
613
564
|
}
|
|
614
|
-
|
|
615
565
|
setVideoPlayerState(prevState => {
|
|
616
|
-
return {
|
|
566
|
+
return {
|
|
567
|
+
...prevState,
|
|
617
568
|
videoIsFullscreen: !prevState.videoIsFullscreen
|
|
618
569
|
};
|
|
619
570
|
});
|
|
620
571
|
}
|
|
621
572
|
};
|
|
622
|
-
|
|
623
573
|
const setVideoQuality = async newVideoQuality => {
|
|
624
574
|
await setPlaying(false);
|
|
625
|
-
setVideoPlayerState(prevState => ({
|
|
575
|
+
setVideoPlayerState(prevState => ({
|
|
576
|
+
...prevState,
|
|
626
577
|
videoLength: 0,
|
|
627
578
|
videoBufferEnd: 0,
|
|
628
579
|
videoQuality: newVideoQuality,
|
|
@@ -634,192 +585,188 @@ const Video = props => {
|
|
|
634
585
|
resetInactivityTimer();
|
|
635
586
|
setSeek(videoPlayerState.videoCurrentTime);
|
|
636
587
|
};
|
|
637
|
-
|
|
638
588
|
const setQualityMenuOpen = isOpen => {
|
|
639
|
-
setVideoPlayerState(prevState => ({
|
|
589
|
+
setVideoPlayerState(prevState => ({
|
|
590
|
+
...prevState,
|
|
640
591
|
qualityMenuOpen: isOpen
|
|
641
592
|
}));
|
|
642
593
|
};
|
|
643
|
-
|
|
644
594
|
const handleClick = event => {
|
|
645
|
-
resetInactivityTimer();
|
|
646
|
-
// links, e.g. `PreviewCard`, `StoryCard`, etc.
|
|
595
|
+
resetInactivityTimer();
|
|
647
596
|
|
|
597
|
+
// This allows playing videos within components that act like
|
|
598
|
+
// links, e.g. `PreviewCard`, `StoryCard`, etc.
|
|
648
599
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
649
600
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
650
601
|
};
|
|
651
|
-
|
|
652
602
|
const handleKeyboard = event => {
|
|
653
603
|
const {
|
|
654
604
|
videoLength,
|
|
655
605
|
videoCurrentVolume
|
|
656
606
|
} = videoPlayerState;
|
|
657
|
-
const key = event.key || event.keyCode;
|
|
607
|
+
const key = event.key || event.keyCode;
|
|
658
608
|
|
|
609
|
+
// *** Begin Seek & Play Control ****
|
|
659
610
|
if (key === ' ' || key === 32 || key === 'k' || key === 75) {
|
|
660
611
|
event.preventDefault();
|
|
661
612
|
resetInactivityTimer();
|
|
662
613
|
togglePlayPause();
|
|
663
|
-
}
|
|
664
|
-
|
|
614
|
+
}
|
|
665
615
|
|
|
616
|
+
// Disables all keys except for play/pause when in simpleMode
|
|
666
617
|
if (!simpleMode) {
|
|
667
618
|
if (key === 'ArrowRight' || key === 39 || key === '.' || key === 190) {
|
|
668
619
|
resetInactivityTimer();
|
|
669
620
|
incrementSeek(playerOptions.keyboardSeekIncrement);
|
|
670
621
|
}
|
|
671
|
-
|
|
672
622
|
if (key === 'ArrowLeft' || key === 37 || key === ',' || key === 188) {
|
|
673
623
|
resetInactivityTimer();
|
|
674
624
|
incrementSeek(-playerOptions.keyboardSeekIncrement);
|
|
675
625
|
}
|
|
676
|
-
|
|
677
626
|
if (key === '0' || key === 48 || key === 'numpad 0' || key === 96) {
|
|
678
627
|
setSeek(0);
|
|
679
628
|
}
|
|
680
|
-
|
|
681
629
|
if (key === '1' || key === 49 || key === 'numpad 1' || key === 97) {
|
|
682
630
|
setSeek(videoLength * 0.1);
|
|
683
631
|
}
|
|
684
|
-
|
|
685
632
|
if (key === '2' || key === 50 || key === 'numpad 2' || key === 98) {
|
|
686
633
|
setSeek(videoLength * 0.2);
|
|
687
634
|
}
|
|
688
|
-
|
|
689
635
|
if (key === '3' || key === 51 || key === 'numpad 3' || key === 99) {
|
|
690
636
|
setSeek(videoLength * 0.3);
|
|
691
637
|
}
|
|
692
|
-
|
|
693
638
|
if (key === '4' || key === 52 || key === 'numpad 4' || key === 100) {
|
|
694
639
|
setSeek(videoLength * 0.4);
|
|
695
640
|
}
|
|
696
|
-
|
|
697
641
|
if (key === '5' || key === 53 || key === 'numpad 5' || key === 101) {
|
|
698
642
|
setSeek(videoLength * 0.5);
|
|
699
643
|
}
|
|
700
|
-
|
|
701
644
|
if (key === '6' || key === 54 || key === 'numpad 6' || key === 102) {
|
|
702
645
|
setSeek(videoLength * 0.6);
|
|
703
646
|
}
|
|
704
|
-
|
|
705
647
|
if (key === '7' || key === 55 || key === 'numpad 7' || key === 103) {
|
|
706
648
|
setSeek(videoLength * 0.7);
|
|
707
649
|
}
|
|
708
|
-
|
|
709
650
|
if (key === '8' || key === 56 || key === 'numpad 8' || key === 104) {
|
|
710
651
|
setSeek(videoLength * 0.8);
|
|
711
652
|
}
|
|
712
|
-
|
|
713
653
|
if (key === '9' || key === 57 || key === 'numpad 9' || key === 105) {
|
|
714
654
|
setSeek(videoLength * 0.9);
|
|
715
|
-
}
|
|
716
|
-
// **** Begin Volume Control ****
|
|
655
|
+
}
|
|
717
656
|
|
|
657
|
+
// **** End Seek & Play Control ****
|
|
658
|
+
|
|
659
|
+
// **** Begin Volume Control ****
|
|
718
660
|
|
|
719
661
|
const {
|
|
720
662
|
keyboardVolumeIncrement
|
|
721
663
|
} = playerOptions;
|
|
722
|
-
|
|
723
664
|
if (key === 'ArrowUp' || key === 38 || key === '=' || key === 187 || key === 'add' || key === 107) {
|
|
724
665
|
resetInactivityTimer();
|
|
725
|
-
|
|
726
666
|
if (videoCurrentVolume + keyboardVolumeIncrement < 1) {
|
|
727
667
|
incrementVolume(keyboardVolumeIncrement);
|
|
728
668
|
} else {
|
|
729
669
|
setVolume(1);
|
|
730
670
|
}
|
|
731
671
|
}
|
|
732
|
-
|
|
733
672
|
if (key === 'ArrowDown' || key === 40 || key === '-' || key === 189 || key === 'subtract' || key === 109) {
|
|
734
673
|
resetInactivityTimer();
|
|
735
|
-
|
|
736
674
|
if (videoCurrentVolume - keyboardVolumeIncrement > 0) {
|
|
737
675
|
incrementVolume(-keyboardVolumeIncrement);
|
|
738
676
|
} else {
|
|
739
677
|
setVolume(0);
|
|
740
678
|
}
|
|
741
679
|
}
|
|
742
|
-
|
|
743
680
|
if (key === 'm' || key === 77) {
|
|
744
681
|
resetInactivityTimer();
|
|
745
682
|
toggleMute();
|
|
746
683
|
}
|
|
747
|
-
|
|
748
684
|
if (key === 'f' || key === 70) {
|
|
749
685
|
resetInactivityTimer();
|
|
750
686
|
toggleFullscreen();
|
|
751
687
|
}
|
|
752
|
-
|
|
753
688
|
if (key === 'Escape' || key === 27) {
|
|
754
689
|
// Resets focus back to container if user is focused on ControlBar button
|
|
755
690
|
refVideoPlayerContainer.current.focus();
|
|
756
691
|
closeSubMenus();
|
|
757
692
|
}
|
|
758
|
-
|
|
759
693
|
if (key === 'q' || key === 81) {
|
|
760
694
|
refKeyboardInstructions.current.focus();
|
|
761
695
|
}
|
|
762
696
|
}
|
|
763
|
-
};
|
|
764
|
-
|
|
697
|
+
};
|
|
765
698
|
|
|
699
|
+
// Prepares video and caption files
|
|
766
700
|
(0, _react.useEffect)(() => {
|
|
767
|
-
refreshMedia();
|
|
768
|
-
|
|
701
|
+
refreshMedia();
|
|
702
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
703
|
+
}, []);
|
|
769
704
|
|
|
705
|
+
// Initial Setup after loading sources
|
|
770
706
|
(0, _react.useEffect)(() => {
|
|
771
707
|
const {
|
|
772
708
|
loadedSources,
|
|
773
709
|
loadedTracks
|
|
774
710
|
} = videoPlayerState;
|
|
775
|
-
|
|
776
711
|
if (loadedSources && loadedTracks) {
|
|
777
712
|
const {
|
|
778
713
|
beginMuted,
|
|
779
714
|
analyticsTracking,
|
|
780
715
|
videoTitle
|
|
781
716
|
} = props;
|
|
782
|
-
const videoPlayer = refVideoPlayer.current;
|
|
717
|
+
const videoPlayer = refVideoPlayer.current;
|
|
783
718
|
|
|
719
|
+
// Initializes Settings
|
|
784
720
|
videoPlayer.volume = defaultVolume / 100;
|
|
785
721
|
videoPlayer.muted = beginMuted || simpleMode;
|
|
786
|
-
getPlayerWidth();
|
|
722
|
+
getPlayerWidth();
|
|
787
723
|
|
|
788
|
-
|
|
724
|
+
// Reports when the video has completed loading metadata (used for seeking after quality switch)
|
|
725
|
+
videoPlayer.onloadedmetadata = qualitySwitchSeek;
|
|
789
726
|
|
|
790
|
-
|
|
727
|
+
// Reports the video's duration when the video player is ready to play
|
|
728
|
+
videoPlayer.oncanplay = initializeVideoDuration;
|
|
791
729
|
|
|
792
|
-
|
|
730
|
+
// Reports the video's width on resize
|
|
731
|
+
window.addEventListener('resize', getPlayerWidth);
|
|
793
732
|
|
|
794
|
-
|
|
733
|
+
// Reports the current video timestamp
|
|
734
|
+
videoPlayer.ontimeupdate = updateVideoTimestamp;
|
|
795
735
|
|
|
796
|
-
|
|
736
|
+
// Reports when the video has paused due to buffering
|
|
737
|
+
videoPlayer.onwaiting = setAsBuffering;
|
|
797
738
|
|
|
798
|
-
|
|
739
|
+
// Reports the video's latest buffering progress if video player is properly initialized
|
|
740
|
+
videoPlayer.onprogress = updateBufferProgress;
|
|
799
741
|
|
|
800
|
-
|
|
742
|
+
// Reports when the video has recovered from buffering
|
|
743
|
+
videoPlayer.oncanplaythrough = playAfterBuffer;
|
|
801
744
|
|
|
802
|
-
|
|
745
|
+
// Reports when the video has ended
|
|
746
|
+
videoPlayer.onended = setAsEnded;
|
|
803
747
|
|
|
804
|
-
|
|
748
|
+
// Reports when the video is playing and disables the buffer spinner (even if buffering is still needed)
|
|
749
|
+
videoPlayer.onplay = setAsPlaying;
|
|
805
750
|
|
|
806
|
-
|
|
751
|
+
// Reports when the video has been paused
|
|
752
|
+
videoPlayer.onpause = setAsPaused;
|
|
807
753
|
|
|
808
|
-
|
|
754
|
+
// Reports when the video has been seeked
|
|
755
|
+
videoPlayer.onseeked = returnFromEndState;
|
|
809
756
|
|
|
810
|
-
|
|
757
|
+
// Reports when the video's volume has been changed, or if the video has been muted
|
|
758
|
+
videoPlayer.onvolumechange = updateVolumeState;
|
|
811
759
|
|
|
760
|
+
// Video Analytics
|
|
812
761
|
if (analyticsTracking !== undefined && videoTitle === undefined || analyticsTracking === undefined && videoTitle !== undefined) {
|
|
813
762
|
(0, _utils.warn)('Video', 'Both the `analyticsTracking` and `videoTitle` props must be defined in order to return a proper analytics object.');
|
|
814
763
|
}
|
|
815
|
-
|
|
816
764
|
return () => {
|
|
817
765
|
clearInactivityTimer();
|
|
818
766
|
window.removeEventListener('resize', getPlayerWidth);
|
|
819
767
|
clearInterval(videoPlayerState.intervalId);
|
|
820
768
|
};
|
|
821
769
|
}
|
|
822
|
-
|
|
823
770
|
return () => {}; // returning a noop for sake of consistency
|
|
824
771
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
825
772
|
}, [videoPlayerState.loadedSources, videoPlayerState.loadedTracks]);
|
|
@@ -851,7 +798,8 @@ const Video = props => {
|
|
|
851
798
|
as,
|
|
852
799
|
...safeRest
|
|
853
800
|
} = rest;
|
|
854
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(VideoPlayerContainer, {
|
|
801
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(VideoPlayerContainer, {
|
|
802
|
+
...safeRest,
|
|
855
803
|
ref: refVideoPlayerContainer,
|
|
856
804
|
videoBorder: videoBorder,
|
|
857
805
|
borderColor: borderColor,
|
|
@@ -947,95 +895,76 @@ const Video = props => {
|
|
|
947
895
|
})]
|
|
948
896
|
});
|
|
949
897
|
};
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
898
|
+
Video.propTypes = {
|
|
899
|
+
...selectedSystemPropTypes,
|
|
953
900
|
/**
|
|
954
901
|
* An array of objects that defines each video file. See the "Basic Usage" section for more information.
|
|
955
902
|
*/
|
|
956
903
|
sources: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
957
904
|
/** A path to a video file */
|
|
958
905
|
source: _propTypes.default.string.isRequired,
|
|
959
|
-
|
|
960
906
|
/** The video's MIME type (example: `video/mp4`) */
|
|
961
907
|
mediaType: _propTypes.default.string.isRequired,
|
|
962
|
-
|
|
963
908
|
/** The label to be given to this file in the quality selector (example: `1080p`) */
|
|
964
909
|
qualityName: _propTypes.default.string.isRequired,
|
|
965
|
-
|
|
966
910
|
/** A number indicating the video's quality, with 1 being the best, and the number increasing from there as quality degrades */
|
|
967
911
|
qualityRank: _propTypes.default.number.isRequired,
|
|
968
|
-
|
|
969
912
|
/** A boolean that defines its source as a fallback for another source with the same `qualityRank` */
|
|
970
913
|
isFallback: _propTypes.default.bool
|
|
971
914
|
})).isRequired,
|
|
972
|
-
|
|
973
915
|
/**
|
|
974
916
|
* A path of the image that will be displayed on the video's splash screen.
|
|
975
917
|
*/
|
|
976
918
|
posterSrc: _propTypes.default.string.isRequired,
|
|
977
|
-
|
|
978
919
|
/**
|
|
979
920
|
* An array of objects that defines each caption file. See the "Basic Usage" section for more information.
|
|
980
921
|
*/
|
|
981
922
|
tracks: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
982
923
|
/** A path to the track file */
|
|
983
924
|
source: _propTypes.default.string.isRequired,
|
|
984
|
-
|
|
985
925
|
/** The name of the track file as it will appear in the "Captions" dialogue */
|
|
986
926
|
label: _propTypes.default.string.isRequired,
|
|
987
|
-
|
|
988
927
|
/** The track's file type, typically one of "subtitles", "captions", or "descriptions". See [MDN's documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track#Attributes) for more information on these types */
|
|
989
928
|
kind: _propTypes.default.string.isRequired,
|
|
990
|
-
|
|
991
929
|
/** The language of the track file represented as a ISO 639-1 language code */
|
|
992
930
|
language: _propTypes.default.string.isRequired
|
|
993
931
|
})),
|
|
994
|
-
|
|
995
932
|
/**
|
|
996
933
|
* The video's default volume, defined from 1 to 100. Please use the `beginMuted` prop to have the video start silenced.
|
|
997
934
|
*/
|
|
998
935
|
defaultVolume: _propTypes.default.number,
|
|
999
|
-
|
|
1000
936
|
/**
|
|
1001
937
|
* Defines if the video should start muted.
|
|
1002
938
|
*/
|
|
1003
939
|
beginMuted: _propTypes.default.bool,
|
|
1004
|
-
|
|
1005
940
|
/**
|
|
1006
941
|
* The default quality level if the user is on mobile. See the `sources` prop for available quality levels.
|
|
1007
942
|
*/
|
|
1008
943
|
defaultMobileQuality: _propTypes.default.number,
|
|
1009
|
-
|
|
1010
944
|
/**
|
|
1011
945
|
* The default quality level if the user is on desktop. See the `sources` prop for available quality levels.
|
|
1012
946
|
*/
|
|
1013
947
|
defaultDesktopQuality: _propTypes.default.number,
|
|
1014
|
-
|
|
1015
948
|
/**
|
|
1016
949
|
* The video player UI's language as an ISO language code. It currently supports English and French.
|
|
1017
950
|
*/
|
|
1018
951
|
copy: _propTypes.default.oneOf(['en', 'fr']).isRequired,
|
|
1019
|
-
|
|
1020
952
|
/**
|
|
1021
953
|
* Sets the `video` tag's `crossorigin` mode. Please note that content loaded without CORS approval may be insecure.
|
|
1022
954
|
* @since 1.1.0
|
|
1023
955
|
*/
|
|
1024
956
|
crossOrigin: _propTypes.default.oneOf(['anonymous', 'use-credentials']),
|
|
1025
|
-
|
|
1026
957
|
/**
|
|
1027
958
|
* Disables the control bar during playback and reduces the amount of time until the UI hides itself.
|
|
1028
959
|
* For special approved internal uses only.
|
|
1029
960
|
* @since 1.2.0
|
|
1030
961
|
*/
|
|
1031
962
|
simpleMode: _propTypes.default.bool,
|
|
1032
|
-
|
|
1033
963
|
/**
|
|
1034
964
|
* Renders a gainsboro coloured border around the video. Used to seperate the video from the rest of the page if the video's background is the same colour as the container's.
|
|
1035
965
|
* @since 1.2.0
|
|
1036
966
|
*/
|
|
1037
967
|
videoBorder: _propTypes.default.bool,
|
|
1038
|
-
|
|
1039
968
|
/**
|
|
1040
969
|
* A callback function that fires when a customer interacts with Video.
|
|
1041
970
|
* When using `analyticsTracking`, `videoTitle` must also be defined.
|
|
@@ -1049,7 +978,6 @@ Video.propTypes = { ...selectedSystemPropTypes,
|
|
|
1049
978
|
* @param {string} analyticsObject.details The name of the video based on the `videoTitle` prop
|
|
1050
979
|
*/
|
|
1051
980
|
analyticsTracking: _propTypes.default.func,
|
|
1052
|
-
|
|
1053
981
|
/**
|
|
1054
982
|
* The title of the video being rendered. This is used for analytics purposes in conjunction with `analyticsTracking`.
|
|
1055
983
|
* @since 1.3.0
|