cloudinary-video-player 3.12.1 → 3.12.2-edge.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/134.min.js +8 -0
- package/dist/309.min.js +6 -0
- package/dist/adaptive-streaming.js +9 -9
- package/dist/adaptive-streaming.min.js +2 -2
- package/dist/chapters.js +4 -4
- package/dist/chapters.min.js +3 -3
- package/dist/cld-player-core.js +37 -0
- package/dist/cld-player-core.min.js +6 -0
- package/dist/cld-video-player-lazy.js +494 -0
- package/dist/cld-video-player-lazy.min.js +6 -0
- package/dist/cld-video-player.css +2 -2
- package/dist/cld-video-player.js +366 -332
- package/dist/cld-video-player.light.js +366 -332
- package/dist/cld-video-player.light.min.js +4 -4
- package/dist/cld-video-player.min.css +2 -2
- package/dist/cld-video-player.min.js +4 -4
- package/dist/colors.js +4 -4
- package/dist/colors.min.js +2 -2
- package/dist/dash.js +6 -6
- package/dist/dash.min.js +2 -2
- package/dist/debug.js +8 -8
- package/dist/debug.min.js +3 -3
- package/dist/ima.js +9 -9
- package/dist/ima.min.js +2 -2
- package/dist/interaction-areas.js +11 -11
- package/dist/interaction-areas.min.js +2 -2
- package/dist/node_modules_lodash_throttle_js.js +8 -8
- package/dist/playlist.js +31 -31
- package/dist/playlist.min.js +3 -3
- package/dist/recommendations-overlay.js +10 -10
- package/dist/recommendations-overlay.min.js +2 -2
- package/dist/schema.json +19 -0
- package/dist/share.js +5 -5
- package/dist/share.min.js +3 -3
- package/dist/shoppable.js +12 -12
- package/dist/shoppable.min.js +2 -2
- package/dist/utils_fetch-config_js.js +81 -0
- package/dist/video-player_js.js +3111 -0
- package/dist/visual-search.js +7 -7
- package/dist/visual-search.min.js +2 -2
- package/lib/_commonjsHelpers.js +7 -0
- package/lib/_videojs-proxy.js +30294 -0
- package/lib/abr-strategies.js +31 -0
- package/lib/adaptive-streaming.js +468 -2
- package/lib/all.js +25 -2
- package/lib/chapters.js +205 -1
- package/lib/cld-video-player.min.css +5 -22
- package/lib/colors.js +59 -1
- package/lib/{schema.json → config/configSchema.json} +19 -0
- package/lib/dash.js +69943 -2
- package/lib/debug.js +322 -1
- package/lib/document.js +770 -0
- package/lib/download-button.js +48 -0
- package/lib/fetch-config.js +93 -0
- package/lib/ima.js +6851 -1
- package/lib/index.js +27 -0
- package/lib/interaction-areas.const.js +24 -0
- package/lib/interaction-areas.service.js +469 -0
- package/lib/lazy.js +20 -0
- package/lib/noop.js +33 -0
- package/lib/player-api.js +469 -0
- package/lib/player.js +7 -2
- package/lib/playlist-panel.js +602 -0
- package/lib/playlist.js +637 -1
- package/lib/querystring.js +81 -0
- package/lib/recommendations-overlay.js +320 -1
- package/lib/share.js +129 -1
- package/lib/shoppable-post-widget.js +572 -0
- package/lib/shoppable-widget.js +77 -0
- package/lib/throttle.js +318 -0
- package/lib/toNumber.js +134 -0
- package/lib/validators-functions.js +485 -0
- package/lib/video-player.js +16241 -0
- package/lib/videoPlayer.js +7 -2
- package/lib/videojs-contrib-hlsjs.js +37638 -0
- package/lib/visual-search.js +235 -1
- package/package.json +31 -15
- package/lib/adaptive-streaming.js.LICENSE.txt +0 -3
- package/lib/all.js.LICENSE.txt +0 -25
- package/lib/cld-video-player.js +0 -2
- package/lib/cld-video-player.js.LICENSE.txt +0 -21
- package/lib/dash.js.LICENSE.txt +0 -1842
- package/lib/interaction-areas.js +0 -1
- package/lib/player.js.LICENSE.txt +0 -21
- package/lib/shoppable.js +0 -1
- package/lib/videoPlayer.js.LICENSE.txt +0 -21
package/lib/chapters.js
CHANGED
|
@@ -1 +1,205 @@
|
|
|
1
|
-
|
|
1
|
+
import { _ as _vjs } from './_videojs-proxy.js';
|
|
2
|
+
import './video-player.js';
|
|
3
|
+
import './validators-functions.js';
|
|
4
|
+
import { g as getCloudinaryUrlPrefix } from './player-api.js';
|
|
5
|
+
import { u as utf8ToBase64, a as appendQueryParams } from './querystring.js';
|
|
6
|
+
import './_commonjsHelpers.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Chapters plugin.
|
|
10
|
+
*
|
|
11
|
+
* @function chapters
|
|
12
|
+
* @param {Object} [options={}]
|
|
13
|
+
* An object of options left to the plugin author to define.
|
|
14
|
+
* @param {Player} player
|
|
15
|
+
* A Video.js player object.
|
|
16
|
+
*/
|
|
17
|
+
const chapters = function chapters(options, player) {
|
|
18
|
+
player.addClass('vjs-chapters');
|
|
19
|
+
player.chapters = new ChaptersPlugin(player, options);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Chapters
|
|
24
|
+
*/
|
|
25
|
+
const ChaptersPlugin = function () {
|
|
26
|
+
/**
|
|
27
|
+
* Plugin class constructor, called by videojs on
|
|
28
|
+
* ready event.
|
|
29
|
+
*
|
|
30
|
+
* @function constructor
|
|
31
|
+
* @param {Player} player
|
|
32
|
+
* A Video.js player object.
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} [options={}]
|
|
35
|
+
* A plain object containing options for the plugin.
|
|
36
|
+
*/
|
|
37
|
+
function ChaptersPlugin(player, options) {
|
|
38
|
+
this.player = player;
|
|
39
|
+
this.options = options;
|
|
40
|
+
this.player.one('loadedmetadata', this.initializeChapters.bind(this));
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
ChaptersPlugin.prototype.src = function src(options) {
|
|
44
|
+
this.resetPlugin();
|
|
45
|
+
this.options = options;
|
|
46
|
+
this.player.one('loadedmetadata', this.initializeChapters.bind(this));
|
|
47
|
+
};
|
|
48
|
+
ChaptersPlugin.prototype.detach = function detach() {
|
|
49
|
+
this.resetPlugin();
|
|
50
|
+
};
|
|
51
|
+
ChaptersPlugin.prototype.resetPlugin = function resetPlugin() {
|
|
52
|
+
if (this.chaptersTrack) {
|
|
53
|
+
this.player.$('.vjs-control-bar-chapter-display').remove();
|
|
54
|
+
this.player.$('.vjs-chapter-display').remove();
|
|
55
|
+
this.player.$$('.vjs-chapter-marker').forEach(el => el.remove());
|
|
56
|
+
this.player.removeRemoteTextTrack(this.chaptersTrack);
|
|
57
|
+
delete this.chaptersTrack;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
ChaptersPlugin.prototype.getChaptersFileUrlByName = function getChaptersFileUrlByName() {
|
|
61
|
+
const currentPublicId = this.player.cloudinary.currentPublicId();
|
|
62
|
+
if (!currentPublicId) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const source = this.player.cloudinary.source();
|
|
66
|
+
const {
|
|
67
|
+
type: deliveryType
|
|
68
|
+
} = source.resourceConfig();
|
|
69
|
+
const urlPrefix = getCloudinaryUrlPrefix(this.player.cloudinary.cloudinaryConfig());
|
|
70
|
+
const fullUrl = `${urlPrefix}/_applet_/video_service/chapters/${deliveryType}/${utf8ToBase64(currentPublicId)}.vtt`;
|
|
71
|
+
return appendQueryParams(fullUrl, source.queryParams());
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Bootstrap the plugin.
|
|
76
|
+
*/
|
|
77
|
+
ChaptersPlugin.prototype.initializeChapters = async function initializeChapters() {
|
|
78
|
+
const chaptersUrl = this.options === true ? this.getChaptersFileUrlByName() : this.options.url;
|
|
79
|
+
if (chaptersUrl) {
|
|
80
|
+
// Fetch chapters VTT from URL
|
|
81
|
+
const chaptersTrack = {
|
|
82
|
+
kind: 'chapters',
|
|
83
|
+
src: chaptersUrl,
|
|
84
|
+
default: true
|
|
85
|
+
};
|
|
86
|
+
const textTrack = this.player.addRemoteTextTrack(chaptersTrack);
|
|
87
|
+
textTrack.addEventListener('load', () => {
|
|
88
|
+
this.chaptersTrack = textTrack.track;
|
|
89
|
+
this.setupChaptersDisplays();
|
|
90
|
+
});
|
|
91
|
+
} else if (Object.entries(this.options).length) {
|
|
92
|
+
// Setup chapters from options
|
|
93
|
+
const textTrack = this.player.addRemoteTextTrack({
|
|
94
|
+
kind: 'chapters',
|
|
95
|
+
default: true
|
|
96
|
+
});
|
|
97
|
+
const end = this.player.duration();
|
|
98
|
+
Object.entries(this.options).forEach((entry, index, arr) => {
|
|
99
|
+
const cue = new VTTCue(parseFloat(entry[0]), parseFloat(arr[index + 1] ? arr[index + 1][0] : end), entry[1]);
|
|
100
|
+
textTrack.track.addCue(cue);
|
|
101
|
+
});
|
|
102
|
+
this.chaptersTrack = textTrack.track;
|
|
103
|
+
this.setupChaptersDisplays();
|
|
104
|
+
if (this.player.controlBar.chaptersButton) {
|
|
105
|
+
this.player.controlBar.chaptersButton.update();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Setup chapter displays.
|
|
112
|
+
*/
|
|
113
|
+
ChaptersPlugin.prototype.setupChaptersDisplays = function initializeChapters() {
|
|
114
|
+
this.setupProgressBarMarkers();
|
|
115
|
+
this.setupProgressBarChapter();
|
|
116
|
+
this.setupControlBarChapter();
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Setup the controlbar chapter display.
|
|
121
|
+
*/
|
|
122
|
+
ChaptersPlugin.prototype.setupControlBarChapter = function setupControlBarChapter() {
|
|
123
|
+
const controlBarChapterHolder = this.player.$('.vjs-control-bar-chapter-display') || document.createElement('div');
|
|
124
|
+
controlBarChapterHolder.setAttribute('class', 'vjs-control-bar-chapter-display');
|
|
125
|
+
const wrapper = this.player.$('.vjs-control-bar .vjs-spacer');
|
|
126
|
+
wrapper.innerHTML = '';
|
|
127
|
+
wrapper.classList.add('vjs-control-bar-chapter-wrapper');
|
|
128
|
+
wrapper.appendChild(controlBarChapterHolder);
|
|
129
|
+
this.chaptersTrack.addEventListener('cuechange', () => {
|
|
130
|
+
const activeCues = Array.from(this.chaptersTrack.activeCues); // Safari needs Array.from()
|
|
131
|
+
controlBarChapterHolder.innerText = activeCues.length > 0 ? activeCues[0].text : '';
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Setup the progress bar markers.
|
|
137
|
+
*/
|
|
138
|
+
ChaptersPlugin.prototype.setupProgressBarMarkers = function setupProgressBarMarkers() {
|
|
139
|
+
const total = this.player.duration();
|
|
140
|
+
const {
|
|
141
|
+
seekBar
|
|
142
|
+
} = this.player.controlBar.progressControl;
|
|
143
|
+
Array.from(this.chaptersTrack.cues).forEach(marker => {
|
|
144
|
+
// Safari needs Array.from()
|
|
145
|
+
if (marker.startTime !== 0) {
|
|
146
|
+
const markerTime = marker.startTime;
|
|
147
|
+
const left = markerTime / total * 100 + '%';
|
|
148
|
+
const markerEl = _vjs.dom.createEl('div', undefined, {
|
|
149
|
+
class: 'vjs-chapter-marker',
|
|
150
|
+
style: `left: ${left}`
|
|
151
|
+
});
|
|
152
|
+
seekBar.el().append(markerEl);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Setup the progrees bar on-hover chapter display.
|
|
159
|
+
*/
|
|
160
|
+
ChaptersPlugin.prototype.setupProgressBarChapter = function setupProgressBarChapter() {
|
|
161
|
+
const chapterEl = _vjs.dom.createEl('div', undefined, {
|
|
162
|
+
class: 'vjs-chapter-display',
|
|
163
|
+
style: `max-width: ${this.player.$('.vjs-vtt-thumbnail-display') ? this.player.$('.vjs-vtt-thumbnail-display').style.width : '160px'}`
|
|
164
|
+
});
|
|
165
|
+
const mouseTimeDisplay = this.player.getDescendant(['controlBar', 'progressControl', 'seekBar', 'mouseTimeDisplay']);
|
|
166
|
+
const timeTooltip = mouseTimeDisplay.getDescendant(['timeTooltip']);
|
|
167
|
+
timeTooltip.el().parentElement.prepend(chapterEl);
|
|
168
|
+
const getChapterFromPoint = point => {
|
|
169
|
+
const total = this.player.duration();
|
|
170
|
+
const seekBarTime = point * total;
|
|
171
|
+
const chapter = Array.from(this.chaptersTrack?.cues || []).find(marker => {
|
|
172
|
+
return seekBarTime >= marker.startTime && seekBarTime <= marker.endTime;
|
|
173
|
+
});
|
|
174
|
+
return chapter ? chapter.text : '';
|
|
175
|
+
};
|
|
176
|
+
timeTooltip.update = function (seekBarRect, seekBarPoint, content) {
|
|
177
|
+
const originalUpdateFn = Object.getPrototypeOf(this).update;
|
|
178
|
+
originalUpdateFn.call(this, seekBarRect, seekBarPoint, content);
|
|
179
|
+
chapterEl.innerText = getChapterFromPoint(seekBarPoint);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// Handle case of no seek-thumbnails
|
|
183
|
+
if (typeof this.player.vttThumbnails !== 'object') {
|
|
184
|
+
mouseTimeDisplay.update = function (seekBarRect, seekBarPoint) {
|
|
185
|
+
const time = seekBarPoint * this.player_.duration();
|
|
186
|
+
const width = seekBarRect.width;
|
|
187
|
+
const size = chapterEl.clientWidth / 2;
|
|
188
|
+
timeTooltip.updateTime(seekBarRect, seekBarPoint, time, () => {
|
|
189
|
+
// Make sure it doesn't exit the player
|
|
190
|
+
if (seekBarRect.width * seekBarPoint < size) {
|
|
191
|
+
this.el_.style.left = `${size}px`;
|
|
192
|
+
} else if (seekBarRect.width * seekBarPoint + size > width) {
|
|
193
|
+
this.el_.style.left = `${seekBarRect.width - size}px`;
|
|
194
|
+
} else {
|
|
195
|
+
this.el_.style.left = `${seekBarRect.width * seekBarPoint}px`;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
timeTooltip.write(_vjs.time.formatTime(time));
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
return ChaptersPlugin;
|
|
203
|
+
}();
|
|
204
|
+
|
|
205
|
+
export { chapters as default };
|