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.
Files changed (86) hide show
  1. package/dist/134.min.js +8 -0
  2. package/dist/309.min.js +6 -0
  3. package/dist/adaptive-streaming.js +9 -9
  4. package/dist/adaptive-streaming.min.js +2 -2
  5. package/dist/chapters.js +4 -4
  6. package/dist/chapters.min.js +3 -3
  7. package/dist/cld-player-core.js +37 -0
  8. package/dist/cld-player-core.min.js +6 -0
  9. package/dist/cld-video-player-lazy.js +494 -0
  10. package/dist/cld-video-player-lazy.min.js +6 -0
  11. package/dist/cld-video-player.css +2 -2
  12. package/dist/cld-video-player.js +366 -332
  13. package/dist/cld-video-player.light.js +366 -332
  14. package/dist/cld-video-player.light.min.js +4 -4
  15. package/dist/cld-video-player.min.css +2 -2
  16. package/dist/cld-video-player.min.js +4 -4
  17. package/dist/colors.js +4 -4
  18. package/dist/colors.min.js +2 -2
  19. package/dist/dash.js +6 -6
  20. package/dist/dash.min.js +2 -2
  21. package/dist/debug.js +8 -8
  22. package/dist/debug.min.js +3 -3
  23. package/dist/ima.js +9 -9
  24. package/dist/ima.min.js +2 -2
  25. package/dist/interaction-areas.js +11 -11
  26. package/dist/interaction-areas.min.js +2 -2
  27. package/dist/node_modules_lodash_throttle_js.js +8 -8
  28. package/dist/playlist.js +31 -31
  29. package/dist/playlist.min.js +3 -3
  30. package/dist/recommendations-overlay.js +10 -10
  31. package/dist/recommendations-overlay.min.js +2 -2
  32. package/dist/schema.json +19 -0
  33. package/dist/share.js +5 -5
  34. package/dist/share.min.js +3 -3
  35. package/dist/shoppable.js +12 -12
  36. package/dist/shoppable.min.js +2 -2
  37. package/dist/utils_fetch-config_js.js +81 -0
  38. package/dist/video-player_js.js +3111 -0
  39. package/dist/visual-search.js +7 -7
  40. package/dist/visual-search.min.js +2 -2
  41. package/lib/_commonjsHelpers.js +7 -0
  42. package/lib/_videojs-proxy.js +30294 -0
  43. package/lib/abr-strategies.js +31 -0
  44. package/lib/adaptive-streaming.js +468 -2
  45. package/lib/all.js +25 -2
  46. package/lib/chapters.js +205 -1
  47. package/lib/cld-video-player.min.css +5 -22
  48. package/lib/colors.js +59 -1
  49. package/lib/{schema.json → config/configSchema.json} +19 -0
  50. package/lib/dash.js +69943 -2
  51. package/lib/debug.js +322 -1
  52. package/lib/document.js +770 -0
  53. package/lib/download-button.js +48 -0
  54. package/lib/fetch-config.js +93 -0
  55. package/lib/ima.js +6851 -1
  56. package/lib/index.js +27 -0
  57. package/lib/interaction-areas.const.js +24 -0
  58. package/lib/interaction-areas.service.js +469 -0
  59. package/lib/lazy.js +20 -0
  60. package/lib/noop.js +33 -0
  61. package/lib/player-api.js +469 -0
  62. package/lib/player.js +7 -2
  63. package/lib/playlist-panel.js +602 -0
  64. package/lib/playlist.js +637 -1
  65. package/lib/querystring.js +81 -0
  66. package/lib/recommendations-overlay.js +320 -1
  67. package/lib/share.js +129 -1
  68. package/lib/shoppable-post-widget.js +572 -0
  69. package/lib/shoppable-widget.js +77 -0
  70. package/lib/throttle.js +318 -0
  71. package/lib/toNumber.js +134 -0
  72. package/lib/validators-functions.js +485 -0
  73. package/lib/video-player.js +16241 -0
  74. package/lib/videoPlayer.js +7 -2
  75. package/lib/videojs-contrib-hlsjs.js +37638 -0
  76. package/lib/visual-search.js +235 -1
  77. package/package.json +31 -15
  78. package/lib/adaptive-streaming.js.LICENSE.txt +0 -3
  79. package/lib/all.js.LICENSE.txt +0 -25
  80. package/lib/cld-video-player.js +0 -2
  81. package/lib/cld-video-player.js.LICENSE.txt +0 -21
  82. package/lib/dash.js.LICENSE.txt +0 -1842
  83. package/lib/interaction-areas.js +0 -1
  84. package/lib/player.js.LICENSE.txt +0 -21
  85. package/lib/shoppable.js +0 -1
  86. package/lib/videoPlayer.js.LICENSE.txt +0 -21
package/lib/chapters.js CHANGED
@@ -1 +1,205 @@
1
- (self.cloudinaryVideoPlayerChunkLoading=self.cloudinaryVideoPlayerChunkLoading||[]).push([[625],{9234:(t,e,r)=>{r.d(e,{default:()=>c});var s=r(6673),a=r.n(s),i=r(1865),o=r(2415),n=r(7311);const p=function(){function t(t,e){return this.player=t,this.options=e,this.player.one("loadedmetadata",this.initializeChapters.bind(this)),this}return t.prototype.src=function(t){this.resetPlugin(),this.options=t,this.player.one("loadedmetadata",this.initializeChapters.bind(this))},t.prototype.detach=function(){this.resetPlugin()},t.prototype.resetPlugin=function(){this.chaptersTrack&&(this.player.$(".vjs-control-bar-chapter-display").remove(),this.player.$(".vjs-chapter-display").remove(),this.player.$$(".vjs-chapter-marker").forEach(t=>t.remove()),this.player.removeRemoteTextTrack(this.chaptersTrack),delete this.chaptersTrack)},t.prototype.getChaptersFileUrlByName=function(){const t=this.player.cloudinary.currentPublicId();if(!t)return null;const e=this.player.cloudinary.source(),{type:r}=e.resourceConfig(),s=`${(0,i.k$)(this.player.cloudinary.cloudinaryConfig())}/_applet_/video_service/chapters/${r}/${(0,o.G)(t)}.vtt`;return(0,n.N)(s,e.queryParams())},t.prototype.initializeChapters=async function(){const t=!0===this.options?this.getChaptersFileUrlByName():this.options.url;if(t){const e={kind:"chapters",src:t,default:!0},r=this.player.addRemoteTextTrack(e);r.addEventListener("load",()=>{this.chaptersTrack=r.track,this.setupChaptersDisplays()})}else if(Object.entries(this.options).length){const t=this.player.addRemoteTextTrack({kind:"chapters",default:!0}),e=this.player.duration();Object.entries(this.options).forEach((r,s,a)=>{const i=new VTTCue(parseFloat(r[0]),parseFloat(a[s+1]?a[s+1][0]:e),r[1]);t.track.addCue(i)}),this.chaptersTrack=t.track,this.setupChaptersDisplays(),this.player.controlBar.chaptersButton&&this.player.controlBar.chaptersButton.update()}},t.prototype.setupChaptersDisplays=function(){this.setupProgressBarMarkers(),this.setupProgressBarChapter(),this.setupControlBarChapter()},t.prototype.setupControlBarChapter=function(){const t=this.player.$(".vjs-control-bar-chapter-display")||document.createElement("div");t.setAttribute("class","vjs-control-bar-chapter-display");const e=this.player.$(".vjs-control-bar .vjs-spacer");e.innerHTML="",e.classList.add("vjs-control-bar-chapter-wrapper"),e.appendChild(t),this.chaptersTrack.addEventListener("cuechange",()=>{const e=Array.from(this.chaptersTrack.activeCues);t.innerText=e.length>0?e[0].text:""})},t.prototype.setupProgressBarMarkers=function(){const t=this.player.duration(),{seekBar:e}=this.player.controlBar.progressControl;Array.from(this.chaptersTrack.cues).forEach(r=>{if(0!==r.startTime){const s=r.startTime/t*100+"%",i=a().dom.createEl("div",void 0,{class:"vjs-chapter-marker",style:`left: ${s}`});e.el().append(i)}})},t.prototype.setupProgressBarChapter=function(){const t=a().dom.createEl("div",void 0,{class:"vjs-chapter-display",style:`max-width: ${this.player.$(".vjs-vtt-thumbnail-display")?this.player.$(".vjs-vtt-thumbnail-display").style.width:"160px"}`}),e=this.player.getDescendant(["controlBar","progressControl","seekBar","mouseTimeDisplay"]),r=e.getDescendant(["timeTooltip"]);r.el().parentElement.prepend(t);const s=t=>{const e=t*this.player.duration(),r=Array.from(this.chaptersTrack?.cues||[]).find(t=>e>=t.startTime&&e<=t.endTime);return r?r.text:""};r.update=function(e,r,a){Object.getPrototypeOf(this).update.call(this,e,r,a),t.innerText=s(r)},"object"!=typeof this.player.vttThumbnails&&(e.update=function(e,s){const i=s*this.player_.duration(),o=e.width,n=t.clientWidth/2;r.updateTime(e,s,i,()=>{e.width*s<n?this.el_.style.left=`${n}px`:e.width*s+n>o?this.el_.style.left=e.width-n+"px":this.el_.style.left=e.width*s+"px"}),r.write(a().time.formatTime(i))})},t}(),c=function(t,e){e.addClass("vjs-chapters"),e.chapters=new p(e,t)}}}]);
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 };