@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
|
@@ -11,8 +11,9 @@ import ControlBar from './ControlBar/ControlBar';
|
|
|
11
11
|
import videoText from './videoText';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
14
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
15
15
|
|
|
16
|
+
// TODO: replace with the actual spinner component from UDS
|
|
16
17
|
const VideoPlayerContainer = /*#__PURE__*/styled.div.withConfig({
|
|
17
18
|
displayName: "Video__VideoPlayerContainer",
|
|
18
19
|
componentId: "components-web__sc-12ltnuw-0"
|
|
@@ -79,7 +80,6 @@ const VideoOverlayElementContainer = /*#__PURE__*/styled.div.withConfig({
|
|
|
79
80
|
width: '100%',
|
|
80
81
|
height: '100%'
|
|
81
82
|
});
|
|
82
|
-
|
|
83
83
|
const Video = props => {
|
|
84
84
|
const refVideoPlayer = useRef({});
|
|
85
85
|
const refVideoPlayerContainer = useRef({});
|
|
@@ -113,8 +113,8 @@ const Video = props => {
|
|
|
113
113
|
keyboardVolumeIncrement: 0.1,
|
|
114
114
|
// from 0 to 1
|
|
115
115
|
compactModeThreshold: 700 // in px
|
|
116
|
-
|
|
117
116
|
};
|
|
117
|
+
|
|
118
118
|
const [videoPlayerState, setVideoPlayerState] = useState({
|
|
119
119
|
loadedSources: null,
|
|
120
120
|
loadedTracks: null,
|
|
@@ -139,7 +139,6 @@ const Video = props => {
|
|
|
139
139
|
videoPlayerWidth: 0,
|
|
140
140
|
percentageWatched: 'watched 0%'
|
|
141
141
|
});
|
|
142
|
-
|
|
143
142
|
const generateSources = videoQuality => {
|
|
144
143
|
return sources.map(source => {
|
|
145
144
|
if (source.qualityRank === videoQuality) {
|
|
@@ -149,11 +148,9 @@ const Video = props => {
|
|
|
149
148
|
key: source.source
|
|
150
149
|
});
|
|
151
150
|
}
|
|
152
|
-
|
|
153
151
|
return undefined;
|
|
154
152
|
});
|
|
155
153
|
};
|
|
156
|
-
|
|
157
154
|
const generateTracks = () => {
|
|
158
155
|
return tracks.map(track => {
|
|
159
156
|
return /*#__PURE__*/React.createElement('track', {
|
|
@@ -166,96 +163,91 @@ const Video = props => {
|
|
|
166
163
|
});
|
|
167
164
|
});
|
|
168
165
|
};
|
|
169
|
-
|
|
170
166
|
const refreshMedia = () => {
|
|
171
167
|
const {
|
|
172
168
|
defaultMobileQuality
|
|
173
169
|
} = props;
|
|
174
170
|
const {
|
|
175
171
|
videoUnplayed
|
|
176
|
-
} = videoPlayerState;
|
|
172
|
+
} = videoPlayerState;
|
|
177
173
|
|
|
174
|
+
// Handle mobile check
|
|
178
175
|
const isMobile = navigator && navigator.userAgent.indexOf('Mobi') >= 0;
|
|
179
|
-
|
|
180
176
|
if (videoUnplayed && isMobile) {
|
|
181
|
-
setVideoPlayerState(prevState => ({
|
|
177
|
+
setVideoPlayerState(prevState => ({
|
|
178
|
+
...prevState,
|
|
182
179
|
isMobile,
|
|
183
180
|
videoQuality: isMobile ? defaultMobileQuality : defaultDesktopQuality
|
|
184
181
|
}));
|
|
185
|
-
}
|
|
186
|
-
|
|
182
|
+
}
|
|
187
183
|
|
|
188
|
-
|
|
184
|
+
// Load media
|
|
185
|
+
setVideoPlayerState(prevState => ({
|
|
186
|
+
...prevState,
|
|
189
187
|
loadedSources: generateSources(prevState.videoQuality),
|
|
190
188
|
loadedTracks: tracks && generateTracks()
|
|
191
189
|
}));
|
|
192
190
|
};
|
|
193
|
-
|
|
194
191
|
const percentageBucket = percentValue => {
|
|
195
192
|
if (percentValue < 25) {
|
|
196
193
|
return setVideoPlayerState(prevState => {
|
|
197
194
|
if (prevState !== 'watched 0%') {
|
|
198
|
-
return {
|
|
195
|
+
return {
|
|
196
|
+
...prevState,
|
|
199
197
|
percentageWatched: 'watched 0%'
|
|
200
198
|
};
|
|
201
199
|
}
|
|
202
|
-
|
|
203
200
|
return false;
|
|
204
201
|
});
|
|
205
202
|
}
|
|
206
|
-
|
|
207
203
|
if (percentValue < 50) {
|
|
208
204
|
return setVideoPlayerState(prevState => {
|
|
209
205
|
if (prevState !== 'watched 25%') {
|
|
210
|
-
return {
|
|
206
|
+
return {
|
|
207
|
+
...prevState,
|
|
211
208
|
percentageWatched: 'watched 25%'
|
|
212
209
|
};
|
|
213
210
|
}
|
|
214
|
-
|
|
215
211
|
return false;
|
|
216
212
|
});
|
|
217
213
|
}
|
|
218
|
-
|
|
219
214
|
if (percentValue < 75) {
|
|
220
215
|
return setVideoPlayerState(prevState => {
|
|
221
216
|
if (prevState !== 'watched 50%') {
|
|
222
|
-
return {
|
|
217
|
+
return {
|
|
218
|
+
...prevState,
|
|
223
219
|
percentageWatched: 'watched 50%'
|
|
224
220
|
};
|
|
225
221
|
}
|
|
226
|
-
|
|
227
222
|
return false;
|
|
228
223
|
});
|
|
229
224
|
}
|
|
230
|
-
|
|
231
225
|
if (percentValue < 100) {
|
|
232
226
|
return setVideoPlayerState(prevState => {
|
|
233
227
|
if (prevState !== 'watched 75%') {
|
|
234
|
-
return {
|
|
228
|
+
return {
|
|
229
|
+
...prevState,
|
|
235
230
|
percentageWatched: 'watched 75%'
|
|
236
231
|
};
|
|
237
232
|
}
|
|
238
|
-
|
|
239
233
|
return false;
|
|
240
234
|
});
|
|
241
235
|
}
|
|
242
|
-
|
|
243
236
|
if (percentValue === 100) {
|
|
244
237
|
return setVideoPlayerState(prevState => {
|
|
245
238
|
if (prevState !== 'watched 100%') {
|
|
246
|
-
return {
|
|
239
|
+
return {
|
|
240
|
+
...prevState,
|
|
247
241
|
percentageWatched: 'watched 100%'
|
|
248
242
|
};
|
|
249
243
|
}
|
|
250
|
-
|
|
251
244
|
return false;
|
|
252
245
|
});
|
|
253
246
|
}
|
|
254
|
-
|
|
255
247
|
return false;
|
|
256
|
-
};
|
|
257
|
-
|
|
248
|
+
};
|
|
258
249
|
|
|
250
|
+
// required for analytics
|
|
259
251
|
const calculatePercentageWatched = () => {
|
|
260
252
|
const {
|
|
261
253
|
videoCurrentTime,
|
|
@@ -270,7 +262,6 @@ const Video = props => {
|
|
|
270
262
|
percentValue = Math.round(percentValue);
|
|
271
263
|
const previousValue = percentageWatched;
|
|
272
264
|
percentageBucket(percentValue);
|
|
273
|
-
|
|
274
265
|
if (previousValue !== percentageWatched) {
|
|
275
266
|
const analyticsObject = {
|
|
276
267
|
name: 'video tracking',
|
|
@@ -280,20 +271,18 @@ const Video = props => {
|
|
|
280
271
|
analyticsTracking(analyticsObject);
|
|
281
272
|
}
|
|
282
273
|
};
|
|
283
|
-
|
|
284
274
|
const setPlaying = async isPlaying => {
|
|
285
275
|
const videoPlayer = refVideoPlayer.current;
|
|
286
276
|
const {
|
|
287
277
|
analyticsTracking,
|
|
288
278
|
videoTitle
|
|
289
279
|
} = props;
|
|
290
|
-
|
|
291
280
|
if (isPlaying) {
|
|
292
281
|
await videoPlayer.play();
|
|
293
|
-
|
|
294
282
|
if (analyticsTracking !== undefined && videoTitle) {
|
|
295
283
|
const intervalId = setInterval(calculatePercentageWatched, 300);
|
|
296
|
-
setVideoPlayerState(prevState => ({
|
|
284
|
+
setVideoPlayerState(prevState => ({
|
|
285
|
+
...prevState,
|
|
297
286
|
intervalId
|
|
298
287
|
}));
|
|
299
288
|
}
|
|
@@ -305,7 +294,6 @@ const Video = props => {
|
|
|
305
294
|
clearInterval(intervalId);
|
|
306
295
|
}
|
|
307
296
|
};
|
|
308
|
-
|
|
309
297
|
const updateAnalyticsData = () => {
|
|
310
298
|
const {
|
|
311
299
|
videoTitle,
|
|
@@ -320,40 +308,38 @@ const Video = props => {
|
|
|
320
308
|
details: videoTitle
|
|
321
309
|
};
|
|
322
310
|
analyticsObject.action = videoIsPlaying ? 'play' : 'pause';
|
|
323
|
-
|
|
324
311
|
if (percentageWatched !== 'watched 100%') {
|
|
325
312
|
analyticsTracking(analyticsObject);
|
|
326
313
|
}
|
|
327
314
|
};
|
|
328
|
-
|
|
329
315
|
const setSeek = seconds => {
|
|
330
316
|
refVideoPlayer.current.currentTime = seconds;
|
|
331
317
|
};
|
|
332
|
-
|
|
333
318
|
const qualitySwitchSeek = () => {
|
|
334
319
|
const {
|
|
335
320
|
videoCurrentTime
|
|
336
|
-
} = videoPlayerState;
|
|
321
|
+
} = videoPlayerState;
|
|
337
322
|
|
|
338
|
-
|
|
323
|
+
// The following setState gets the video length on the splash screen in iOS
|
|
324
|
+
setVideoPlayerState(prevState => ({
|
|
325
|
+
...prevState,
|
|
339
326
|
videoLength: refVideoPlayer.current.duration
|
|
340
327
|
}));
|
|
341
|
-
|
|
342
328
|
if (videoCurrentTime > -1) {
|
|
343
329
|
setSeek(videoCurrentTime);
|
|
344
330
|
}
|
|
345
331
|
};
|
|
346
|
-
|
|
347
332
|
const updateVideoTimestamp = () => {
|
|
348
|
-
setVideoPlayerState(prevState => ({
|
|
333
|
+
setVideoPlayerState(prevState => ({
|
|
334
|
+
...prevState,
|
|
349
335
|
videoCurrentTime: refVideoPlayer.current.currentTime
|
|
350
336
|
}));
|
|
351
337
|
};
|
|
352
|
-
|
|
353
338
|
const initializeVideoDuration = () => {
|
|
354
339
|
// This will run on every load() call, meaning it will also run when video quality is changed.
|
|
355
340
|
setVideoPlayerState(prevState => {
|
|
356
|
-
return {
|
|
341
|
+
return {
|
|
342
|
+
...prevState,
|
|
357
343
|
videoLength: refVideoPlayer.current.duration,
|
|
358
344
|
videoBufferEnd: refVideoPlayer.current.buffered.length === 0 ? 0 : refVideoPlayer.current.buffered.end(refVideoPlayer.current.buffered.length - 1),
|
|
359
345
|
videoUnplayed: refVideoPlayer.current.played.length === 0 && !prevState.videoQualityChanged
|
|
@@ -362,25 +348,26 @@ const Video = props => {
|
|
|
362
348
|
const {
|
|
363
349
|
videoQualityChanged,
|
|
364
350
|
videoIsPlaying
|
|
365
|
-
} = videoPlayerState;
|
|
351
|
+
} = videoPlayerState;
|
|
366
352
|
|
|
353
|
+
// Prevents an IE 11 bug where the video will not continue playing after a quality switch
|
|
367
354
|
if (videoQualityChanged && videoIsPlaying) {
|
|
368
355
|
setPlaying(true);
|
|
369
356
|
}
|
|
370
357
|
};
|
|
371
|
-
|
|
372
358
|
const clearInactivityTimer = () => {
|
|
373
|
-
setVideoPlayerState(prevState => ({
|
|
359
|
+
setVideoPlayerState(prevState => ({
|
|
360
|
+
...prevState,
|
|
374
361
|
mouseInactive: false
|
|
375
362
|
}));
|
|
376
363
|
clearTimeout(inactivityTimer);
|
|
377
364
|
};
|
|
378
|
-
|
|
379
365
|
const setAsBuffering = () => {
|
|
380
366
|
// Prevent IE infinite buffer bug with readyState
|
|
381
367
|
if (refVideoPlayer.current.readyState < 4) {
|
|
382
368
|
clearInactivityTimer();
|
|
383
|
-
setVideoPlayerState(prevState => ({
|
|
369
|
+
setVideoPlayerState(prevState => ({
|
|
370
|
+
...prevState,
|
|
384
371
|
videoIsPlaying: false,
|
|
385
372
|
videoIsBuffering: true,
|
|
386
373
|
mouseInactive: true
|
|
@@ -388,22 +375,20 @@ const Video = props => {
|
|
|
388
375
|
setPlaying(false);
|
|
389
376
|
}
|
|
390
377
|
};
|
|
391
|
-
|
|
392
378
|
const playAfterBuffer = () => {
|
|
393
379
|
const {
|
|
394
380
|
videoIsBuffering,
|
|
395
381
|
videoCurrentTime,
|
|
396
382
|
videoQualityChanged
|
|
397
383
|
} = videoPlayerState;
|
|
398
|
-
|
|
399
384
|
if (videoIsBuffering && videoCurrentTime !== -1 && !videoQualityChanged) {
|
|
400
385
|
setPlaying(true);
|
|
401
|
-
setVideoPlayerState(prevState => ({
|
|
386
|
+
setVideoPlayerState(prevState => ({
|
|
387
|
+
...prevState,
|
|
402
388
|
videoIsBuffering: false
|
|
403
389
|
}));
|
|
404
390
|
}
|
|
405
391
|
};
|
|
406
|
-
|
|
407
392
|
const resetInactivityTimer = () => {
|
|
408
393
|
clearInactivityTimer();
|
|
409
394
|
const {
|
|
@@ -411,20 +396,20 @@ const Video = props => {
|
|
|
411
396
|
videoIsPlaying,
|
|
412
397
|
mouseOnControlBar
|
|
413
398
|
} = videoPlayerState;
|
|
414
|
-
|
|
415
399
|
if (!videoQualityChanged && videoIsPlaying) {
|
|
416
400
|
inactivityTimer = setTimeout(() => {
|
|
417
401
|
if (!mouseOnControlBar) {
|
|
418
|
-
setVideoPlayerState(prevState => ({
|
|
402
|
+
setVideoPlayerState(prevState => ({
|
|
403
|
+
...prevState,
|
|
419
404
|
mouseInactive: true
|
|
420
405
|
}));
|
|
421
406
|
}
|
|
422
407
|
}, playerOptions.mouseTimeout);
|
|
423
408
|
}
|
|
424
409
|
};
|
|
425
|
-
|
|
426
410
|
const setAsPlaying = () => {
|
|
427
|
-
setVideoPlayerState(prevState => ({
|
|
411
|
+
setVideoPlayerState(prevState => ({
|
|
412
|
+
...prevState,
|
|
428
413
|
videoIsPlaying: true,
|
|
429
414
|
videoIsBuffering: false,
|
|
430
415
|
videoEnded: false,
|
|
@@ -434,147 +419,134 @@ const Video = props => {
|
|
|
434
419
|
const {
|
|
435
420
|
analyticsTracking
|
|
436
421
|
} = props;
|
|
437
|
-
|
|
438
422
|
if (analyticsTracking) {
|
|
439
423
|
updateAnalyticsData();
|
|
440
424
|
}
|
|
441
|
-
|
|
442
425
|
resetInactivityTimer();
|
|
443
426
|
};
|
|
444
|
-
|
|
445
427
|
const setAsPaused = () => {
|
|
446
428
|
clearInactivityTimer();
|
|
447
|
-
setVideoPlayerState(prevState => ({
|
|
429
|
+
setVideoPlayerState(prevState => ({
|
|
430
|
+
...prevState,
|
|
448
431
|
videoIsPlaying: false
|
|
449
432
|
}));
|
|
450
433
|
const {
|
|
451
434
|
analyticsTracking
|
|
452
435
|
} = props;
|
|
453
|
-
|
|
454
436
|
if (analyticsTracking) {
|
|
455
437
|
updateAnalyticsData();
|
|
456
438
|
}
|
|
457
439
|
};
|
|
458
|
-
|
|
459
440
|
const returnFromEndState = () => {
|
|
460
441
|
resetInactivityTimer();
|
|
461
|
-
setVideoPlayerState(prevState => ({
|
|
442
|
+
setVideoPlayerState(prevState => ({
|
|
443
|
+
...prevState,
|
|
462
444
|
videoEnded: false
|
|
463
445
|
}));
|
|
464
446
|
};
|
|
465
|
-
|
|
466
447
|
const setAsEnded = () => {
|
|
467
|
-
setVideoPlayerState(prevState => ({
|
|
448
|
+
setVideoPlayerState(prevState => ({
|
|
449
|
+
...prevState,
|
|
468
450
|
videoIsPlaying: false,
|
|
469
451
|
videoEnded: true
|
|
470
452
|
}));
|
|
471
453
|
clearInactivityTimer();
|
|
472
454
|
};
|
|
473
|
-
|
|
474
455
|
const updateBufferProgress = () => {
|
|
475
456
|
const {
|
|
476
457
|
videoCurrentTime,
|
|
477
458
|
videoQualityChanged
|
|
478
459
|
} = videoPlayerState;
|
|
479
460
|
const videoPlayer = refVideoPlayer.current;
|
|
480
|
-
|
|
481
461
|
if (videoPlayer && videoPlayer.readyState >= 2) {
|
|
482
462
|
const {
|
|
483
463
|
buffered
|
|
484
464
|
} = videoPlayer;
|
|
485
|
-
setVideoPlayerState(prevState => ({
|
|
465
|
+
setVideoPlayerState(prevState => ({
|
|
466
|
+
...prevState,
|
|
486
467
|
videoBufferEnd: buffered.length === 0 ? 0 : buffered.end(buffered.length - 1)
|
|
487
468
|
}));
|
|
488
469
|
} else if (videoCurrentTime !== -1 && !videoQualityChanged && !videoPlayer) {
|
|
489
|
-
setVideoPlayerState(prevState => ({
|
|
470
|
+
setVideoPlayerState(prevState => ({
|
|
471
|
+
...prevState,
|
|
490
472
|
videoIsPlaying: false,
|
|
491
473
|
videoIsBuffering: true
|
|
492
474
|
}));
|
|
493
475
|
}
|
|
494
476
|
};
|
|
495
|
-
|
|
496
477
|
const updateVolumeState = () => {
|
|
497
478
|
resetInactivityTimer();
|
|
498
479
|
const videoPlayer = refVideoPlayer.current;
|
|
499
|
-
setVideoPlayerState(prevState => ({
|
|
480
|
+
setVideoPlayerState(prevState => ({
|
|
481
|
+
...prevState,
|
|
500
482
|
videoCurrentVolume: videoPlayer.volume,
|
|
501
483
|
videoIsMuted: videoPlayer.muted
|
|
502
484
|
}));
|
|
503
485
|
};
|
|
504
|
-
|
|
505
486
|
const getPlayerWidth = () => {
|
|
506
|
-
setVideoPlayerState(prevState => ({
|
|
487
|
+
setVideoPlayerState(prevState => ({
|
|
488
|
+
...prevState,
|
|
507
489
|
videoPlayerWidth: refVideoPlayerContainer.current.offsetWidth
|
|
508
490
|
}));
|
|
509
491
|
};
|
|
510
|
-
|
|
511
492
|
const setMouseOnControlBar = isOver => {
|
|
512
|
-
setVideoPlayerState(prevState => ({
|
|
493
|
+
setVideoPlayerState(prevState => ({
|
|
494
|
+
...prevState,
|
|
513
495
|
mouseOnControlBar: isOver
|
|
514
496
|
}));
|
|
515
497
|
};
|
|
516
|
-
|
|
517
498
|
const togglePlayPause = () => {
|
|
518
499
|
const {
|
|
519
500
|
videoIsPlaying
|
|
520
501
|
} = videoPlayerState;
|
|
521
502
|
setPlaying(!videoIsPlaying);
|
|
522
503
|
};
|
|
523
|
-
|
|
524
504
|
const setTextTracks = trackNumber => {
|
|
525
505
|
const {
|
|
526
506
|
textTracks
|
|
527
507
|
} = refVideoPlayer.current;
|
|
528
|
-
|
|
529
508
|
for (let i = 0; i < textTracks.length; i += 1) {
|
|
530
509
|
textTracks[i].mode = i === trackNumber ? 'showing' : 'hidden';
|
|
531
510
|
}
|
|
532
|
-
|
|
533
|
-
|
|
511
|
+
setVideoPlayerState(prevState => ({
|
|
512
|
+
...prevState,
|
|
534
513
|
selectedTextTrack: trackNumber
|
|
535
514
|
}));
|
|
536
515
|
};
|
|
537
|
-
|
|
538
516
|
const beginVideo = () => {
|
|
539
517
|
setTextTracks(-1);
|
|
540
518
|
setPlaying(true);
|
|
541
519
|
refVideoPlayerContainer.current.focus();
|
|
542
520
|
};
|
|
543
|
-
|
|
544
521
|
const closeSubMenus = () => {
|
|
545
|
-
setVideoPlayerState(prevState => ({
|
|
522
|
+
setVideoPlayerState(prevState => ({
|
|
523
|
+
...prevState,
|
|
546
524
|
qualityMenuOpen: false,
|
|
547
525
|
captionsMenuOpen: false
|
|
548
526
|
}));
|
|
549
527
|
};
|
|
550
|
-
|
|
551
528
|
const incrementSeek = seconds => {
|
|
552
529
|
refVideoPlayer.current.currentTime += seconds;
|
|
553
530
|
};
|
|
554
|
-
|
|
555
531
|
const replayVideo = async () => {
|
|
556
532
|
setSeek(0);
|
|
557
533
|
togglePlayPause();
|
|
558
534
|
};
|
|
559
|
-
|
|
560
535
|
const incrementVolume = amount => {
|
|
561
536
|
refVideoPlayer.current.volume += amount;
|
|
562
537
|
};
|
|
563
|
-
|
|
564
538
|
const setVolume = amount => {
|
|
565
539
|
refVideoPlayer.current.volume = amount;
|
|
566
540
|
};
|
|
567
|
-
|
|
568
541
|
const toggleMute = () => {
|
|
569
542
|
refVideoPlayer.current.muted = !refVideoPlayer.current.muted;
|
|
570
543
|
};
|
|
571
|
-
|
|
572
544
|
const setCaptionsMenuOpen = isOpen => {
|
|
573
|
-
setVideoPlayerState(prevState => ({
|
|
545
|
+
setVideoPlayerState(prevState => ({
|
|
546
|
+
...prevState,
|
|
574
547
|
captionsMenuOpen: isOpen
|
|
575
548
|
}));
|
|
576
549
|
};
|
|
577
|
-
|
|
578
550
|
const toggleFullscreen = () => {
|
|
579
551
|
if (fscreen.fullscreenEnabled) {
|
|
580
552
|
if (fscreen.fullscreenElement === null) {
|
|
@@ -582,18 +554,18 @@ const Video = props => {
|
|
|
582
554
|
} else {
|
|
583
555
|
fscreen.exitFullscreen();
|
|
584
556
|
}
|
|
585
|
-
|
|
586
557
|
setVideoPlayerState(prevState => {
|
|
587
|
-
return {
|
|
558
|
+
return {
|
|
559
|
+
...prevState,
|
|
588
560
|
videoIsFullscreen: !prevState.videoIsFullscreen
|
|
589
561
|
};
|
|
590
562
|
});
|
|
591
563
|
}
|
|
592
564
|
};
|
|
593
|
-
|
|
594
565
|
const setVideoQuality = async newVideoQuality => {
|
|
595
566
|
await setPlaying(false);
|
|
596
|
-
setVideoPlayerState(prevState => ({
|
|
567
|
+
setVideoPlayerState(prevState => ({
|
|
568
|
+
...prevState,
|
|
597
569
|
videoLength: 0,
|
|
598
570
|
videoBufferEnd: 0,
|
|
599
571
|
videoQuality: newVideoQuality,
|
|
@@ -605,192 +577,188 @@ const Video = props => {
|
|
|
605
577
|
resetInactivityTimer();
|
|
606
578
|
setSeek(videoPlayerState.videoCurrentTime);
|
|
607
579
|
};
|
|
608
|
-
|
|
609
580
|
const setQualityMenuOpen = isOpen => {
|
|
610
|
-
setVideoPlayerState(prevState => ({
|
|
581
|
+
setVideoPlayerState(prevState => ({
|
|
582
|
+
...prevState,
|
|
611
583
|
qualityMenuOpen: isOpen
|
|
612
584
|
}));
|
|
613
585
|
};
|
|
614
|
-
|
|
615
586
|
const handleClick = event => {
|
|
616
|
-
resetInactivityTimer();
|
|
617
|
-
// links, e.g. `PreviewCard`, `StoryCard`, etc.
|
|
587
|
+
resetInactivityTimer();
|
|
618
588
|
|
|
589
|
+
// This allows playing videos within components that act like
|
|
590
|
+
// links, e.g. `PreviewCard`, `StoryCard`, etc.
|
|
619
591
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
620
592
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
621
593
|
};
|
|
622
|
-
|
|
623
594
|
const handleKeyboard = event => {
|
|
624
595
|
const {
|
|
625
596
|
videoLength,
|
|
626
597
|
videoCurrentVolume
|
|
627
598
|
} = videoPlayerState;
|
|
628
|
-
const key = event.key || event.keyCode;
|
|
599
|
+
const key = event.key || event.keyCode;
|
|
629
600
|
|
|
601
|
+
// *** Begin Seek & Play Control ****
|
|
630
602
|
if (key === ' ' || key === 32 || key === 'k' || key === 75) {
|
|
631
603
|
event.preventDefault();
|
|
632
604
|
resetInactivityTimer();
|
|
633
605
|
togglePlayPause();
|
|
634
|
-
}
|
|
635
|
-
|
|
606
|
+
}
|
|
636
607
|
|
|
608
|
+
// Disables all keys except for play/pause when in simpleMode
|
|
637
609
|
if (!simpleMode) {
|
|
638
610
|
if (key === 'ArrowRight' || key === 39 || key === '.' || key === 190) {
|
|
639
611
|
resetInactivityTimer();
|
|
640
612
|
incrementSeek(playerOptions.keyboardSeekIncrement);
|
|
641
613
|
}
|
|
642
|
-
|
|
643
614
|
if (key === 'ArrowLeft' || key === 37 || key === ',' || key === 188) {
|
|
644
615
|
resetInactivityTimer();
|
|
645
616
|
incrementSeek(-playerOptions.keyboardSeekIncrement);
|
|
646
617
|
}
|
|
647
|
-
|
|
648
618
|
if (key === '0' || key === 48 || key === 'numpad 0' || key === 96) {
|
|
649
619
|
setSeek(0);
|
|
650
620
|
}
|
|
651
|
-
|
|
652
621
|
if (key === '1' || key === 49 || key === 'numpad 1' || key === 97) {
|
|
653
622
|
setSeek(videoLength * 0.1);
|
|
654
623
|
}
|
|
655
|
-
|
|
656
624
|
if (key === '2' || key === 50 || key === 'numpad 2' || key === 98) {
|
|
657
625
|
setSeek(videoLength * 0.2);
|
|
658
626
|
}
|
|
659
|
-
|
|
660
627
|
if (key === '3' || key === 51 || key === 'numpad 3' || key === 99) {
|
|
661
628
|
setSeek(videoLength * 0.3);
|
|
662
629
|
}
|
|
663
|
-
|
|
664
630
|
if (key === '4' || key === 52 || key === 'numpad 4' || key === 100) {
|
|
665
631
|
setSeek(videoLength * 0.4);
|
|
666
632
|
}
|
|
667
|
-
|
|
668
633
|
if (key === '5' || key === 53 || key === 'numpad 5' || key === 101) {
|
|
669
634
|
setSeek(videoLength * 0.5);
|
|
670
635
|
}
|
|
671
|
-
|
|
672
636
|
if (key === '6' || key === 54 || key === 'numpad 6' || key === 102) {
|
|
673
637
|
setSeek(videoLength * 0.6);
|
|
674
638
|
}
|
|
675
|
-
|
|
676
639
|
if (key === '7' || key === 55 || key === 'numpad 7' || key === 103) {
|
|
677
640
|
setSeek(videoLength * 0.7);
|
|
678
641
|
}
|
|
679
|
-
|
|
680
642
|
if (key === '8' || key === 56 || key === 'numpad 8' || key === 104) {
|
|
681
643
|
setSeek(videoLength * 0.8);
|
|
682
644
|
}
|
|
683
|
-
|
|
684
645
|
if (key === '9' || key === 57 || key === 'numpad 9' || key === 105) {
|
|
685
646
|
setSeek(videoLength * 0.9);
|
|
686
|
-
}
|
|
687
|
-
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// **** End Seek & Play Control ****
|
|
688
650
|
|
|
651
|
+
// **** Begin Volume Control ****
|
|
689
652
|
|
|
690
653
|
const {
|
|
691
654
|
keyboardVolumeIncrement
|
|
692
655
|
} = playerOptions;
|
|
693
|
-
|
|
694
656
|
if (key === 'ArrowUp' || key === 38 || key === '=' || key === 187 || key === 'add' || key === 107) {
|
|
695
657
|
resetInactivityTimer();
|
|
696
|
-
|
|
697
658
|
if (videoCurrentVolume + keyboardVolumeIncrement < 1) {
|
|
698
659
|
incrementVolume(keyboardVolumeIncrement);
|
|
699
660
|
} else {
|
|
700
661
|
setVolume(1);
|
|
701
662
|
}
|
|
702
663
|
}
|
|
703
|
-
|
|
704
664
|
if (key === 'ArrowDown' || key === 40 || key === '-' || key === 189 || key === 'subtract' || key === 109) {
|
|
705
665
|
resetInactivityTimer();
|
|
706
|
-
|
|
707
666
|
if (videoCurrentVolume - keyboardVolumeIncrement > 0) {
|
|
708
667
|
incrementVolume(-keyboardVolumeIncrement);
|
|
709
668
|
} else {
|
|
710
669
|
setVolume(0);
|
|
711
670
|
}
|
|
712
671
|
}
|
|
713
|
-
|
|
714
672
|
if (key === 'm' || key === 77) {
|
|
715
673
|
resetInactivityTimer();
|
|
716
674
|
toggleMute();
|
|
717
675
|
}
|
|
718
|
-
|
|
719
676
|
if (key === 'f' || key === 70) {
|
|
720
677
|
resetInactivityTimer();
|
|
721
678
|
toggleFullscreen();
|
|
722
679
|
}
|
|
723
|
-
|
|
724
680
|
if (key === 'Escape' || key === 27) {
|
|
725
681
|
// Resets focus back to container if user is focused on ControlBar button
|
|
726
682
|
refVideoPlayerContainer.current.focus();
|
|
727
683
|
closeSubMenus();
|
|
728
684
|
}
|
|
729
|
-
|
|
730
685
|
if (key === 'q' || key === 81) {
|
|
731
686
|
refKeyboardInstructions.current.focus();
|
|
732
687
|
}
|
|
733
688
|
}
|
|
734
|
-
};
|
|
735
|
-
|
|
689
|
+
};
|
|
736
690
|
|
|
691
|
+
// Prepares video and caption files
|
|
737
692
|
useEffect(() => {
|
|
738
|
-
refreshMedia();
|
|
739
|
-
|
|
693
|
+
refreshMedia();
|
|
694
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
695
|
+
}, []);
|
|
740
696
|
|
|
697
|
+
// Initial Setup after loading sources
|
|
741
698
|
useEffect(() => {
|
|
742
699
|
const {
|
|
743
700
|
loadedSources,
|
|
744
701
|
loadedTracks
|
|
745
702
|
} = videoPlayerState;
|
|
746
|
-
|
|
747
703
|
if (loadedSources && loadedTracks) {
|
|
748
704
|
const {
|
|
749
705
|
beginMuted,
|
|
750
706
|
analyticsTracking,
|
|
751
707
|
videoTitle
|
|
752
708
|
} = props;
|
|
753
|
-
const videoPlayer = refVideoPlayer.current;
|
|
709
|
+
const videoPlayer = refVideoPlayer.current;
|
|
754
710
|
|
|
711
|
+
// Initializes Settings
|
|
755
712
|
videoPlayer.volume = defaultVolume / 100;
|
|
756
713
|
videoPlayer.muted = beginMuted || simpleMode;
|
|
757
|
-
getPlayerWidth();
|
|
714
|
+
getPlayerWidth();
|
|
758
715
|
|
|
759
|
-
|
|
716
|
+
// Reports when the video has completed loading metadata (used for seeking after quality switch)
|
|
717
|
+
videoPlayer.onloadedmetadata = qualitySwitchSeek;
|
|
760
718
|
|
|
761
|
-
|
|
719
|
+
// Reports the video's duration when the video player is ready to play
|
|
720
|
+
videoPlayer.oncanplay = initializeVideoDuration;
|
|
762
721
|
|
|
763
|
-
|
|
722
|
+
// Reports the video's width on resize
|
|
723
|
+
window.addEventListener('resize', getPlayerWidth);
|
|
764
724
|
|
|
765
|
-
|
|
725
|
+
// Reports the current video timestamp
|
|
726
|
+
videoPlayer.ontimeupdate = updateVideoTimestamp;
|
|
766
727
|
|
|
767
|
-
|
|
728
|
+
// Reports when the video has paused due to buffering
|
|
729
|
+
videoPlayer.onwaiting = setAsBuffering;
|
|
768
730
|
|
|
769
|
-
|
|
731
|
+
// Reports the video's latest buffering progress if video player is properly initialized
|
|
732
|
+
videoPlayer.onprogress = updateBufferProgress;
|
|
770
733
|
|
|
771
|
-
|
|
734
|
+
// Reports when the video has recovered from buffering
|
|
735
|
+
videoPlayer.oncanplaythrough = playAfterBuffer;
|
|
772
736
|
|
|
773
|
-
|
|
737
|
+
// Reports when the video has ended
|
|
738
|
+
videoPlayer.onended = setAsEnded;
|
|
774
739
|
|
|
775
|
-
|
|
740
|
+
// Reports when the video is playing and disables the buffer spinner (even if buffering is still needed)
|
|
741
|
+
videoPlayer.onplay = setAsPlaying;
|
|
776
742
|
|
|
777
|
-
|
|
743
|
+
// Reports when the video has been paused
|
|
744
|
+
videoPlayer.onpause = setAsPaused;
|
|
778
745
|
|
|
779
|
-
|
|
746
|
+
// Reports when the video has been seeked
|
|
747
|
+
videoPlayer.onseeked = returnFromEndState;
|
|
780
748
|
|
|
781
|
-
|
|
749
|
+
// Reports when the video's volume has been changed, or if the video has been muted
|
|
750
|
+
videoPlayer.onvolumechange = updateVolumeState;
|
|
782
751
|
|
|
752
|
+
// Video Analytics
|
|
783
753
|
if (analyticsTracking !== undefined && videoTitle === undefined || analyticsTracking === undefined && videoTitle !== undefined) {
|
|
784
754
|
warn('Video', 'Both the `analyticsTracking` and `videoTitle` props must be defined in order to return a proper analytics object.');
|
|
785
755
|
}
|
|
786
|
-
|
|
787
756
|
return () => {
|
|
788
757
|
clearInactivityTimer();
|
|
789
758
|
window.removeEventListener('resize', getPlayerWidth);
|
|
790
759
|
clearInterval(videoPlayerState.intervalId);
|
|
791
760
|
};
|
|
792
761
|
}
|
|
793
|
-
|
|
794
762
|
return () => {}; // returning a noop for sake of consistency
|
|
795
763
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
796
764
|
}, [videoPlayerState.loadedSources, videoPlayerState.loadedTracks]);
|
|
@@ -822,7 +790,8 @@ const Video = props => {
|
|
|
822
790
|
as,
|
|
823
791
|
...safeRest
|
|
824
792
|
} = rest;
|
|
825
|
-
return /*#__PURE__*/_jsxs(VideoPlayerContainer, {
|
|
793
|
+
return /*#__PURE__*/_jsxs(VideoPlayerContainer, {
|
|
794
|
+
...safeRest,
|
|
826
795
|
ref: refVideoPlayerContainer,
|
|
827
796
|
videoBorder: videoBorder,
|
|
828
797
|
borderColor: borderColor,
|
|
@@ -918,95 +887,76 @@ const Video = props => {
|
|
|
918
887
|
})]
|
|
919
888
|
});
|
|
920
889
|
};
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
890
|
+
Video.propTypes = {
|
|
891
|
+
...selectedSystemPropTypes,
|
|
924
892
|
/**
|
|
925
893
|
* An array of objects that defines each video file. See the "Basic Usage" section for more information.
|
|
926
894
|
*/
|
|
927
895
|
sources: PropTypes.arrayOf(PropTypes.shape({
|
|
928
896
|
/** A path to a video file */
|
|
929
897
|
source: PropTypes.string.isRequired,
|
|
930
|
-
|
|
931
898
|
/** The video's MIME type (example: `video/mp4`) */
|
|
932
899
|
mediaType: PropTypes.string.isRequired,
|
|
933
|
-
|
|
934
900
|
/** The label to be given to this file in the quality selector (example: `1080p`) */
|
|
935
901
|
qualityName: PropTypes.string.isRequired,
|
|
936
|
-
|
|
937
902
|
/** A number indicating the video's quality, with 1 being the best, and the number increasing from there as quality degrades */
|
|
938
903
|
qualityRank: PropTypes.number.isRequired,
|
|
939
|
-
|
|
940
904
|
/** A boolean that defines its source as a fallback for another source with the same `qualityRank` */
|
|
941
905
|
isFallback: PropTypes.bool
|
|
942
906
|
})).isRequired,
|
|
943
|
-
|
|
944
907
|
/**
|
|
945
908
|
* A path of the image that will be displayed on the video's splash screen.
|
|
946
909
|
*/
|
|
947
910
|
posterSrc: PropTypes.string.isRequired,
|
|
948
|
-
|
|
949
911
|
/**
|
|
950
912
|
* An array of objects that defines each caption file. See the "Basic Usage" section for more information.
|
|
951
913
|
*/
|
|
952
914
|
tracks: PropTypes.arrayOf(PropTypes.shape({
|
|
953
915
|
/** A path to the track file */
|
|
954
916
|
source: PropTypes.string.isRequired,
|
|
955
|
-
|
|
956
917
|
/** The name of the track file as it will appear in the "Captions" dialogue */
|
|
957
918
|
label: PropTypes.string.isRequired,
|
|
958
|
-
|
|
959
919
|
/** 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 */
|
|
960
920
|
kind: PropTypes.string.isRequired,
|
|
961
|
-
|
|
962
921
|
/** The language of the track file represented as a ISO 639-1 language code */
|
|
963
922
|
language: PropTypes.string.isRequired
|
|
964
923
|
})),
|
|
965
|
-
|
|
966
924
|
/**
|
|
967
925
|
* The video's default volume, defined from 1 to 100. Please use the `beginMuted` prop to have the video start silenced.
|
|
968
926
|
*/
|
|
969
927
|
defaultVolume: PropTypes.number,
|
|
970
|
-
|
|
971
928
|
/**
|
|
972
929
|
* Defines if the video should start muted.
|
|
973
930
|
*/
|
|
974
931
|
beginMuted: PropTypes.bool,
|
|
975
|
-
|
|
976
932
|
/**
|
|
977
933
|
* The default quality level if the user is on mobile. See the `sources` prop for available quality levels.
|
|
978
934
|
*/
|
|
979
935
|
defaultMobileQuality: PropTypes.number,
|
|
980
|
-
|
|
981
936
|
/**
|
|
982
937
|
* The default quality level if the user is on desktop. See the `sources` prop for available quality levels.
|
|
983
938
|
*/
|
|
984
939
|
defaultDesktopQuality: PropTypes.number,
|
|
985
|
-
|
|
986
940
|
/**
|
|
987
941
|
* The video player UI's language as an ISO language code. It currently supports English and French.
|
|
988
942
|
*/
|
|
989
943
|
copy: PropTypes.oneOf(['en', 'fr']).isRequired,
|
|
990
|
-
|
|
991
944
|
/**
|
|
992
945
|
* Sets the `video` tag's `crossorigin` mode. Please note that content loaded without CORS approval may be insecure.
|
|
993
946
|
* @since 1.1.0
|
|
994
947
|
*/
|
|
995
948
|
crossOrigin: PropTypes.oneOf(['anonymous', 'use-credentials']),
|
|
996
|
-
|
|
997
949
|
/**
|
|
998
950
|
* Disables the control bar during playback and reduces the amount of time until the UI hides itself.
|
|
999
951
|
* For special approved internal uses only.
|
|
1000
952
|
* @since 1.2.0
|
|
1001
953
|
*/
|
|
1002
954
|
simpleMode: PropTypes.bool,
|
|
1003
|
-
|
|
1004
955
|
/**
|
|
1005
956
|
* 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.
|
|
1006
957
|
* @since 1.2.0
|
|
1007
958
|
*/
|
|
1008
959
|
videoBorder: PropTypes.bool,
|
|
1009
|
-
|
|
1010
960
|
/**
|
|
1011
961
|
* A callback function that fires when a customer interacts with Video.
|
|
1012
962
|
* When using `analyticsTracking`, `videoTitle` must also be defined.
|
|
@@ -1020,7 +970,6 @@ Video.propTypes = { ...selectedSystemPropTypes,
|
|
|
1020
970
|
* @param {string} analyticsObject.details The name of the video based on the `videoTitle` prop
|
|
1021
971
|
*/
|
|
1022
972
|
analyticsTracking: PropTypes.func,
|
|
1023
|
-
|
|
1024
973
|
/**
|
|
1025
974
|
* The title of the video being rendered. This is used for analytics purposes in conjunction with `analyticsTracking`.
|
|
1026
975
|
* @since 1.3.0
|