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,16 @@
|
|
|
1
|
+
import PlaylistLayout from './playlist-layout';
|
|
2
|
+
|
|
3
|
+
class PlaylistLayoutHorizontal extends PlaylistLayout {
|
|
4
|
+
constructor (player, options) {
|
|
5
|
+
options.wrap = true;
|
|
6
|
+
super(player, options);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getCls() {
|
|
10
|
+
const cls = super.getCls();
|
|
11
|
+
cls.push('cld-plw-horizontal');
|
|
12
|
+
return cls;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default PlaylistLayoutHorizontal;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import PlaylistLayout from './playlist-layout';
|
|
2
|
+
|
|
3
|
+
class PlaylistLayoutVertical extends PlaylistLayout {
|
|
4
|
+
|
|
5
|
+
constructor (player, options) {
|
|
6
|
+
options.wrap = true;
|
|
7
|
+
super(player, options);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
getCls() {
|
|
11
|
+
const cls = super.getCls();
|
|
12
|
+
cls.push('cld-plw-vertical');
|
|
13
|
+
|
|
14
|
+
return cls;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export default PlaylistLayoutVertical;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import videojs from 'video.js';
|
|
2
|
+
import { wrap } from '../../../utils/dom';
|
|
3
|
+
import {
|
|
4
|
+
skinClassPrefix,
|
|
5
|
+
playerClassPrefix
|
|
6
|
+
} from '../../../utils/css-prefix';
|
|
7
|
+
|
|
8
|
+
const dom = videojs.dom || videojs;
|
|
9
|
+
const Component = videojs.getComponent('Component');
|
|
10
|
+
|
|
11
|
+
const OPTIONS_DEFAULT = {
|
|
12
|
+
wrap: false
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
class PlaylistLayout extends Component {
|
|
16
|
+
constructor(player, options) {
|
|
17
|
+
const layoutOptions = { ...OPTIONS_DEFAULT, ...options };
|
|
18
|
+
super(player, layoutOptions);
|
|
19
|
+
this.player_ = player;
|
|
20
|
+
this.setCls();
|
|
21
|
+
|
|
22
|
+
const fluidHandler = (e, fluid) => {
|
|
23
|
+
this.options_.fluid = fluid;
|
|
24
|
+
this.removeCls();
|
|
25
|
+
this.setCls();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const wrapVideoWithLayout = () => {
|
|
29
|
+
const el = this.el();
|
|
30
|
+
|
|
31
|
+
this.videoWrap_ = dom.createEl('div', { className: 'cld-plw-col-player' });
|
|
32
|
+
this.contentEl_ = this.contentEl_ = dom.createEl('div', { className: 'cld-plw-col-list' });
|
|
33
|
+
|
|
34
|
+
wrap(this.player().el(), el);
|
|
35
|
+
|
|
36
|
+
el.appendChild(this.videoWrap_);
|
|
37
|
+
el.appendChild(this.contentEl_);
|
|
38
|
+
|
|
39
|
+
wrap(this.player().el(), this.videoWrap_);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
if (layoutOptions.wrap) {
|
|
43
|
+
wrapVideoWithLayout();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
player.on('fluid', fluidHandler);
|
|
47
|
+
|
|
48
|
+
this.addChild('PlaylistPanel', this.options_);
|
|
49
|
+
|
|
50
|
+
this.dispose = () => {
|
|
51
|
+
this.removeLayout();
|
|
52
|
+
super.dispose();
|
|
53
|
+
player.off('fluid', fluidHandler);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
getCls() {
|
|
58
|
+
let cls = ['cld-video-player', 'cld-plw-layout'];
|
|
59
|
+
|
|
60
|
+
cls.push(skinClassPrefix(this.player()));
|
|
61
|
+
cls.push(playerClassPrefix(this.player()));
|
|
62
|
+
|
|
63
|
+
if (this.options_.fluid) {
|
|
64
|
+
cls.push('cld-plw-layout-fluid');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return cls;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
setCls() {
|
|
71
|
+
this.removeClass(skinClassPrefix(this));
|
|
72
|
+
this.getCls().forEach((cls) => {
|
|
73
|
+
this.addClass(cls);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
removeCls() {
|
|
78
|
+
this.getCls().forEach((cls) => {
|
|
79
|
+
this.removeClass(cls);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
update(optionToChange, options) {
|
|
84
|
+
this.options(options);
|
|
85
|
+
this.removeChild('PlaylistPanel');
|
|
86
|
+
this.addChild('PlaylistPanel', this.options_);
|
|
87
|
+
this.trigger('playlistlayoutupdate');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
removeLayout() {
|
|
91
|
+
const parentElem = this.el().parentElement;
|
|
92
|
+
if (parentElem) {
|
|
93
|
+
parentElem.appendChild(this.player().el());
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
createEl() {
|
|
98
|
+
const el = super.createEl('div');
|
|
99
|
+
|
|
100
|
+
// Apply font styles on wrapper div.
|
|
101
|
+
el.style.fontFamily = this.player().el().style.fontFamily;
|
|
102
|
+
|
|
103
|
+
return el;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
videojs.registerComponent('playlistLayout', PlaylistLayout);
|
|
109
|
+
|
|
110
|
+
export default PlaylistLayout;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import videojs from 'video.js';
|
|
2
|
+
import Thumbnail from '../thumbnail/thumbnail';
|
|
3
|
+
|
|
4
|
+
const dom = videojs.dom || videojs;
|
|
5
|
+
|
|
6
|
+
const DEFAULT_OPTIONS = {
|
|
7
|
+
source: null,
|
|
8
|
+
next: false
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
class PlaylistPanelItem extends Thumbnail {
|
|
12
|
+
|
|
13
|
+
constructor(player, initOptions) {
|
|
14
|
+
const options = videojs.mergeOptions(DEFAULT_OPTIONS, initOptions);
|
|
15
|
+
super(player, options);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
handleClick(event) {
|
|
19
|
+
super.handleClick(event);
|
|
20
|
+
this.play();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
play() {
|
|
24
|
+
const item = this.getItem();
|
|
25
|
+
const list = this.player().cloudinary.playlist().list();
|
|
26
|
+
const index = list.indexOf(item);
|
|
27
|
+
|
|
28
|
+
if (index === -1) {
|
|
29
|
+
throw new Error('Invalid playlist item...');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.player().cloudinary.playlist().playAtIndex(index);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
isCurrent() {
|
|
36
|
+
return this.options_.current;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getTitle() {
|
|
40
|
+
return super.getTitle();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getDuration() {
|
|
44
|
+
return super.getDuration();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
createEl() {
|
|
48
|
+
const el = super.createEl();
|
|
49
|
+
|
|
50
|
+
el.classList.add('cld-plw-panel-item');
|
|
51
|
+
|
|
52
|
+
const info = dom.createEl('div', { className: 'cld-plw-item-info-wrap' });
|
|
53
|
+
const titleWrap = dom.createEl('div', { className: 'cld-plw-item-title' });
|
|
54
|
+
|
|
55
|
+
if (this.isCurrent()) {
|
|
56
|
+
el.classList.add('cld-plw-panel-item-active');
|
|
57
|
+
|
|
58
|
+
const currEl = dom.createEl('span', {
|
|
59
|
+
className: 'cld-plw-item-title-curr'
|
|
60
|
+
}, {}, 'Now Playing: ');
|
|
61
|
+
|
|
62
|
+
titleWrap.appendChild(currEl);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const title = dom.createEl('span', { className: 'cld-plw-item-title' }, {}, this.getTitle());
|
|
66
|
+
|
|
67
|
+
titleWrap.appendChild(title);
|
|
68
|
+
|
|
69
|
+
const duration = dom.createEl('div', { className: 'cld-plw-item-duration' }, {}, this.getDuration());
|
|
70
|
+
|
|
71
|
+
info.appendChild(titleWrap);
|
|
72
|
+
info.appendChild(duration);
|
|
73
|
+
|
|
74
|
+
if (el) {
|
|
75
|
+
el.appendChild(info);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
el.appendChild(info);
|
|
79
|
+
|
|
80
|
+
return el;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
videojs.registerComponent('playlistPanelItem', PlaylistPanelItem);
|
|
85
|
+
|
|
86
|
+
export default PlaylistPanelItem;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import videojs from 'video.js';
|
|
2
|
+
import 'assets/styles/components/playlist.scss';
|
|
3
|
+
import PlaylistPanelItem from './playlist-panel-item';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const Component = videojs.getComponent('Component');
|
|
7
|
+
|
|
8
|
+
class PlaylistPanel extends Component {
|
|
9
|
+
|
|
10
|
+
constructor(player, options = {}) {
|
|
11
|
+
super(player, options);
|
|
12
|
+
|
|
13
|
+
const itemChangeHandler = () => {
|
|
14
|
+
this.render();
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
player.on('playlistitemchanged', itemChangeHandler);
|
|
18
|
+
|
|
19
|
+
this.render();
|
|
20
|
+
|
|
21
|
+
this.dispose = () => {
|
|
22
|
+
super.dispose();
|
|
23
|
+
player.off('playlistitemchanged', itemChangeHandler);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
createEl() {
|
|
28
|
+
const el = super.createEl();
|
|
29
|
+
el.classList.add('cld-plw-panel');
|
|
30
|
+
|
|
31
|
+
return el;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
removeAll() {
|
|
35
|
+
const childrens = this.children();
|
|
36
|
+
for (let i = childrens.length - 1; i >= 0; --i) {
|
|
37
|
+
this.removeChild(childrens[i]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getItems() {
|
|
42
|
+
const playlist = this.player().cloudinary.playlist();
|
|
43
|
+
const repeat = playlist._repeat;
|
|
44
|
+
|
|
45
|
+
if (this.options_.showAll) {
|
|
46
|
+
return playlist.list();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const items = [];
|
|
50
|
+
const numOfItems = this.options_.total;
|
|
51
|
+
let index = playlist.currentIndex();
|
|
52
|
+
let source = playlist.list()[index];
|
|
53
|
+
items.push(source);
|
|
54
|
+
|
|
55
|
+
while (items.length < numOfItems) {
|
|
56
|
+
index = playlist.nextIndex(index);
|
|
57
|
+
if (index === -1) {
|
|
58
|
+
if (!repeat && items.length > 0) {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
index = 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
source = playlist.list()[index];
|
|
66
|
+
items.push(source);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return items;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
render() {
|
|
73
|
+
const items = this.getItems();
|
|
74
|
+
|
|
75
|
+
this.removeAll();
|
|
76
|
+
|
|
77
|
+
items.forEach((source, index) => {
|
|
78
|
+
const playlistItem = new PlaylistPanelItem(this.player(), videojs.mergeOptions(this.options_, {
|
|
79
|
+
item: source,
|
|
80
|
+
next: index === 1,
|
|
81
|
+
current: index === 0
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
this.addChild(playlistItem);
|
|
85
|
+
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
videojs.registerComponent('playlistPanel', PlaylistPanel);
|
|
91
|
+
|
|
92
|
+
export default PlaylistPanel;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import videojs from 'video.js';
|
|
2
|
+
import PlaylistLayoutHorizontal from './layout/playlist-layout-horizontal';
|
|
3
|
+
import PlaylistLayoutVertical from './layout/playlist-layout-vertical';
|
|
4
|
+
import PlaylistLayoutCustom from './layout/playlist-layout-custom';
|
|
5
|
+
import { PLAYLIST_DEFAULTS_OPTIONS } from './playlist.const';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const modifyOptions = (player, opt) => {
|
|
9
|
+
const options = { ...PLAYLIST_DEFAULTS_OPTIONS, ...opt };
|
|
10
|
+
|
|
11
|
+
if (options.show && typeof options.selector === 'string') {
|
|
12
|
+
options.useDefaultLayout = false;
|
|
13
|
+
options.useCustomLayout = true;
|
|
14
|
+
options.renderTo = document.querySelector(options.selector);
|
|
15
|
+
options.showAll = true;
|
|
16
|
+
|
|
17
|
+
if (!options.renderTo.length === 0) {
|
|
18
|
+
throw new Error(`Couldn't find element(s) by selector '${options.selector}' for playlist`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (options.show && !options.selector) {
|
|
23
|
+
options.useDefaultLayout = true;
|
|
24
|
+
options.useCustomLayout = false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
options.direction = options.direction.toLowerCase() === 'horizontal' ? 'horizontal' : 'vertical';
|
|
28
|
+
|
|
29
|
+
options.skin = player.options_.skin;
|
|
30
|
+
|
|
31
|
+
return options;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class PlaylistWidget {
|
|
36
|
+
constructor(player, options = {}) {
|
|
37
|
+
options = modifyOptions(player, options);
|
|
38
|
+
this.options_ = options;
|
|
39
|
+
this.player_ = player;
|
|
40
|
+
this.render();
|
|
41
|
+
|
|
42
|
+
const fluidHandler = (e, fluid) => {
|
|
43
|
+
this.options_.fluid = fluid;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
player.on('fluid', fluidHandler);
|
|
47
|
+
|
|
48
|
+
this.options = (options) => {
|
|
49
|
+
if (!options) {
|
|
50
|
+
return this.options_;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.options_ = videojs.mergeOptions(this.options_, options);
|
|
54
|
+
player.trigger('playlistwidgetoption', this.options_.playlistWidget);
|
|
55
|
+
return this.options_;
|
|
56
|
+
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
this.dispose = () => {
|
|
60
|
+
this.layout_.dispose();
|
|
61
|
+
player.off('fluid', fluidHandler);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
render() {
|
|
66
|
+
if (this.options_.useDefaultLayout) {
|
|
67
|
+
if (this.options_.direction === 'horizontal') {
|
|
68
|
+
this.layout_ = new PlaylistLayoutHorizontal(this.player_, this.options_);
|
|
69
|
+
} else {
|
|
70
|
+
this.layout_ = new PlaylistLayoutVertical(this.player_, this.options_);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (this.options_.useCustomLayout) {
|
|
75
|
+
this.layout_ = new PlaylistLayoutCustom(this.player_, this.options_);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
getLayout() {
|
|
80
|
+
return this.layout_;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
update(optionName, optionValue) {
|
|
84
|
+
this.options(optionValue);
|
|
85
|
+
|
|
86
|
+
if (optionName === 'direction') {
|
|
87
|
+
this.layout_.removeLayout();
|
|
88
|
+
this.layout_.dispose();
|
|
89
|
+
this.render();
|
|
90
|
+
} else {
|
|
91
|
+
this.layout_.update(optionName, this.options_);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
setSkin() {
|
|
96
|
+
this.layout_.setCls();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
total(totalNumber = PLAYLIST_DEFAULTS_OPTIONS.total) {
|
|
100
|
+
const total = parseInt(totalNumber, 10);
|
|
101
|
+
|
|
102
|
+
if (total !== this.options_.total && typeof total === 'number' && total > 0) {
|
|
103
|
+
this.update('total', { total: total });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
direction(direction = PLAYLIST_DEFAULTS_OPTIONS.direction) {
|
|
110
|
+
if (direction === 'horizontal' || direction === 'vertical') {
|
|
111
|
+
this.update('direction', { direction: direction });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
export default PlaylistWidget;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const DEFAULT_AUTO_ADVANCE = 0;
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_PRESENT_UPCOMING = 10;
|
|
4
|
+
|
|
5
|
+
export const UPCOMING_VIDEO_TRANSITION = 1;
|
|
6
|
+
|
|
7
|
+
export const PLAYLIST_DEFAULTS_OPTIONS = {
|
|
8
|
+
fluid: false,
|
|
9
|
+
show: true,
|
|
10
|
+
direction: 'vertical',
|
|
11
|
+
total: 4,
|
|
12
|
+
selector: false,
|
|
13
|
+
renderTo: []
|
|
14
|
+
};
|