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,454 @@
|
|
|
1
|
+
import VideoSource from '../../src/plugins/cloudinary/models/video-source/video-source.js';
|
|
2
|
+
import cloudinary from 'cloudinary-core';
|
|
3
|
+
import { isCodecAlreadyExist } from '../../src/plugins/cloudinary/models/video-source/video-source.utils';
|
|
4
|
+
const cld = cloudinary.Cloudinary.new({ cloud_name: 'demo' });
|
|
5
|
+
|
|
6
|
+
describe('video source tests', () => {
|
|
7
|
+
it('Test transformation input object', () => {
|
|
8
|
+
let sourceDef = {
|
|
9
|
+
cloudinaryConfig: cld,
|
|
10
|
+
transformation: {
|
|
11
|
+
fetch_format: 'auto'
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
let source = new VideoSource('sea_turtle', sourceDef);
|
|
15
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
16
|
+
// eslint-disable-next-line no-unused-expressions
|
|
17
|
+
expect(srcs[0]).toContain('f_auto');
|
|
18
|
+
});
|
|
19
|
+
it('Test transformation input array', () => {
|
|
20
|
+
let sourceDef = {
|
|
21
|
+
cloudinaryConfig: cld,
|
|
22
|
+
transformation: [{
|
|
23
|
+
fetch_format: 'auto'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
streaming_profile: 'hd'
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
let source = new VideoSource('sea_turtle', sourceDef);
|
|
31
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
32
|
+
// eslint-disable-next-line no-unused-expressions
|
|
33
|
+
expect(srcs[0]).toContain('f_auto');
|
|
34
|
+
expect(srcs[0]).toContain('sp_hd');
|
|
35
|
+
});
|
|
36
|
+
it('Test transformation input cloudinary transformation', () => {
|
|
37
|
+
let tr = cloudinary.Transformation.new({
|
|
38
|
+
fetch_format: 'auto'
|
|
39
|
+
});
|
|
40
|
+
let sourceDef = {
|
|
41
|
+
cloudinaryConfig: cld,
|
|
42
|
+
transformation: tr
|
|
43
|
+
};
|
|
44
|
+
let source = new VideoSource('sea_turtle', sourceDef);
|
|
45
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
46
|
+
// eslint-disable-next-line no-unused-expressions
|
|
47
|
+
expect(srcs[0]).toContain('f_auto');
|
|
48
|
+
});
|
|
49
|
+
it('Test transformation input string (named transformation)', () => {
|
|
50
|
+
let sourceDef = {
|
|
51
|
+
cloudinaryConfig: cld,
|
|
52
|
+
transformation: 'test'
|
|
53
|
+
};
|
|
54
|
+
let source = new VideoSource('sea_turtle', sourceDef);
|
|
55
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
56
|
+
// eslint-disable-next-line no-unused-expressions
|
|
57
|
+
expect(srcs[0]).toContain('t_test');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe('Adaptive source type tests', () => {
|
|
61
|
+
it('Test hls no codec', () => {
|
|
62
|
+
let sourceDef = {
|
|
63
|
+
cloudinaryConfig: cld
|
|
64
|
+
};
|
|
65
|
+
let source = new VideoSource('sea_turtle', sourceDef);
|
|
66
|
+
source.sourceTypes(['hls']);
|
|
67
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
68
|
+
// eslint-disable-next-line no-unused-expressions
|
|
69
|
+
expect(srcs[0]).not.toContain('vc_');
|
|
70
|
+
});
|
|
71
|
+
it('Test hls with codec', () => {
|
|
72
|
+
let sourceDef = {
|
|
73
|
+
cloudinaryConfig: cld
|
|
74
|
+
};
|
|
75
|
+
let source = new VideoSource('sea_turtle', sourceDef);
|
|
76
|
+
source.sourceTypes(['hls/h265']);
|
|
77
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
78
|
+
// eslint-disable-next-line no-unused-expressions
|
|
79
|
+
expect(srcs[0]).toContain('vc_h265');
|
|
80
|
+
});
|
|
81
|
+
it('Test dash no codec', () => {
|
|
82
|
+
let sourceDef = {
|
|
83
|
+
cloudinaryConfig: cld
|
|
84
|
+
};
|
|
85
|
+
let source = new VideoSource('sea_turtle', sourceDef);
|
|
86
|
+
source.sourceTypes(['dash']);
|
|
87
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
88
|
+
// eslint-disable-next-line no-unused-expressions
|
|
89
|
+
expect(srcs[0]).not.toContain('vc_');
|
|
90
|
+
});
|
|
91
|
+
it('Test dash codec', () => {
|
|
92
|
+
let sourceDef = {
|
|
93
|
+
cloudinaryConfig: cld
|
|
94
|
+
};
|
|
95
|
+
let source = new VideoSource('sea_turtle', sourceDef);
|
|
96
|
+
source.sourceTypes(['dash/vp9']);
|
|
97
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
98
|
+
// eslint-disable-next-line no-unused-expressions
|
|
99
|
+
expect(srcs[0]).toContain('vc_vp9');
|
|
100
|
+
});
|
|
101
|
+
it('Test dash codec + transformation', () => {
|
|
102
|
+
let sourceDef = {
|
|
103
|
+
cloudinaryConfig: cld,
|
|
104
|
+
transformation: [{
|
|
105
|
+
fetch_format: 'auto'
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
streaming_profile: 'hd'
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
};
|
|
112
|
+
let source = new VideoSource('sea_turtle', sourceDef);
|
|
113
|
+
source.sourceTypes(['dash/vp9']);
|
|
114
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
115
|
+
// eslint-disable-next-line no-unused-expressions
|
|
116
|
+
expect(srcs[0]).not.toContain('vc_vp9');
|
|
117
|
+
expect(srcs[0]).toContain('f_auto');
|
|
118
|
+
expect(srcs[0]).toContain('sp_hd');
|
|
119
|
+
expect(srcs[0]).toContain('.mpd');
|
|
120
|
+
});
|
|
121
|
+
it('Test hls codec + transformation', () => {
|
|
122
|
+
let sourceDef = {
|
|
123
|
+
cloudinaryConfig: cld,
|
|
124
|
+
transformation: [{
|
|
125
|
+
fetch_format: 'auto'
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
streaming_profile: 'hd'
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
};
|
|
132
|
+
let source = new VideoSource('sea_turtle', sourceDef);
|
|
133
|
+
source.sourceTypes(['hls/h265']);
|
|
134
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
135
|
+
// eslint-disable-next-line no-unused-expressions
|
|
136
|
+
expect(srcs[0]).not.toContain('vc_h265');
|
|
137
|
+
expect(srcs[0]).toContain('f_auto');
|
|
138
|
+
expect(srcs[0]).toContain('sp_hd');
|
|
139
|
+
expect(srcs[0]).toContain('.m3u8');
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
describe('Raw url tests', () => {
|
|
143
|
+
it('Test raw url', () => {
|
|
144
|
+
let sourceDef = {
|
|
145
|
+
cloudinaryConfig: cld,
|
|
146
|
+
sourceTypes: ['webm']
|
|
147
|
+
};
|
|
148
|
+
let url = 'https://exmaple.com/test.mp4';
|
|
149
|
+
let source = new VideoSource(url, sourceDef);
|
|
150
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
151
|
+
expect(srcs[0]).toEqual(url);
|
|
152
|
+
});
|
|
153
|
+
it('Test raw url without type', () => {
|
|
154
|
+
let sourceDef = {
|
|
155
|
+
cloudinaryConfig: cld
|
|
156
|
+
};
|
|
157
|
+
let url = 'https://exmaple.com/test.mp4';
|
|
158
|
+
let source = new VideoSource(url, sourceDef);
|
|
159
|
+
let srcs = source.generateSources();
|
|
160
|
+
expect(srcs[0].src).toEqual(url);
|
|
161
|
+
expect(srcs[0].type).toEqual(null);
|
|
162
|
+
expect(srcs[0].isAdaptive).toEqual(false);
|
|
163
|
+
});
|
|
164
|
+
it('Test raw url with transformations', () => {
|
|
165
|
+
let sourceDef = {
|
|
166
|
+
cloudinaryConfig: cld
|
|
167
|
+
};
|
|
168
|
+
let url = 'https://media.castit.biz/castit-dev/video/upload/a_0,c_limit,f_mp4,vc_h264,w_600/cit-qa/Videoback/2020/08/03/269085_358976.mp4';
|
|
169
|
+
let source = new VideoSource(url, sourceDef);
|
|
170
|
+
let srcs = source.generateSources();
|
|
171
|
+
expect(srcs[0].src).toEqual(url);
|
|
172
|
+
expect(srcs[0].type).toEqual(null);
|
|
173
|
+
expect(srcs[0].isAdaptive).toEqual(false);
|
|
174
|
+
});
|
|
175
|
+
it('Test raw url without extension', () => {
|
|
176
|
+
let sourceDef = {
|
|
177
|
+
cloudinaryConfig: cld,
|
|
178
|
+
sourceTypes: ['mp4']
|
|
179
|
+
};
|
|
180
|
+
let url = 'https://exmaple.com/test';
|
|
181
|
+
let source = new VideoSource(url, sourceDef);
|
|
182
|
+
let srcs = source.generateSources();
|
|
183
|
+
expect(srcs[0].src).toEqual(url);
|
|
184
|
+
expect(srcs[0].type).toEqual('video/mp4');
|
|
185
|
+
});
|
|
186
|
+
it('Test raw url with params', () => {
|
|
187
|
+
let sourceDef = {
|
|
188
|
+
cloudinaryConfig: cld
|
|
189
|
+
};
|
|
190
|
+
let url = 'https://exmaple.com/test.mp4?test=1234&user=eeeee&format=webm';
|
|
191
|
+
let source = new VideoSource(url, sourceDef);
|
|
192
|
+
source.sourceTypes(['webm']);
|
|
193
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
194
|
+
expect(srcs[0]).toEqual(url);
|
|
195
|
+
});
|
|
196
|
+
it('Test raw url with anchor', () => {
|
|
197
|
+
let sourceDef = {
|
|
198
|
+
cloudinaryConfig: cld
|
|
199
|
+
};
|
|
200
|
+
let url = 'https://exmaple.com/test.mp4#123454';
|
|
201
|
+
let source = new VideoSource(url, sourceDef);
|
|
202
|
+
source.sourceTypes(['webm']);
|
|
203
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
204
|
+
expect(srcs[0]).toEqual(url);
|
|
205
|
+
});
|
|
206
|
+
it('Test raw url with anchor', () => {
|
|
207
|
+
let sourceDef = {
|
|
208
|
+
cloudinaryConfig: cld
|
|
209
|
+
};
|
|
210
|
+
let url = 'https://exmaple.com/test.mp4#123454';
|
|
211
|
+
let source = new VideoSource(url, sourceDef);
|
|
212
|
+
source.sourceTypes(['webm']);
|
|
213
|
+
let srcs = source.generateSources().map(s => s.src);
|
|
214
|
+
expect(srcs[0]).toEqual(url);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('Test raw url adaptive m3u8', () => {
|
|
218
|
+
let sourceDef = {
|
|
219
|
+
cloudinaryConfig: cld
|
|
220
|
+
};
|
|
221
|
+
let url = 'https://exmaple.com/test.m3u8';
|
|
222
|
+
let source = new VideoSource(url, sourceDef);
|
|
223
|
+
let srcs = source.generateSources();
|
|
224
|
+
expect(srcs[0].src).toEqual(url);
|
|
225
|
+
expect(srcs[0].isAdaptive).toEqual(true);
|
|
226
|
+
expect(srcs[0].type).toEqual('application/x-mpegURL');
|
|
227
|
+
});
|
|
228
|
+
it('Test raw url adaptive hls', () => {
|
|
229
|
+
let sourceDef = {
|
|
230
|
+
cloudinaryConfig: cld
|
|
231
|
+
};
|
|
232
|
+
let url = 'https://exmaple.com/test';
|
|
233
|
+
let source = new VideoSource(url, sourceDef);
|
|
234
|
+
source.sourceTypes(['hls']);
|
|
235
|
+
let srcs = source.generateSources();
|
|
236
|
+
expect(srcs[0].src).toEqual(url);
|
|
237
|
+
expect(srcs[0].isAdaptive).toEqual(true);
|
|
238
|
+
expect(srcs[0].type).toEqual('application/x-mpegURL');
|
|
239
|
+
});
|
|
240
|
+
it('Test raw url adaptive mpd', () => {
|
|
241
|
+
let sourceDef = {
|
|
242
|
+
cloudinaryConfig: cld
|
|
243
|
+
};
|
|
244
|
+
let url = 'https://exmaple.com/test.mpd';
|
|
245
|
+
let source = new VideoSource(url, sourceDef);
|
|
246
|
+
let srcs = source.generateSources();
|
|
247
|
+
expect(srcs[0].src).toEqual(url);
|
|
248
|
+
expect(srcs[0].isAdaptive).toEqual(true);
|
|
249
|
+
expect(srcs[0].type).toEqual('application/dash+xml');
|
|
250
|
+
});
|
|
251
|
+
it('Test raw url adaptive dash', () => {
|
|
252
|
+
let sourceDef = {
|
|
253
|
+
cloudinaryConfig: cld
|
|
254
|
+
};
|
|
255
|
+
let url = 'https://exmaple.com/test';
|
|
256
|
+
let source = new VideoSource(url, sourceDef);
|
|
257
|
+
source.sourceTypes(['dash']);
|
|
258
|
+
let srcs = source.generateSources();
|
|
259
|
+
expect(srcs[0].src).toEqual(url);
|
|
260
|
+
expect(srcs[0].isAdaptive).toEqual(true);
|
|
261
|
+
expect(srcs[0].type).toEqual('application/dash+xml');
|
|
262
|
+
});
|
|
263
|
+
it('Should not break when calling generateSources() more then once', () => {
|
|
264
|
+
let sourceDef = {
|
|
265
|
+
cloudinaryConfig: cld
|
|
266
|
+
};
|
|
267
|
+
let url = 'https://exmaple.com/test';
|
|
268
|
+
let source = new VideoSource(url, sourceDef);
|
|
269
|
+
source.sourceTypes(['hls']);
|
|
270
|
+
source.generateSources();
|
|
271
|
+
let srcs = source.generateSources();
|
|
272
|
+
expect(srcs[0].src).toEqual(url);
|
|
273
|
+
expect(srcs[0].isAdaptive).toEqual(true);
|
|
274
|
+
expect(srcs[0].type).toEqual('application/x-mpegURL');
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
describe('tests withCredentials', () => {
|
|
278
|
+
it('test withCredentials true', () => {
|
|
279
|
+
let sourceDef = {
|
|
280
|
+
cloudinaryConfig: cld,
|
|
281
|
+
withCredentials: true
|
|
282
|
+
};
|
|
283
|
+
let source = new VideoSource('sea_turtle', sourceDef);
|
|
284
|
+
source.sourceTypes(['webm']);
|
|
285
|
+
let srcs = source.generateSources().map(s => s.withCredentials);
|
|
286
|
+
expect(srcs[0]).toEqual(true);
|
|
287
|
+
});
|
|
288
|
+
it('test withCredentials false', () => {
|
|
289
|
+
let sourceDef = {
|
|
290
|
+
cloudinaryConfig: cld,
|
|
291
|
+
withCredentials: false
|
|
292
|
+
};
|
|
293
|
+
let source = new VideoSource('sea_turtle', sourceDef);
|
|
294
|
+
source.sourceTypes(['webm']);
|
|
295
|
+
let srcs = source.generateSources().map(s => s.withCredentials);
|
|
296
|
+
expect(srcs[0]).toEqual(false);
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
describe('test isCodecAlreadyExist method', () => {
|
|
302
|
+
|
|
303
|
+
describe('test has codec in raw transformation', () => {
|
|
304
|
+
|
|
305
|
+
it('should codec already exist', () => {
|
|
306
|
+
expect(isCodecAlreadyExist(null, 'vc_vp9,q_auto')).toEqual(true);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
it('should codec not exist', () => {
|
|
310
|
+
expect(isCodecAlreadyExist(null, 'q_auto')).toEqual(false);
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
describe('test has codec in transformation object', () => {
|
|
316
|
+
|
|
317
|
+
it('codec exist in transformation object', () => {
|
|
318
|
+
const transformations = {
|
|
319
|
+
video_codec: 'vp9'
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
expect(isCodecAlreadyExist(transformations)).toEqual(true);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it('codec NOT exist in transformation object', () => {
|
|
326
|
+
|
|
327
|
+
const transformations = {
|
|
328
|
+
quality: 'auto'
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
expect(isCodecAlreadyExist(transformations)).toEqual(false);
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
describe('test if codec exist in transformations array', () => {
|
|
336
|
+
|
|
337
|
+
it('codec exist in transformation array', () => {
|
|
338
|
+
const transformations = [
|
|
339
|
+
{
|
|
340
|
+
toOptions: () => ({ transformation: ['vc_vp9,q_auto'] })
|
|
341
|
+
}
|
|
342
|
+
];
|
|
343
|
+
|
|
344
|
+
expect(isCodecAlreadyExist(transformations)).toEqual(true);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
it('codec NOT exist in transformation array', () => {
|
|
349
|
+
const transformations = [
|
|
350
|
+
{
|
|
351
|
+
toOptions: () => ({ transformation: ['q_auto'] })
|
|
352
|
+
}
|
|
353
|
+
];
|
|
354
|
+
|
|
355
|
+
expect(isCodecAlreadyExist(transformations)).toEqual(false);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
describe('should generated codec in source url', () => {
|
|
362
|
+
|
|
363
|
+
it('should get default code', () => {
|
|
364
|
+
|
|
365
|
+
const source = new VideoSource('sea_turtle', {
|
|
366
|
+
cloudinaryConfig: cld
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
const srcs = source.generateSources();
|
|
370
|
+
expect(srcs[0].src).toEqual('http://res.cloudinary.com/demo/video/upload/vc_vp9/sea_turtle.webm');
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it('check if codec has NOT bee added to the ur twice', () => {
|
|
374
|
+
|
|
375
|
+
const source = new VideoSource('sea_turtle', {
|
|
376
|
+
cloudinaryConfig: cld,
|
|
377
|
+
transformation: {
|
|
378
|
+
video_codec: 'vp9'
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
const srcs = source.generateSources();
|
|
383
|
+
expect(srcs[0].src).toEqual('http://res.cloudinary.com/demo/video/upload/vc_vp9/sea_turtle.webm');
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it('check if codec has been changed', () => {
|
|
387
|
+
|
|
388
|
+
const source = new VideoSource('sea_turtle', {
|
|
389
|
+
cloudinaryConfig: cld,
|
|
390
|
+
transformation: {
|
|
391
|
+
video_codec: 'h265'
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
const srcs = source.generateSources();
|
|
396
|
+
expect(srcs[0].src).toEqual('http://res.cloudinary.com/demo/video/upload/vc_h265/sea_turtle.webm');
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
it('check if codec has been NOT add twice using raw_transformation', () => {
|
|
401
|
+
|
|
402
|
+
const source = new VideoSource('sea_turtle', {
|
|
403
|
+
cloudinaryConfig: cld,
|
|
404
|
+
raw_transformation: 'vc_vp9'
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
const srcs = source.generateSources();
|
|
408
|
+
expect(srcs[0].src).toEqual('http://res.cloudinary.com/demo/video/upload/vc_vp9/sea_turtle.webm');
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
it('check if codec has been change using raw_transformation', () => {
|
|
412
|
+
|
|
413
|
+
const source = new VideoSource('sea_turtle', {
|
|
414
|
+
cloudinaryConfig: cld,
|
|
415
|
+
raw_transformation: 'h265'
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
const srcs = source.generateSources();
|
|
419
|
+
expect(srcs[0].src).toEqual('http://res.cloudinary.com/demo/video/upload/h265/sea_turtle.webm');
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
it('check array of transformations without codec', () => {
|
|
424
|
+
|
|
425
|
+
const source = new VideoSource('sea_turtle', {
|
|
426
|
+
cloudinaryConfig: cld,
|
|
427
|
+
transformation: [
|
|
428
|
+
{ width: 400 }
|
|
429
|
+
]
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
const srcs = source.generateSources();
|
|
433
|
+
expect(srcs[0].src).toEqual('http://res.cloudinary.com/demo/video/upload/vc_vp9/sea_turtle.webm');
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
it('check array of transformations with codec', () => {
|
|
437
|
+
|
|
438
|
+
const source = new VideoSource('sea_turtle', {
|
|
439
|
+
cloudinaryConfig: cld,
|
|
440
|
+
transformation: [
|
|
441
|
+
{ video_codec: 'h265' }
|
|
442
|
+
]
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
const srcs = source.generateSources();
|
|
446
|
+
expect(srcs[0].src).toEqual('http://res.cloudinary.com/demo/video/upload/vc_h265/sea_turtle.webm');
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
var video_player_1 = __importDefault(require("./video-player"));
|
|
7
|
+
var player = new video_player_1["default"]('player', {}, false);
|
|
8
|
+
player.source('test', {
|
|
9
|
+
sourceTypes: ['mp4/h264']
|
|
10
|
+
});
|
|
11
|
+
player.play();
|
|
12
|
+
player.currentPublicId(); // te
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is used to validate the type spec. The code is not actually run.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import VideoPlayer, {Options} from './video-player';
|
|
6
|
+
import {Cloudinary} from 'cloudinary-core';
|
|
7
|
+
|
|
8
|
+
let player: VideoPlayer = new VideoPlayer('player', {}, false);
|
|
9
|
+
player.source('test', {
|
|
10
|
+
sourceTypes: ['mp4/h264']
|
|
11
|
+
})
|
|
12
|
+
player.play();
|
|
13
|
+
player.currentPublicId();
|
|
14
|
+
player.pause()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
let player2 = new VideoPlayer('player2' , {
|
|
19
|
+
bigPlayButton: false,
|
|
20
|
+
}, false)
|
|
21
|
+
|
|
22
|
+
const cloudinaryApi = Cloudinary.new({cloud_name: 'demo', secure: true});
|
|
23
|
+
let pl = cloudinaryApi.videoPlayer('test',{bigPlayButton: true, controls: false});
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
interface VideoPlayerWithVideoJs extends VideoPlayer {
|
|
29
|
+
videojs: Options;
|
|
30
|
+
|
|
31
|
+
}
|