cloudinary-video-player 1.6.2-edge.13
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/.eslintignore +4 -0
- package/.snyk +19 -0
- package/.travis.yml +8 -0
- package/CHANGELOG.md +329 -0
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/cld-video-player.css +2110 -0
- package/dist/cld-video-player.js +5249 -0
- package/dist/cld-video-player.light.css +1766 -0
- package/dist/cld-video-player.light.js +1399 -0
- package/dist/cld-video-player.light.min.css +1 -0
- package/dist/cld-video-player.light.min.js +2 -0
- package/dist/cld-video-player.light.min.js.LICENSE.txt +23 -0
- package/dist/cld-video-player.min.css +1 -0
- package/dist/cld-video-player.min.js +2 -0
- package/dist/cld-video-player.min.js.LICENSE.txt +26 -0
- package/dist/fonts/cloudinary_icon_for_black_bg.svg +69 -0
- package/dist/fonts/cloudinary_icon_for_white_bg.svg +69 -0
- package/docs/360.html +102 -0
- package/docs/_template.html +93 -0
- package/docs/adaptive-streaming.html +297 -0
- package/docs/analytics.html +140 -0
- package/docs/api.html +302 -0
- package/docs/audio.html +136 -0
- package/docs/autoplay-fallback.html +138 -0
- package/docs/autoplay-on-scroll.html +107 -0
- package/docs/codec-fallback.html +158 -0
- package/docs/colors.html +135 -0
- package/docs/components.html +284 -0
- package/docs/custom-cld-errors.html +134 -0
- package/docs/floating-player.html +98 -0
- package/docs/fluid.html +117 -0
- package/docs/force-hls-subtitles-ios.html +159 -0
- package/docs/index.html +83 -0
- package/docs/interaction-area.html +398 -0
- package/docs/live-customer.html +128 -0
- package/docs/multiple-players.html +125 -0
- package/docs/playlist-by-tag-cap.html +182 -0
- package/docs/playlist-by-tag.html +133 -0
- package/docs/playlist.html +133 -0
- package/docs/poster.html +155 -0
- package/docs/raw-url.html +104 -0
- package/docs/recommendations.html +155 -0
- package/docs/scripts.js +156 -0
- package/docs/seek-thumbs.html +90 -0
- package/docs/shoppable.html +335 -0
- package/docs/subtitles-and-captions.html +267 -0
- package/docs/transformations.html +171 -0
- package/docs/ui-config.html +108 -0
- package/docs/vast-vpaid.html +149 -0
- package/env.example.js +6 -0
- package/env.js +6 -0
- package/jest-puppeteer.config.js +14 -0
- package/jest.config.js +196 -0
- package/package.json +99 -0
- package/sandbox.config.json +3 -0
- package/setupJest.js +1 -0
- package/src/assets/fonts/VideoJS.svg +120 -0
- package/src/assets/fonts/VideoJS.ttf +0 -0
- package/src/assets/fonts/VideoJS.woff +0 -0
- package/src/assets/fonts/icons.json +120 -0
- package/src/assets/icons/cloudinary_icon_for_black_bg.svg +69 -0
- package/src/assets/icons/cloudinary_icon_for_white_bg.svg +69 -0
- package/src/assets/icons/cloudinary_logo_for_dark_bg.svg +188 -0
- package/src/assets/icons/cloudinary_logo_for_white_bg.svg +188 -0
- package/src/assets/icons/info-circle.svg +17 -0
- package/src/assets/styles/ads-label.scss +16 -0
- package/src/assets/styles/components/interaction-areas.scss +158 -0
- package/src/assets/styles/components/playlist.scss +213 -0
- package/src/assets/styles/components/themedButton.scss +48 -0
- package/src/assets/styles/components/thumbnail.scss +94 -0
- package/src/assets/styles/components/title-bar.scss +67 -0
- package/src/assets/styles/components/triangle-volume-bar.scss +52 -0
- package/src/assets/styles/icons.scss +257 -0
- package/src/assets/styles/main.scss +324 -0
- package/src/assets/styles/mixins/aspect-ratio.scss +16 -0
- package/src/assets/styles/mixins/disable-transition.scss +3 -0
- package/src/assets/styles/mixins/mixins.scss +5 -0
- package/src/assets/styles/mixins/skin.scss +64 -0
- package/src/assets/styles/variables.scss +2 -0
- package/src/assets/styles/videojs-ima.scss +252 -0
- package/src/components/component-utils.js +20 -0
- package/src/components/index.js +21 -0
- package/src/components/interaction-area/interaction-area.const.js +30 -0
- package/src/components/interaction-area/interaction-area.service.js +223 -0
- package/src/components/interaction-area/interaction-area.utils.js +236 -0
- package/src/components/jumpButtons/jump-10-minus.js +21 -0
- package/src/components/jumpButtons/jump-10-plus.js +20 -0
- package/src/components/logoButton/logo-button.const.js +3 -0
- package/src/components/logoButton/logo-button.js +30 -0
- package/src/components/logoButton/logo-button.scss +15 -0
- package/src/components/playlist/components/playlist-button.js +34 -0
- package/src/components/playlist/components/playlist-next-button.js +18 -0
- package/src/components/playlist/components/playlist-previous-button.js +18 -0
- package/src/components/playlist/components/playlist.js +5 -0
- package/src/components/playlist/components/playlist.scss +15 -0
- package/src/components/playlist/components/upcoming-video-overlay.js +149 -0
- package/src/components/playlist/components/upcoming-video-overlay.scss +86 -0
- package/src/components/playlist/layout/playlist-layout-custom.js +21 -0
- package/src/components/playlist/layout/playlist-layout-horizontal.js +16 -0
- package/src/components/playlist/layout/playlist-layout-vertical.js +19 -0
- package/src/components/playlist/layout/playlist-layout.js +110 -0
- package/src/components/playlist/panel/playlist-panel-item.js +86 -0
- package/src/components/playlist/panel/playlist-panel.js +92 -0
- package/src/components/playlist/playlist-widget.js +119 -0
- package/src/components/playlist/playlist.const.js +14 -0
- package/src/components/playlist/playlist.js +413 -0
- package/src/components/playlist/thumbnail/thumbnail.js +69 -0
- package/src/components/progress-control-events-blocker/progress-control-events-blocker.js +17 -0
- package/src/components/qualitySelector/quality-selector.scss +10 -0
- package/src/components/qualitySelector/qualitySelector.js +152 -0
- package/src/components/recommendations-overlay/index.js +3 -0
- package/src/components/recommendations-overlay/recommendations-overlay-content.js +57 -0
- package/src/components/recommendations-overlay/recommendations-overlay-hide-button.js +18 -0
- package/src/components/recommendations-overlay/recommendations-overlay-item.js +35 -0
- package/src/components/recommendations-overlay/recommendations-overlay-primary-item.js +81 -0
- package/src/components/recommendations-overlay/recommendations-overlay-secondary-item.js +48 -0
- package/src/components/recommendations-overlay/recommendations-overlay-secondary-items-container.js +35 -0
- package/src/components/recommendations-overlay/recommendations-overlay.js +94 -0
- package/src/components/recommendations-overlay/recommendations-overlay.scss +182 -0
- package/src/components/shoppable-bar/layout/bar-layout.js +111 -0
- package/src/components/shoppable-bar/layout/shoppable-panel-toggle.js +64 -0
- package/src/components/shoppable-bar/layout/shoppable-products-overlay.js +87 -0
- package/src/components/shoppable-bar/panel/shoppable-panel-item.js +105 -0
- package/src/components/shoppable-bar/panel/shoppable-panel.js +172 -0
- package/src/components/shoppable-bar/shoppable-post-widget.js +110 -0
- package/src/components/shoppable-bar/shoppable-widget.const.js +52 -0
- package/src/components/shoppable-bar/shoppable-widget.js +111 -0
- package/src/components/shoppable-bar/shoppable-widget.scss +359 -0
- package/src/components/themeButton/themedButton.const.js +3 -0
- package/src/components/themeButton/themedButton.js +25 -0
- package/src/components/title-bar/title-bar.js +79 -0
- package/src/config/defaults.js +25 -0
- package/src/extended-events.js +228 -0
- package/src/index.js +18 -0
- package/src/mixins/eventable.js +54 -0
- package/src/mixins/playlistable.js +106 -0
- package/src/plugins/analytics/index.js +245 -0
- package/src/plugins/autoplay-on-scroll/index.js +86 -0
- package/src/plugins/cloudinary/common.js +216 -0
- package/src/plugins/cloudinary/event-handler-registry.js +46 -0
- package/src/plugins/cloudinary/index.js +345 -0
- package/src/plugins/cloudinary/models/audio-source/audio-source.const.js +11 -0
- package/src/plugins/cloudinary/models/audio-source/audio-source.js +82 -0
- package/src/plugins/cloudinary/models/base-source.js +107 -0
- package/src/plugins/cloudinary/models/image-source.js +26 -0
- package/src/plugins/cloudinary/models/video-source/video-source.const.js +32 -0
- package/src/plugins/cloudinary/models/video-source/video-source.js +239 -0
- package/src/plugins/cloudinary/models/video-source/video-source.utils.js +57 -0
- package/src/plugins/colors/index.js +303 -0
- package/src/plugins/context-menu/components/context-menu-item.js +12 -0
- package/src/plugins/context-menu/components/context-menu.js +63 -0
- package/src/plugins/context-menu/context-menu.scss +30 -0
- package/src/plugins/context-menu/contextMenuContent.js +53 -0
- package/src/plugins/context-menu/index.js +134 -0
- package/src/plugins/dash/index.js +26 -0
- package/src/plugins/dash/setup-audio-tracks.js +112 -0
- package/src/plugins/dash/setup-text-tracks.js +195 -0
- package/src/plugins/dash/videojs-dash.js +372 -0
- package/src/plugins/floating-player/floating-player.scss +74 -0
- package/src/plugins/floating-player/index.js +129 -0
- package/src/plugins/ima/index.js +1775 -0
- package/src/plugins/index.js +31 -0
- package/src/plugins/interactive-plugin/index.js +10 -0
- package/src/plugins/videojs-http-source-selector/components/SourceMenuButton.js +98 -0
- package/src/plugins/videojs-http-source-selector/components/SourceMenuItem.js +52 -0
- package/src/plugins/videojs-http-source-selector/plugin.js +82 -0
- package/src/plugins/videojs-http-source-selector/plugin.scss +9 -0
- package/src/plugins/vtt-thumbnails/index.js +526 -0
- package/src/plugins/vtt-thumbnails/vtt-thumbnails.scss +29 -0
- package/src/utils/api.js +32 -0
- package/src/utils/apply-with-props.js +32 -0
- package/src/utils/array.js +22 -0
- package/src/utils/assign.js +27 -0
- package/src/utils/attributes-normalizer.js +72 -0
- package/src/utils/cloudinary.js +165 -0
- package/src/utils/css-prefix.js +43 -0
- package/src/utils/dom.js +74 -0
- package/src/utils/find.js +28 -0
- package/src/utils/fontFace.js +25 -0
- package/src/utils/groupBy.js +12 -0
- package/src/utils/index.js +29 -0
- package/src/utils/matches.js +11 -0
- package/src/utils/mixin.js +5 -0
- package/src/utils/object.js +26 -0
- package/src/utils/playButton.js +9 -0
- package/src/utils/positioning.js +78 -0
- package/src/utils/querystring.js +12 -0
- package/src/utils/slicing.js +21 -0
- package/src/utils/string.js +15 -0
- package/src/utils/throttle.js +30 -0
- package/src/utils/time.js +77 -0
- package/src/utils/type-inference.js +35 -0
- package/src/validators/validators-functions.js +48 -0
- package/src/validators/validators-types.js +78 -0
- package/src/validators/validators.js +110 -0
- package/src/video-player.const.js +68 -0
- package/src/video-player.js +761 -0
- package/src/video-player.utils.js +123 -0
- package/test/adaptive-streaming.test.js +38 -0
- package/test/ads.test.js +35 -0
- package/test/analytics.test.js +111 -0
- package/test/api.test.js +111 -0
- package/test/autoplay.scroll.test.js +23 -0
- package/test/basic-ui.test.js +59 -0
- package/test/colors.test.js +58 -0
- package/test/components.test.js +21 -0
- package/test/custom-error.test.js +24 -0
- package/test/fluid.test.js +36 -0
- package/test/isValidConfig.test.js +224 -0
- package/test/mocks/cloudinary-core-mock.js +0 -0
- package/test/mocks/styleMock.js +1 -0
- package/test/multiplayer.test.js +25 -0
- package/test/playlist.test.js +60 -0
- package/test/puppeteer/vp-env.js +19 -0
- package/test/recommendations.test.js +38 -0
- package/test/title-bar.test.js +28 -0
- package/test/ui-conf.test.js +49 -0
- package/test/unit/cloudinaryConfig.test.js +22 -0
- package/test/unit/cloudinaryUtils.test.js +53 -0
- package/test/unit/utils.test.js +27 -0
- package/test/unit/videoSource.test.js +454 -0
- package/tsconfig.json +15 -0
- package/types/video-player-tests.js +12 -0
- package/types/video-player-tests.ts +31 -0
- package/types/video-player.d.ts +570 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import cloudinary from 'cloudinary-core';
|
|
2
|
+
import { normalizeOptions } from '../common';
|
|
3
|
+
import { sliceAndUnsetProperties } from 'utils/slicing';
|
|
4
|
+
import { getCloudinaryInstanceOf } from 'utils/cloudinary';
|
|
5
|
+
import { objectToQuerystring } from 'utils/querystring';
|
|
6
|
+
|
|
7
|
+
class BaseSource {
|
|
8
|
+
constructor(publicId, options = {}) {
|
|
9
|
+
({ publicId, options } = normalizeOptions(publicId, options));
|
|
10
|
+
|
|
11
|
+
let _publicId = null;
|
|
12
|
+
let _cloudinaryConfig = null;
|
|
13
|
+
let _transformation = null;
|
|
14
|
+
let _resourceConfig = null;
|
|
15
|
+
let _queryParams = null;
|
|
16
|
+
|
|
17
|
+
this.publicId = (publicId) => {
|
|
18
|
+
if (!publicId) {
|
|
19
|
+
return _publicId;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_publicId = publicId;
|
|
23
|
+
|
|
24
|
+
return this;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
this.cloudinaryConfig = (config) => {
|
|
28
|
+
if (!config) {
|
|
29
|
+
return _cloudinaryConfig;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_cloudinaryConfig = getCloudinaryInstanceOf(cloudinary.Cloudinary, config);
|
|
33
|
+
|
|
34
|
+
return this;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
this.resourceConfig = (config) => {
|
|
38
|
+
if (!config) {
|
|
39
|
+
return _resourceConfig;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_resourceConfig = config;
|
|
43
|
+
|
|
44
|
+
return this;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
this.transformation = (trans) => {
|
|
48
|
+
if (!trans) {
|
|
49
|
+
return _transformation;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_transformation = getCloudinaryInstanceOf(cloudinary.Transformation, trans);
|
|
53
|
+
|
|
54
|
+
return this;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
this.queryParams = (params) => {
|
|
58
|
+
if (!params) {
|
|
59
|
+
return _queryParams;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
_queryParams = params;
|
|
63
|
+
|
|
64
|
+
return this;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
this.getType = () => this._type;
|
|
68
|
+
|
|
69
|
+
const { cloudinaryConfig } = sliceAndUnsetProperties(options, 'cloudinaryConfig');
|
|
70
|
+
if (!cloudinaryConfig) {
|
|
71
|
+
throw new Error('Source is missing \'cloudinaryConfig\'.');
|
|
72
|
+
}
|
|
73
|
+
this.cloudinaryConfig(cloudinaryConfig);
|
|
74
|
+
|
|
75
|
+
const { transformation } = sliceAndUnsetProperties(options, 'transformation');
|
|
76
|
+
this.transformation(transformation);
|
|
77
|
+
|
|
78
|
+
const { queryParams } = sliceAndUnsetProperties(options, 'queryParams');
|
|
79
|
+
this.queryParams(queryParams);
|
|
80
|
+
|
|
81
|
+
this.resourceConfig(options);
|
|
82
|
+
|
|
83
|
+
this.publicId(publicId);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
config() {
|
|
88
|
+
const cld = new cloudinary.Cloudinary(this.cloudinaryConfig().config());
|
|
89
|
+
cld.config(this.resourceConfig());
|
|
90
|
+
|
|
91
|
+
return cld;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
url({ transformation } = {}) {
|
|
95
|
+
const url = this.config().url(this.publicId(), { transformation: transformation || this.transformation() });
|
|
96
|
+
|
|
97
|
+
let queryString = '';
|
|
98
|
+
if (this.queryParams()) {
|
|
99
|
+
queryString = objectToQuerystring(this.queryParams());
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return `${url}${queryString}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default BaseSource;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import BaseSource from './base-source';
|
|
2
|
+
import { normalizeOptions } from '../common';
|
|
3
|
+
import { assign } from 'utils/assign';
|
|
4
|
+
|
|
5
|
+
const COMMON_IMAGE_FORMATS = ['jpg', 'png', 'gif', 'webp'];
|
|
6
|
+
const IMAGE_SUFFIX_REMOVAL_PATTERN = RegExp(`\\.(${COMMON_IMAGE_FORMATS.join('|')})$$`);
|
|
7
|
+
const DEFAULT_IMAGE_PARAMS = {
|
|
8
|
+
resource_type: 'image',
|
|
9
|
+
type: 'upload',
|
|
10
|
+
transformation: []
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
class ImageSource extends BaseSource {
|
|
14
|
+
constructor(publicId, options = {}) {
|
|
15
|
+
({ publicId, options } = normalizeOptions(publicId, options));
|
|
16
|
+
|
|
17
|
+
publicId = publicId.replace(IMAGE_SUFFIX_REMOVAL_PATTERN, '');
|
|
18
|
+
|
|
19
|
+
options = assign({}, DEFAULT_IMAGE_PARAMS, options);
|
|
20
|
+
|
|
21
|
+
super(publicId, options);
|
|
22
|
+
this._type = 'ImageSource';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default ImageSource;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const DEFAULT_POSTER_PARAMS = { format: 'jpg', resource_type: 'video' };
|
|
2
|
+
|
|
3
|
+
const DEFAULT_VIDEO_SOURCE_TYPES = ['webm/vp9', 'mp4/h265', 'mp4'];
|
|
4
|
+
|
|
5
|
+
export const DEFAULT_VIDEO_PARAMS = {
|
|
6
|
+
resource_type: 'video',
|
|
7
|
+
type: 'upload',
|
|
8
|
+
transformation: [],
|
|
9
|
+
sourceTransformation: {},
|
|
10
|
+
sourceTypes: DEFAULT_VIDEO_SOURCE_TYPES,
|
|
11
|
+
recommendations: null,
|
|
12
|
+
info: {},
|
|
13
|
+
interactionAreas: {}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const VIDEO_SUFFIX_REMOVAL_PATTERN = RegExp(`\\.(${DEFAULT_VIDEO_SOURCE_TYPES.join('|')})$$`);
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line no-control-regex
|
|
19
|
+
export const URL_PATTERN = RegExp('https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\+.~#?&/=]*)');
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export const CONTAINER_MIME_TYPES = {
|
|
23
|
+
dash: ['application/dash+xml'],
|
|
24
|
+
hls: ['application/x-mpegURL'],
|
|
25
|
+
mpd: ['application/dash+xml'],
|
|
26
|
+
m3u8: ['application/x-mpegURL']
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const FORMAT_MAPPINGS = {
|
|
30
|
+
hls: 'm3u8',
|
|
31
|
+
dash: 'mpd'
|
|
32
|
+
};
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import BaseSource from '../base-source';
|
|
2
|
+
import ImageSource from '../image-source';
|
|
3
|
+
import { normalizeOptions, isSrcEqual } from '../../common';
|
|
4
|
+
import { sliceAndUnsetProperties } from 'utils/slicing';
|
|
5
|
+
import { assign } from 'utils/assign';
|
|
6
|
+
import { objectToQuerystring } from 'utils/querystring';
|
|
7
|
+
import { default as vjs } from 'video.js';
|
|
8
|
+
import {
|
|
9
|
+
CONTAINER_MIME_TYPES,
|
|
10
|
+
DEFAULT_POSTER_PARAMS,
|
|
11
|
+
DEFAULT_VIDEO_PARAMS,
|
|
12
|
+
URL_PATTERN,
|
|
13
|
+
VIDEO_SUFFIX_REMOVAL_PATTERN
|
|
14
|
+
} from './video-source.const';
|
|
15
|
+
import { formatToMimeTypeAndTransformation, isCodecAlreadyExist, normalizeFormat } from './video-source.utils';
|
|
16
|
+
import { castArray } from '../../../../utils/array';
|
|
17
|
+
|
|
18
|
+
let objectId = 0;
|
|
19
|
+
|
|
20
|
+
const generateId = () => objectId++;
|
|
21
|
+
|
|
22
|
+
class VideoSource extends BaseSource {
|
|
23
|
+
|
|
24
|
+
constructor(_publicId, initOptions = {}) {
|
|
25
|
+
|
|
26
|
+
const isRawUrl = URL_PATTERN.test(_publicId);
|
|
27
|
+
let { publicId, options } = normalizeOptions(_publicId, initOptions);
|
|
28
|
+
|
|
29
|
+
if (!isRawUrl) {
|
|
30
|
+
publicId = publicId.replace(VIDEO_SUFFIX_REMOVAL_PATTERN, '');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
options = assign({}, DEFAULT_VIDEO_PARAMS, options);
|
|
34
|
+
|
|
35
|
+
if (!options.poster) {
|
|
36
|
+
options.poster = assign({ publicId }, DEFAULT_POSTER_PARAMS);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
poster,
|
|
41
|
+
sourceTypes,
|
|
42
|
+
sourceTransformation,
|
|
43
|
+
info,
|
|
44
|
+
recommendations,
|
|
45
|
+
textTracks,
|
|
46
|
+
withCredentials,
|
|
47
|
+
interactionAreas
|
|
48
|
+
} = sliceAndUnsetProperties(
|
|
49
|
+
options,
|
|
50
|
+
'poster',
|
|
51
|
+
'sourceTypes',
|
|
52
|
+
'sourceTransformation',
|
|
53
|
+
'info',
|
|
54
|
+
'recommendations',
|
|
55
|
+
'textTracks',
|
|
56
|
+
'withCredentials',
|
|
57
|
+
'interactionAreas'
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
super(publicId, options);
|
|
61
|
+
|
|
62
|
+
this._sourceTypes = null;
|
|
63
|
+
this._recommendations = null;
|
|
64
|
+
this._textTracks = null;
|
|
65
|
+
this._poster = null;
|
|
66
|
+
this._info = null;
|
|
67
|
+
this._sourceTransformation = null;
|
|
68
|
+
this._interactionAreas = null;
|
|
69
|
+
this._type = 'VideoSource';
|
|
70
|
+
this.isRawUrl = isRawUrl;
|
|
71
|
+
this._rawTransformation = options.raw_transformation;
|
|
72
|
+
this.withCredentials = !!withCredentials;
|
|
73
|
+
this.getInitOptions = () => initOptions;
|
|
74
|
+
|
|
75
|
+
this.poster(poster);
|
|
76
|
+
this.sourceTypes(sourceTypes);
|
|
77
|
+
this.sourceTransformation(sourceTransformation);
|
|
78
|
+
this.info(info);
|
|
79
|
+
this.interactionAreas(interactionAreas);
|
|
80
|
+
this.recommendations(recommendations);
|
|
81
|
+
this.textTracks(textTracks);
|
|
82
|
+
this.objectId = generateId();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
textTracks(textTracks) {
|
|
86
|
+
if (textTracks === undefined) {
|
|
87
|
+
return this._textTracks;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
this._textTracks = textTracks;
|
|
91
|
+
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
recommendations(recommends) {
|
|
96
|
+
if (recommends === undefined) {
|
|
97
|
+
return this._recommendations;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this._recommendations = recommends;
|
|
101
|
+
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
sourceTypes (types) {
|
|
106
|
+
if (!types) {
|
|
107
|
+
return this._sourceTypes;
|
|
108
|
+
}
|
|
109
|
+
this._sourceTypes = types;
|
|
110
|
+
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
info(info) {
|
|
115
|
+
if (!info) {
|
|
116
|
+
return this._info;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this._info = info;
|
|
120
|
+
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interactionAreas(interactionAreas) {
|
|
125
|
+
if (!interactionAreas) {
|
|
126
|
+
return this._interactionAreas;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
this._interactionAreas = interactionAreas;
|
|
130
|
+
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
sourceTransformation(trans) {
|
|
135
|
+
if (!trans) {
|
|
136
|
+
return this._sourceTransformation;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this._sourceTransformation = trans;
|
|
140
|
+
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
poster (publicId, options = {}) {
|
|
145
|
+
if (!publicId) {
|
|
146
|
+
return this._poster;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (publicId instanceof ImageSource) {
|
|
150
|
+
this._poster = publicId;
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
({ publicId, options } = normalizeOptions(publicId, options, { tolerateMissingId: true }));
|
|
155
|
+
|
|
156
|
+
if (!publicId) {
|
|
157
|
+
publicId = this.publicId();
|
|
158
|
+
options = assign({}, options, DEFAULT_POSTER_PARAMS);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
options.cloudinaryConfig = options.cloudinaryConfig || this.cloudinaryConfig();
|
|
162
|
+
this._poster = new ImageSource(publicId, options);
|
|
163
|
+
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
contains(source) {
|
|
168
|
+
const sources = this.generateSources();
|
|
169
|
+
return sources.some((_source) => isSrcEqual(_source, source));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
generateSources() {
|
|
173
|
+
if (this.isRawUrl) {
|
|
174
|
+
const type = this.sourceTypes().length > 1 ? null : this.sourceTypes()[0];
|
|
175
|
+
return [this.generateRawSource(this.publicId(), type)];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const srcs = this.sourceTypes().map((sourceType) => {
|
|
179
|
+
const srcTransformation = this.sourceTransformation()[sourceType] || this.transformation();
|
|
180
|
+
const format = normalizeFormat(sourceType);
|
|
181
|
+
const isAdaptive = (['mpd', 'm3u8'].indexOf(format) !== -1);
|
|
182
|
+
const opts = {};
|
|
183
|
+
|
|
184
|
+
if (srcTransformation) {
|
|
185
|
+
opts.transformation = castArray(srcTransformation);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
assign(opts, { resource_type: 'video', format });
|
|
189
|
+
|
|
190
|
+
const [type, codecTrans] = formatToMimeTypeAndTransformation(sourceType);
|
|
191
|
+
|
|
192
|
+
// If user's transformation include video_codec then don't add another video codec to transformation
|
|
193
|
+
if (codecTrans && !isCodecAlreadyExist(opts.transformation, this._rawTransformation)) {
|
|
194
|
+
opts.transformation.push(codecTrans);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (opts.format === 'auto') {
|
|
198
|
+
delete opts.format;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const queryString = this.queryParams() ? objectToQuerystring(this.queryParams()) : '';
|
|
202
|
+
|
|
203
|
+
const src = this.config().url(this.publicId(), opts);
|
|
204
|
+
// if src is a url that already contains query params then replace '?' with '&'
|
|
205
|
+
const params = src.indexOf('?') > -1 ? queryString.replace('?', '&') : queryString;
|
|
206
|
+
|
|
207
|
+
return { type, src: src + params, cldSrc: this, isAdaptive: isAdaptive, withCredentials: this.withCredentials };
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
const isIe = typeof navigator !== 'undefined' && (/MSIE/.test(navigator.userAgent) || /Trident\//.test(navigator.appVersion));
|
|
211
|
+
|
|
212
|
+
if (isIe) {
|
|
213
|
+
return srcs.filter(s => s.type !== 'video/mp4; codec="hev1.1.6.L93.B0"');
|
|
214
|
+
} else if (vjs.browser.IS_ANY_SAFARI) {
|
|
215
|
+
// filter out dash on safari
|
|
216
|
+
return srcs.filter(s => s.type.indexOf('application/dash+xml') === -1);
|
|
217
|
+
} else {
|
|
218
|
+
return srcs;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
generateRawSource(url, type) {
|
|
223
|
+
const t = type || url.split('.').pop();
|
|
224
|
+
const isAdaptive = !!CONTAINER_MIME_TYPES[t];
|
|
225
|
+
if (isAdaptive) {
|
|
226
|
+
type = CONTAINER_MIME_TYPES[t][0];
|
|
227
|
+
} else {
|
|
228
|
+
type = type ? `video/${type}` : null;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return { type, src: url, cldSrc: this, isAdaptive, withCredentials: this.withCredentials };
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
getInteractionAreas() {
|
|
235
|
+
return this._interactionAreas;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export default VideoSource;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CONTAINER_MIME_TYPES, FORMAT_MAPPINGS } from './video-source.const';
|
|
2
|
+
import { codecShorthandTrans, codecToSrcTransformation, VIDEO_CODEC } from '../../common';
|
|
3
|
+
import { isPlainObject, isString } from '../../../../utils/type-inference';
|
|
4
|
+
import { isKeyInTransformation } from 'utils/cloudinary';
|
|
5
|
+
import { some } from '../../../../utils/array';
|
|
6
|
+
|
|
7
|
+
export function formatToMimeTypeAndTransformation(format) {
|
|
8
|
+
const [container, codec] = format.toLowerCase().split('\/');
|
|
9
|
+
let result = CONTAINER_MIME_TYPES[container];
|
|
10
|
+
let transformation = null;
|
|
11
|
+
|
|
12
|
+
if (!result) {
|
|
13
|
+
result = [`video/${container}`, transformation];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (codec) {
|
|
17
|
+
transformation = codecToSrcTransformation(codec);
|
|
18
|
+
result = [`${result[0]}; codecs="${codecShorthandTrans(codec)}"`, transformation];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function normalizeFormat(format) {
|
|
25
|
+
format = format.toLowerCase().split('\/').shift();
|
|
26
|
+
|
|
27
|
+
let res = FORMAT_MAPPINGS[format];
|
|
28
|
+
if (!res) {
|
|
29
|
+
res = format.split('\/').shift();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const isContainCodec = (value) => value && some(Object.values(VIDEO_CODEC), (codec) => value.includes(codec));
|
|
36
|
+
|
|
37
|
+
const hasCodecSrcTrans = (transformations) => some(['video_codec', 'streaming_profile'], (key) => isKeyInTransformation(transformations, key));
|
|
38
|
+
|
|
39
|
+
export const isCodecAlreadyExist = (transformations, rawTransformation) => {
|
|
40
|
+
if (!(transformations || rawTransformation)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (hasCodecSrcTrans(transformations)) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (isString(rawTransformation)) {
|
|
49
|
+
return isContainCodec(rawTransformation);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return some(transformations, (transformation) => {
|
|
53
|
+
const options = transformation.toOptions();
|
|
54
|
+
|
|
55
|
+
return some(options && options.transformation, (item) => isContainCodec(isPlainObject(item) ? item.video_codec : item));
|
|
56
|
+
});
|
|
57
|
+
};
|