cloudinary-video-player 2.3.6-edge.6 → 2.3.6-edge.8
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/chapters.js +1 -1
- package/dist/chapters.light.js +1 -1
- package/dist/chapters.light.min.js +1 -1
- package/dist/chapters.min.js +1 -1
- package/dist/cld-video-player.css +158 -46
- package/dist/cld-video-player.js +68 -12
- package/dist/cld-video-player.light.css +158 -46
- package/dist/cld-video-player.light.js +68 -12
- package/dist/cld-video-player.light.min.css +1 -1
- package/dist/cld-video-player.light.min.js +1 -1
- package/dist/cld-video-player.min.css +1 -1
- package/dist/cld-video-player.min.js +1 -1
- package/dist/debug.js +1 -0
- package/dist/debug.light.js +1 -0
- package/dist/debug.light.min.js +1 -1
- package/dist/debug.min.js +1 -1
- package/dist/visual-search.js +317 -0
- package/dist/visual-search.light.js +317 -0
- package/dist/visual-search.light.min.js +2 -0
- package/dist/visual-search.min.js +2 -0
- package/lib/all.js +1 -1
- package/lib/chapters.js +1 -1
- package/lib/cld-video-player.js +1 -1
- package/lib/cld-video-player.min.css +2 -1
- package/lib/debug.js +1 -1
- package/lib/light/chapters.js +1 -1
- package/lib/light/cld-video-player.light.min.css +2 -1
- package/lib/light/debug.js +1 -1
- package/lib/light/index.js +1 -1
- package/lib/light/visual-search.js +2 -0
- package/lib/player.js +1 -1
- package/lib/videoPlayer.js +1 -1
- package/lib/visual-search.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(self["cloudinaryVideoPlayerChunkLoading"] = self["cloudinaryVideoPlayerChunkLoading"] || []).push([["visual-search"],{
|
|
3
|
+
|
|
4
|
+
/***/ "./plugins/visual-search/components/SearchButton.js":
|
|
5
|
+
/*!**********************************************************!*\
|
|
6
|
+
!*** ./plugins/visual-search/components/SearchButton.js ***!
|
|
7
|
+
\**********************************************************/
|
|
8
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
9
|
+
|
|
10
|
+
__webpack_require__.r(__webpack_exports__);
|
|
11
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
12
|
+
/* harmony export */ SearchButton: () => (/* binding */ SearchButton)
|
|
13
|
+
/* harmony export */ });
|
|
14
|
+
/* harmony import */ var video_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! video.js */ "../node_modules/video.js/dist/alt/video.core-exposed.js");
|
|
15
|
+
/* harmony import */ var video_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(video_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
16
|
+
|
|
17
|
+
const SearchButton = onClick => {
|
|
18
|
+
const button = video_js__WEBPACK_IMPORTED_MODULE_0___default().dom.createEl('button', {
|
|
19
|
+
className: 'vjs-control vjs-button vjs-visual-search-button',
|
|
20
|
+
title: 'Search video content',
|
|
21
|
+
ariaLabel: 'Search video content'
|
|
22
|
+
});
|
|
23
|
+
const searchIcon = video_js__WEBPACK_IMPORTED_MODULE_0___default().dom.createEl('span', {
|
|
24
|
+
className: 'vjs-icon-search'
|
|
25
|
+
});
|
|
26
|
+
button.appendChild(searchIcon);
|
|
27
|
+
const spinnerIcon = video_js__WEBPACK_IMPORTED_MODULE_0___default().dom.createEl('span', {
|
|
28
|
+
className: 'vjs-loading-spinner'
|
|
29
|
+
});
|
|
30
|
+
button.appendChild(spinnerIcon);
|
|
31
|
+
button.addEventListener('click', onClick);
|
|
32
|
+
return button;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/***/ }),
|
|
36
|
+
|
|
37
|
+
/***/ "./plugins/visual-search/components/SearchInput.js":
|
|
38
|
+
/*!*********************************************************!*\
|
|
39
|
+
!*** ./plugins/visual-search/components/SearchInput.js ***!
|
|
40
|
+
\*********************************************************/
|
|
41
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
42
|
+
|
|
43
|
+
__webpack_require__.r(__webpack_exports__);
|
|
44
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
45
|
+
/* harmony export */ SearchInput: () => (/* binding */ SearchInput)
|
|
46
|
+
/* harmony export */ });
|
|
47
|
+
/* harmony import */ var video_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! video.js */ "../node_modules/video.js/dist/alt/video.core-exposed.js");
|
|
48
|
+
/* harmony import */ var video_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(video_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
49
|
+
|
|
50
|
+
const SearchInput = (onSearch, onClose) => {
|
|
51
|
+
const form = video_js__WEBPACK_IMPORTED_MODULE_0___default().dom.createEl('form', {
|
|
52
|
+
className: 'vjs-visual-search-form'
|
|
53
|
+
});
|
|
54
|
+
const input = video_js__WEBPACK_IMPORTED_MODULE_0___default().dom.createEl('input', {
|
|
55
|
+
className: 'vjs-visual-search-input',
|
|
56
|
+
type: 'text',
|
|
57
|
+
ariaLabel: 'Search input',
|
|
58
|
+
tabIndex: -1
|
|
59
|
+
});
|
|
60
|
+
const closeButton = video_js__WEBPACK_IMPORTED_MODULE_0___default().dom.createEl('button', {
|
|
61
|
+
className: 'vjs-control vjs-button vjs-visual-search-close',
|
|
62
|
+
type: 'button',
|
|
63
|
+
title: 'Close search',
|
|
64
|
+
ariaLabel: 'Close search',
|
|
65
|
+
tabIndex: -1
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Add close icon
|
|
69
|
+
const closeIcon = video_js__WEBPACK_IMPORTED_MODULE_0___default().dom.createEl('span', {
|
|
70
|
+
className: 'vjs-icon-close'
|
|
71
|
+
});
|
|
72
|
+
closeButton.appendChild(closeIcon);
|
|
73
|
+
form.appendChild(input);
|
|
74
|
+
form.appendChild(closeButton);
|
|
75
|
+
|
|
76
|
+
// Handle search submission
|
|
77
|
+
form.addEventListener('submit', e => {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
const query = input.value.trim();
|
|
80
|
+
if (query) {
|
|
81
|
+
onSearch(query);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Handle close button
|
|
86
|
+
closeButton.addEventListener('click', e => {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
if (onClose) {
|
|
89
|
+
onClose();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
element: form,
|
|
94
|
+
input,
|
|
95
|
+
closeButton
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/***/ }),
|
|
100
|
+
|
|
101
|
+
/***/ "./plugins/visual-search/components/SearchResults.js":
|
|
102
|
+
/*!***********************************************************!*\
|
|
103
|
+
!*** ./plugins/visual-search/components/SearchResults.js ***!
|
|
104
|
+
\***********************************************************/
|
|
105
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
106
|
+
|
|
107
|
+
__webpack_require__.r(__webpack_exports__);
|
|
108
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
109
|
+
/* harmony export */ SearchResults: () => (/* binding */ SearchResults)
|
|
110
|
+
/* harmony export */ });
|
|
111
|
+
/* harmony import */ var video_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! video.js */ "../node_modules/video.js/dist/alt/video.core-exposed.js");
|
|
112
|
+
/* harmony import */ var video_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(video_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
113
|
+
|
|
114
|
+
const SearchResults = player => {
|
|
115
|
+
const clearMarkers = () => {
|
|
116
|
+
player.$$('.vjs-visual-search-marker').forEach(el => el.remove());
|
|
117
|
+
player.$$('.vjs-visual-search-results-wrapper').forEach(el => el.remove());
|
|
118
|
+
|
|
119
|
+
// Remove the class that indicates search results are displayed
|
|
120
|
+
player.removeClass('vjs-visual-search-results-active');
|
|
121
|
+
};
|
|
122
|
+
const displayResults = results => {
|
|
123
|
+
// Clear existing markers
|
|
124
|
+
clearMarkers();
|
|
125
|
+
const total = player.duration();
|
|
126
|
+
const seekBar = player.controlBar.progressControl.seekBar;
|
|
127
|
+
|
|
128
|
+
// Create wrapper for search results
|
|
129
|
+
const wrapperEl = video_js__WEBPACK_IMPORTED_MODULE_0___default().dom.createEl('div', {
|
|
130
|
+
className: 'vjs-visual-search-results-wrapper',
|
|
131
|
+
role: 'presentation'
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Add markers for each result
|
|
135
|
+
results.forEach(result => {
|
|
136
|
+
const {
|
|
137
|
+
start_time,
|
|
138
|
+
end_time
|
|
139
|
+
} = result;
|
|
140
|
+
const position = start_time / total * 100;
|
|
141
|
+
const width = (end_time - start_time) / total * 100;
|
|
142
|
+
const time = `${Math.floor(start_time / 60)}:${Math.floor(start_time % 60).toString().padStart(2, '0')}`;
|
|
143
|
+
const markerEl = video_js__WEBPACK_IMPORTED_MODULE_0___default().dom.createEl('div', {
|
|
144
|
+
className: 'vjs-control vjs-visual-search-marker',
|
|
145
|
+
style: `left: ${position}%; width: ${width}%`,
|
|
146
|
+
tabIndex: 0,
|
|
147
|
+
role: 'button',
|
|
148
|
+
title: `Search result at ${time}`,
|
|
149
|
+
ariaLabel: `Search result at ${time}`
|
|
150
|
+
});
|
|
151
|
+
wrapperEl.appendChild(markerEl);
|
|
152
|
+
|
|
153
|
+
// Add click handler to jump to this time
|
|
154
|
+
markerEl.addEventListener('click', () => {
|
|
155
|
+
player.currentTime(start_time);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Add keyboard support
|
|
159
|
+
markerEl.addEventListener('keydown', e => {
|
|
160
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
player.currentTime(start_time);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Add wrapper to seek bar
|
|
168
|
+
seekBar.el().appendChild(wrapperEl);
|
|
169
|
+
|
|
170
|
+
// Add a class to indicate search results are displayed
|
|
171
|
+
if (results.length > 0) {
|
|
172
|
+
player.addClass('vjs-visual-search-results-active');
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
return {
|
|
176
|
+
displayResults,
|
|
177
|
+
clearMarkers
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/***/ }),
|
|
182
|
+
|
|
183
|
+
/***/ "./plugins/visual-search/visual-search.js":
|
|
184
|
+
/*!************************************************!*\
|
|
185
|
+
!*** ./plugins/visual-search/visual-search.js ***!
|
|
186
|
+
\************************************************/
|
|
187
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
188
|
+
|
|
189
|
+
__webpack_require__.r(__webpack_exports__);
|
|
190
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
191
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
192
|
+
/* harmony export */ });
|
|
193
|
+
/* harmony import */ var video_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! video.js */ "../node_modules/video.js/dist/alt/video.core-exposed.js");
|
|
194
|
+
/* harmony import */ var video_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(video_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
195
|
+
/* harmony import */ var _components_SearchButton__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/SearchButton */ "./plugins/visual-search/components/SearchButton.js");
|
|
196
|
+
/* harmony import */ var _components_SearchInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/SearchInput */ "./plugins/visual-search/components/SearchInput.js");
|
|
197
|
+
/* harmony import */ var _components_SearchResults__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/SearchResults */ "./plugins/visual-search/components/SearchResults.js");
|
|
198
|
+
/* harmony import */ var _visual_search_scss__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./visual-search.scss */ "./plugins/visual-search/visual-search.scss");
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
const visualSearch = (options, player) => {
|
|
205
|
+
player.addClass('vjs-visual-search');
|
|
206
|
+
let isSearchActive = false;
|
|
207
|
+
const searchResults = (0,_components_SearchResults__WEBPACK_IMPORTED_MODULE_3__.SearchResults)(player);
|
|
208
|
+
const performSearch = async query => {
|
|
209
|
+
const searchButton = player.$('.vjs-visual-search-button');
|
|
210
|
+
searchButton.classList.add('vjs-waiting');
|
|
211
|
+
try {
|
|
212
|
+
const source = player.cloudinary.source();
|
|
213
|
+
const publicId = source.publicId();
|
|
214
|
+
const transformation = Object.assign({}, source.transformation());
|
|
215
|
+
transformation.flags = transformation.flags || [];
|
|
216
|
+
transformation.flags.push(`getinfo:search_b64_${btoa(query)}`);
|
|
217
|
+
const visualSearchSrc = source.config().url(`${publicId}`, {
|
|
218
|
+
transformation
|
|
219
|
+
});
|
|
220
|
+
const response = await fetch(visualSearchSrc, {
|
|
221
|
+
method: 'GET',
|
|
222
|
+
headers: {
|
|
223
|
+
'Content-Type': 'application/json'
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
if (!response.ok) {
|
|
227
|
+
throw new Error(`Search request failed with status: ${response.status}`);
|
|
228
|
+
}
|
|
229
|
+
const results = await response.json();
|
|
230
|
+
searchResults.displayResults(results.timestamps);
|
|
231
|
+
if (results && !player.hasStarted()) {
|
|
232
|
+
// Make sure the progress bar is visible
|
|
233
|
+
player.play().then(() => player.pause());
|
|
234
|
+
}
|
|
235
|
+
} catch (error) {
|
|
236
|
+
console.error('Error performing visual search:', error);
|
|
237
|
+
} finally {
|
|
238
|
+
searchButton.classList.remove('vjs-waiting');
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
const clearUI = () => {
|
|
242
|
+
isSearchActive = false;
|
|
243
|
+
searchResults.clearMarkers();
|
|
244
|
+
player.$('.vjs-visual-search-wrapper')?.remove();
|
|
245
|
+
};
|
|
246
|
+
const createSearchUI = () => {
|
|
247
|
+
clearUI();
|
|
248
|
+
const titleBar = player.$('.vjs-title-bar');
|
|
249
|
+
if (titleBar) {
|
|
250
|
+
titleBar.classList.remove('vjs-hidden');
|
|
251
|
+
}
|
|
252
|
+
const searchContainer = video_js__WEBPACK_IMPORTED_MODULE_0___default().dom.createEl('div', {
|
|
253
|
+
className: 'vjs-visual-search-wrapper'
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// Handle the search icon click (expand or submit)
|
|
257
|
+
const handleSearchButtonClick = () => {
|
|
258
|
+
if (!isSearchActive) {
|
|
259
|
+
isSearchActive = true;
|
|
260
|
+
searchContainer.classList.add('vjs-visual-search-active');
|
|
261
|
+
searchInput.input.tabIndex = 0;
|
|
262
|
+
searchInput.closeButton.tabIndex = 0;
|
|
263
|
+
searchInput.input.focus();
|
|
264
|
+
} else {
|
|
265
|
+
const query = searchInput.input.value.trim();
|
|
266
|
+
if (query) {
|
|
267
|
+
performSearch(query);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const closeSearch = () => {
|
|
272
|
+
if (isSearchActive) {
|
|
273
|
+
isSearchActive = false;
|
|
274
|
+
searchContainer.classList.remove('vjs-visual-search-active');
|
|
275
|
+
searchInput.input.value = '';
|
|
276
|
+
searchInput.input.tabIndex = -1;
|
|
277
|
+
searchInput.closeButton.tabIndex = -1;
|
|
278
|
+
searchResults.clearMarkers();
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
const searchButton = (0,_components_SearchButton__WEBPACK_IMPORTED_MODULE_1__.SearchButton)(handleSearchButtonClick);
|
|
282
|
+
const searchInput = (0,_components_SearchInput__WEBPACK_IMPORTED_MODULE_2__.SearchInput)(performSearch, closeSearch);
|
|
283
|
+
searchContainer.appendChild(searchButton);
|
|
284
|
+
searchContainer.appendChild(searchInput.element);
|
|
285
|
+
titleBar.prepend(searchContainer);
|
|
286
|
+
player.on('keydown', e => {
|
|
287
|
+
if (e.key === 'Escape' && isSearchActive) {
|
|
288
|
+
closeSearch();
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
};
|
|
292
|
+
createSearchUI();
|
|
293
|
+
|
|
294
|
+
// Public methods
|
|
295
|
+
player.visualSearch = {
|
|
296
|
+
createSearchUI,
|
|
297
|
+
clearUI
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (visualSearch);
|
|
301
|
+
|
|
302
|
+
/***/ }),
|
|
303
|
+
|
|
304
|
+
/***/ "./plugins/visual-search/visual-search.scss":
|
|
305
|
+
/*!**************************************************!*\
|
|
306
|
+
!*** ./plugins/visual-search/visual-search.scss ***!
|
|
307
|
+
\**************************************************/
|
|
308
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
309
|
+
|
|
310
|
+
__webpack_require__.r(__webpack_exports__);
|
|
311
|
+
// extracted by mini-css-extract-plugin
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
/***/ })
|
|
315
|
+
|
|
316
|
+
}]);
|
|
317
|
+
//# sourceMappingURL=visual-search.light.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";(self.cloudinaryVideoPlayerChunkLoading=self.cloudinaryVideoPlayerChunkLoading||[]).push([[728],{9148:(e,a,s)=>{s.d(a,{default:()=>l});var t=s(6673),r=s.n(t);const l=(e,a)=>{a.addClass("vjs-visual-search");let s=!1;const t=(e=>{const a=()=>{e.$$(".vjs-visual-search-marker").forEach((e=>e.remove())),e.$$(".vjs-visual-search-results-wrapper").forEach((e=>e.remove())),e.removeClass("vjs-visual-search-results-active")};return{displayResults:s=>{a();const t=e.duration(),l=e.controlBar.progressControl.seekBar,n=r().dom.createEl("div",{className:"vjs-visual-search-results-wrapper",role:"presentation"});s.forEach((a=>{const{start_time:s,end_time:l}=a,c=s/t*100,o=(l-s)/t*100,i=`${Math.floor(s/60)}:${Math.floor(s%60).toString().padStart(2,"0")}`,d=r().dom.createEl("div",{className:"vjs-control vjs-visual-search-marker",style:`left: ${c}%; width: ${o}%`,tabIndex:0,role:"button",title:`Search result at ${i}`,ariaLabel:`Search result at ${i}`});n.appendChild(d),d.addEventListener("click",(()=>{e.currentTime(s)})),d.addEventListener("keydown",(a=>{"Enter"!==a.key&&" "!==a.key||(a.preventDefault(),e.currentTime(s))}))})),l.el().appendChild(n),s.length>0&&e.addClass("vjs-visual-search-results-active")},clearMarkers:a}})(a),l=async e=>{const s=a.$(".vjs-visual-search-button");s.classList.add("vjs-waiting");try{const s=a.cloudinary.source(),r=s.publicId(),l=Object.assign({},s.transformation());l.flags=l.flags||[],l.flags.push(`getinfo:search_b64_${btoa(e)}`);const n=s.config().url(`${r}`,{transformation:l}),c=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}});if(!c.ok)throw new Error(`Search request failed with status: ${c.status}`);const o=await c.json();t.displayResults(o.timestamps),o&&!a.hasStarted()&&a.play().then((()=>a.pause()))}catch(e){console.error("Error performing visual search:",e)}finally{s.classList.remove("vjs-waiting")}},n=()=>{s=!1,t.clearMarkers(),a.$(".vjs-visual-search-wrapper")?.remove()},c=()=>{n();const e=a.$(".vjs-title-bar");e&&e.classList.remove("vjs-hidden");const c=r().dom.createEl("div",{className:"vjs-visual-search-wrapper"}),o=()=>{s&&(s=!1,c.classList.remove("vjs-visual-search-active"),d.input.value="",d.input.tabIndex=-1,d.closeButton.tabIndex=-1,t.clearMarkers())},i=(e=>{const a=r().dom.createEl("button",{className:"vjs-control vjs-button vjs-visual-search-button",title:"Search video content",ariaLabel:"Search video content"}),s=r().dom.createEl("span",{className:"vjs-icon-search"});a.appendChild(s);const t=r().dom.createEl("span",{className:"vjs-loading-spinner"});return a.appendChild(t),a.addEventListener("click",e),a})((()=>{if(s){const e=d.input.value.trim();e&&l(e)}else s=!0,c.classList.add("vjs-visual-search-active"),d.input.tabIndex=0,d.closeButton.tabIndex=0,d.input.focus()})),d=((e,a)=>{const s=r().dom.createEl("form",{className:"vjs-visual-search-form"}),t=r().dom.createEl("input",{className:"vjs-visual-search-input",type:"text",ariaLabel:"Search input",tabIndex:-1}),l=r().dom.createEl("button",{className:"vjs-control vjs-button vjs-visual-search-close",type:"button",title:"Close search",ariaLabel:"Close search",tabIndex:-1}),n=r().dom.createEl("span",{className:"vjs-icon-close"});return l.appendChild(n),s.appendChild(t),s.appendChild(l),s.addEventListener("submit",(a=>{a.preventDefault();const s=t.value.trim();s&&e(s)})),l.addEventListener("click",(e=>{e.preventDefault(),a&&a()})),{element:s,input:t,closeButton:l}})(l,o);c.appendChild(i),c.appendChild(d.element),e.prepend(c),a.on("keydown",(e=>{"Escape"===e.key&&s&&o()}))};c(),a.visualSearch={createSearchUI:c,clearUI:n}}}}]);
|
|
2
|
+
//# sourceMappingURL=visual-search.light.min.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";(self.cloudinaryVideoPlayerChunkLoading=self.cloudinaryVideoPlayerChunkLoading||[]).push([[728],{9148:(e,a,s)=>{s.d(a,{default:()=>l});var t=s(7938),r=s.n(t);const l=(e,a)=>{a.addClass("vjs-visual-search");let s=!1;const t=(e=>{const a=()=>{e.$$(".vjs-visual-search-marker").forEach((e=>e.remove())),e.$$(".vjs-visual-search-results-wrapper").forEach((e=>e.remove())),e.removeClass("vjs-visual-search-results-active")};return{displayResults:s=>{a();const t=e.duration(),l=e.controlBar.progressControl.seekBar,n=r().dom.createEl("div",{className:"vjs-visual-search-results-wrapper",role:"presentation"});s.forEach((a=>{const{start_time:s,end_time:l}=a,c=s/t*100,o=(l-s)/t*100,i=`${Math.floor(s/60)}:${Math.floor(s%60).toString().padStart(2,"0")}`,d=r().dom.createEl("div",{className:"vjs-control vjs-visual-search-marker",style:`left: ${c}%; width: ${o}%`,tabIndex:0,role:"button",title:`Search result at ${i}`,ariaLabel:`Search result at ${i}`});n.appendChild(d),d.addEventListener("click",(()=>{e.currentTime(s)})),d.addEventListener("keydown",(a=>{"Enter"!==a.key&&" "!==a.key||(a.preventDefault(),e.currentTime(s))}))})),l.el().appendChild(n),s.length>0&&e.addClass("vjs-visual-search-results-active")},clearMarkers:a}})(a),l=async e=>{const s=a.$(".vjs-visual-search-button");s.classList.add("vjs-waiting");try{const s=a.cloudinary.source(),r=s.publicId(),l=Object.assign({},s.transformation());l.flags=l.flags||[],l.flags.push(`getinfo:search_b64_${btoa(e)}`);const n=s.config().url(`${r}`,{transformation:l}),c=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}});if(!c.ok)throw new Error(`Search request failed with status: ${c.status}`);const o=await c.json();t.displayResults(o.timestamps),o&&!a.hasStarted()&&a.play().then((()=>a.pause()))}catch(e){console.error("Error performing visual search:",e)}finally{s.classList.remove("vjs-waiting")}},n=()=>{s=!1,t.clearMarkers(),a.$(".vjs-visual-search-wrapper")?.remove()},c=()=>{n();const e=a.$(".vjs-title-bar");e&&e.classList.remove("vjs-hidden");const c=r().dom.createEl("div",{className:"vjs-visual-search-wrapper"}),o=()=>{s&&(s=!1,c.classList.remove("vjs-visual-search-active"),d.input.value="",d.input.tabIndex=-1,d.closeButton.tabIndex=-1,t.clearMarkers())},i=(e=>{const a=r().dom.createEl("button",{className:"vjs-control vjs-button vjs-visual-search-button",title:"Search video content",ariaLabel:"Search video content"}),s=r().dom.createEl("span",{className:"vjs-icon-search"});a.appendChild(s);const t=r().dom.createEl("span",{className:"vjs-loading-spinner"});return a.appendChild(t),a.addEventListener("click",e),a})((()=>{if(s){const e=d.input.value.trim();e&&l(e)}else s=!0,c.classList.add("vjs-visual-search-active"),d.input.tabIndex=0,d.closeButton.tabIndex=0,d.input.focus()})),d=((e,a)=>{const s=r().dom.createEl("form",{className:"vjs-visual-search-form"}),t=r().dom.createEl("input",{className:"vjs-visual-search-input",type:"text",ariaLabel:"Search input",tabIndex:-1}),l=r().dom.createEl("button",{className:"vjs-control vjs-button vjs-visual-search-close",type:"button",title:"Close search",ariaLabel:"Close search",tabIndex:-1}),n=r().dom.createEl("span",{className:"vjs-icon-close"});return l.appendChild(n),s.appendChild(t),s.appendChild(l),s.addEventListener("submit",(a=>{a.preventDefault();const s=t.value.trim();s&&e(s)})),l.addEventListener("click",(e=>{e.preventDefault(),a&&a()})),{element:s,input:t,closeButton:l}})(l,o);c.appendChild(i),c.appendChild(d.element),e.prepend(c),a.on("keydown",(e=>{"Escape"===e.key&&s&&o()}))};c(),a.visualSearch={createSearchUI:c,clearUI:n}}}}]);
|
|
2
|
+
//# sourceMappingURL=visual-search.min.js.map
|