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,31 @@
|
|
|
1
|
+
// #if (!process.env.WEBPACK_BUILD_LIGHT)
|
|
2
|
+
import 'videojs-contrib-ads';
|
|
3
|
+
import './ima';
|
|
4
|
+
import dashPlugin from './dash';
|
|
5
|
+
import interactive from './interactive-plugin';
|
|
6
|
+
import './videojs-http-source-selector/plugin';
|
|
7
|
+
// #endif
|
|
8
|
+
|
|
9
|
+
import autoplayOnScroll from './autoplay-on-scroll';
|
|
10
|
+
import floatingPlayer from './floating-player';
|
|
11
|
+
import colors from './colors';
|
|
12
|
+
import contextMenu from './context-menu';
|
|
13
|
+
import cloudinary from './cloudinary';
|
|
14
|
+
import analytics from './analytics';
|
|
15
|
+
import vttThumbnails from './vtt-thumbnails';
|
|
16
|
+
|
|
17
|
+
const plugins = {
|
|
18
|
+
autoplayOnScroll,
|
|
19
|
+
floatingPlayer,
|
|
20
|
+
colors,
|
|
21
|
+
contextMenu,
|
|
22
|
+
cloudinary,
|
|
23
|
+
analytics,
|
|
24
|
+
vttThumbnails,
|
|
25
|
+
// #if (!process.env.WEBPACK_BUILD_LIGHT)
|
|
26
|
+
interactive,
|
|
27
|
+
dashPlugin
|
|
28
|
+
// #endif
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default plugins;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import ShoppableWidget from '../../components/shoppable-bar/shoppable-widget';
|
|
2
|
+
|
|
3
|
+
export default function interactivePlugin(player, options) {
|
|
4
|
+
|
|
5
|
+
// Shoppable Video
|
|
6
|
+
if (options.shoppable) {
|
|
7
|
+
new ShoppableWidget(player, options.shoppable).init();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import videojs from 'video.js';
|
|
2
|
+
import SourceMenuItem from './SourceMenuItem';
|
|
3
|
+
|
|
4
|
+
const MenuButton = videojs.getComponent('MenuButton');
|
|
5
|
+
|
|
6
|
+
class SourceMenuButton extends MenuButton {
|
|
7
|
+
|
|
8
|
+
constructor(player, options) {
|
|
9
|
+
super(player, options);
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line prefer-rest-params
|
|
12
|
+
MenuButton.apply(this, arguments);
|
|
13
|
+
|
|
14
|
+
const qualityLevels = this.player().qualityLevels();
|
|
15
|
+
|
|
16
|
+
// Handle options: We accept an options.default value of ( high || low )
|
|
17
|
+
// This determines a bias to set initial resolution selection.
|
|
18
|
+
if (options && options.default) {
|
|
19
|
+
if (options.default === 'low') {
|
|
20
|
+
for (let i = 0; i < qualityLevels.length; i++) {
|
|
21
|
+
qualityLevels[i].enabled = (i === 0);
|
|
22
|
+
}
|
|
23
|
+
} else if (options.default === 'high') {
|
|
24
|
+
for (let i = 0; i < qualityLevels.length; i++) {
|
|
25
|
+
qualityLevels[i].enabled = (i === (qualityLevels.length - 1));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Bind update to qualityLevels changes
|
|
31
|
+
this.player().qualityLevels().on(['addqualitylevel'], videojs.bind(this, this.update));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
createEl() {
|
|
35
|
+
return videojs.dom.createEl('div', {
|
|
36
|
+
className: 'vjs-http-source-selector vjs-menu-button vjs-menu-button-popup vjs-control vjs-button'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
buildCSSClass() {
|
|
41
|
+
return MenuButton.prototype.buildCSSClass.call(this) + ' vjs-icon-cog';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
update() {
|
|
45
|
+
return MenuButton.prototype.update.call(this);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
createItems() {
|
|
49
|
+
const menuItems = [];
|
|
50
|
+
const levels = this.player().qualityLevels();
|
|
51
|
+
const labels = [];
|
|
52
|
+
|
|
53
|
+
for (let i = 0; i < levels.length; i++) {
|
|
54
|
+
let index = levels.length - (i + 1);
|
|
55
|
+
let selected = (index === levels.selectedIndex);
|
|
56
|
+
|
|
57
|
+
// Display height if height metadata is provided with the stream, else use bitrate
|
|
58
|
+
let label = `${index}`;
|
|
59
|
+
let sortVal = index;
|
|
60
|
+
if (levels[index].height) {
|
|
61
|
+
label = `${levels[index].height}p`;
|
|
62
|
+
sortVal = parseInt(levels[index].height, 10);
|
|
63
|
+
} else if (levels[index].bitrate) {
|
|
64
|
+
label = `${Math.floor(levels[index].bitrate / 1e3)} kbps`;
|
|
65
|
+
sortVal = parseInt(levels[index].bitrate, 10);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Skip duplicate labels
|
|
69
|
+
if (labels.indexOf(label) >= 0) {
|
|
70
|
+
// eslint-disable-next-line no-continue
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
labels.push(label);
|
|
74
|
+
|
|
75
|
+
menuItems.push(new SourceMenuItem(this.player_, { label, index, selected, sortVal }));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// If there are multiple quality levels, offer an 'auto' option
|
|
79
|
+
if (levels.length > 1) {
|
|
80
|
+
menuItems.push(new SourceMenuItem(this.player_, { label: 'Auto', index: levels.length, selected: false, sortVal: 99999 }));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Sort menu items by their label name with Auto always first
|
|
84
|
+
menuItems.sort(function(a, b) {
|
|
85
|
+
if (a.options_.sortVal < b.options_.sortVal) {
|
|
86
|
+
return 1;
|
|
87
|
+
} else if (a.options_.sortVal > b.options_.sortVal) {
|
|
88
|
+
return -1;
|
|
89
|
+
} else {
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return menuItems;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default SourceMenuButton;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import videojs from 'video.js';
|
|
2
|
+
const MenuItem = videojs.getComponent('MenuItem');
|
|
3
|
+
const Component = videojs.getComponent('Component');
|
|
4
|
+
|
|
5
|
+
class SourceMenuItem extends MenuItem {
|
|
6
|
+
constructor(player, options) {
|
|
7
|
+
options.selectable = true;
|
|
8
|
+
options.multiSelectable = false;
|
|
9
|
+
|
|
10
|
+
super(player, options);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
handleClick() {
|
|
14
|
+
const selected = this.options_;
|
|
15
|
+
console.log('Changing quality to:', selected.label);
|
|
16
|
+
super.handleClick();
|
|
17
|
+
|
|
18
|
+
let levels = this.player().qualityLevels();
|
|
19
|
+
let isAuto = selected.index === levels.length;
|
|
20
|
+
for (let i = 0; i < levels.length; i++) {
|
|
21
|
+
if (isAuto) {
|
|
22
|
+
// If this is the Auto option, enable all renditions for adaptive selection
|
|
23
|
+
levels[i].enabled = true;
|
|
24
|
+
} else if (selected.index === i) {
|
|
25
|
+
levels[i].enabled = true;
|
|
26
|
+
} else {
|
|
27
|
+
levels[i].enabled = false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (isAuto) {
|
|
31
|
+
this.deselectRest(6);
|
|
32
|
+
} else {
|
|
33
|
+
this.deselectRest(selected.index);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
deselectRest(idx) {
|
|
38
|
+
if (this.parentComponent_) {
|
|
39
|
+
this.parentComponent_.children().forEach((item) => {
|
|
40
|
+
item.selected(idx === item.options_.index);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
update() {
|
|
46
|
+
let selectedIndex = this.player().qualityLevels().selectedIndex;
|
|
47
|
+
this.selected(this.options_.index === selectedIndex);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Component.registerComponent('SourceMenuItem', SourceMenuItem);
|
|
52
|
+
export default SourceMenuItem;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import videojs from 'video.js';
|
|
2
|
+
|
|
3
|
+
import SourceMenuButton from './components/SourceMenuButton';
|
|
4
|
+
import SourceMenuItem from './components/SourceMenuItem';
|
|
5
|
+
|
|
6
|
+
// Default options for the plugin.
|
|
7
|
+
const defaults = {};
|
|
8
|
+
|
|
9
|
+
// Cross-compatibility for Video.js 5 and 6.
|
|
10
|
+
const registerPlugin = videojs.registerPlugin || videojs.plugin;
|
|
11
|
+
// const dom = videojs.dom || videojs;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Function to invoke when the player is ready.
|
|
15
|
+
*
|
|
16
|
+
* This is a great place for your plugin to initialize itself. When this
|
|
17
|
+
* function is called, the player will have its DOM and child components
|
|
18
|
+
* in place.
|
|
19
|
+
*
|
|
20
|
+
* @function onPlayerReady
|
|
21
|
+
* @param {Player} player
|
|
22
|
+
* A Video.js player object.
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} [options={}]
|
|
25
|
+
* A plain object containing options for the plugin.
|
|
26
|
+
*/
|
|
27
|
+
const onPlayerReady = (player) => {
|
|
28
|
+
player.addClass('vjs-http-source-selector');
|
|
29
|
+
console.log('videojs-http-source-selector initialized!');
|
|
30
|
+
|
|
31
|
+
console.log('player.techName_:' + player.techName_);
|
|
32
|
+
// This plugin only supports level selection for HLS playback
|
|
33
|
+
if (player.techName_ !== 'Html5') {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* We have to wait for the manifest to load before we can scan renditions for resolutions/bitrates to populate selections
|
|
40
|
+
*
|
|
41
|
+
**/
|
|
42
|
+
player.on(['loadedmetadata'], function() {
|
|
43
|
+
videojs.log('loadmetadata event');
|
|
44
|
+
// hack for plugin idempodency... prevents duplicate menubuttons from being inserted into the player if multiple player.httpSourceSelector() functions called.
|
|
45
|
+
if (player.videojs_http_source_selector_initialized === 'undefined' || player.videojs_http_source_selector_initialized === true) {
|
|
46
|
+
console.log('player.videojs_http_source_selector_initialized == true');
|
|
47
|
+
} else {
|
|
48
|
+
console.log('player.videojs_http_source_selector_initialized == false');
|
|
49
|
+
player.videojs_http_source_selector_initialized = true;
|
|
50
|
+
const controlBar = player.controlBar,
|
|
51
|
+
fullscreenToggle = controlBar.getChild('fullscreenToggle').el();
|
|
52
|
+
controlBar.el().insertBefore(controlBar.addChild('SourceMenuButton').el(), fullscreenToggle);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A video.js plugin.
|
|
59
|
+
*
|
|
60
|
+
* In the plugin function, the value of `this` is a video.js `Player`
|
|
61
|
+
* instance. You cannot rely on the player being in a "ready" state here,
|
|
62
|
+
* depending on how the plugin is invoked. This may or may not be important
|
|
63
|
+
* to you; if not, remove the wait for "ready"!
|
|
64
|
+
*
|
|
65
|
+
* @function httpSourceSelector
|
|
66
|
+
* @param {Object} [options={}]
|
|
67
|
+
* An object of options left to the plugin author to define.
|
|
68
|
+
*/
|
|
69
|
+
const httpSourceSelector = function(options) {
|
|
70
|
+
this.ready(() => {
|
|
71
|
+
onPlayerReady(this, videojs.mergeOptions(defaults, options));
|
|
72
|
+
// this.getChild('controlBar').addChild('SourceMenuButton', {});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
videojs.registerComponent('SourceMenuButton', SourceMenuButton);
|
|
76
|
+
videojs.registerComponent('SourceMenuItem', SourceMenuItem);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Register the plugin with video.js.
|
|
80
|
+
registerPlugin('httpSourceSelector', httpSourceSelector);
|
|
81
|
+
|
|
82
|
+
export default httpSourceSelector;
|