()
| 12430 | }); |
| 12431 | } |
| 12432 | function loadVideoJsLibrary() { |
| 12433 | if (!window.videoJsStatus) { |
| 12434 | window.videoJsStatus = 'none'; |
| 12435 | } |
| 12436 | |
| 12437 | return new Promise((resolve, reject) => { |
| 12438 | if (window.videoJsStatus === 'loaded') { |
| 12439 | return resolve(); |
| 12440 | } |
| 12441 | |
| 12442 | if (window.videoJsStatus === 'loading') { |
| 12443 | const interval = setInterval(() => { |
| 12444 | if (window.videoJsStatus === 'loaded') { |
| 12445 | clearInterval(interval); |
| 12446 | resolve(); |
| 12447 | } else if (window.videoJsStatus === 'failed') { |
| 12448 | clearInterval(interval); |
| 12449 | reject(new Error('Previous Video.js loading attempt failed.')); |
| 12450 | } |
| 12451 | }, 100); |
| 12452 | return; |
| 12453 | } |
| 12454 | |
| 12455 | window.videoJsStatus = 'loading'; |
| 12456 | |
| 12457 | const cssSources = [ |
| 12458 | "https://vjs.zencdn.net/8.23.3/video-js.min.css", |
| 12459 | "https://unpkg.com/video.js/dist/video-js.min.css", |
| 12460 | "https://cdn.jsdelivr.net/npm/video.js@8.23.3/dist/video-js.min.css" |
| 12461 | ]; |
| 12462 | const jsSources = [ |
| 12463 | "https://vjs.zencdn.net/8.23.3/video.min.js", |
| 12464 | "https://unpkg.com/video.js/dist/video.min.js", |
| 12465 | "https://cdn.jsdelivr.net/npm/video.js@8.23.3/dist/video.min.js" |
| 12466 | ]; |
| 12467 | const fetchWithFallback = (urls) => { |
| 12468 | return new Promise((resolve, reject) => { |
| 12469 | let lastError = null; |
| 12470 | const urlsToTry = [...urls]; |
| 12471 | |
| 12472 | const tryNext = () => { |
| 12473 | if (urlsToTry.length === 0) { |
| 12474 | reject(new Error(`Failed to load resource after trying all sources. Last error: ${lastError}`)); |
| 12475 | return; |
| 12476 | } |
| 12477 | |
| 12478 | const url = urlsToTry.shift(); |
| 12479 | const xhr = new XMLHttpRequest(); |
| 12480 | xhr.open('GET', url); |
| 12481 | xhr.onload = () => { |
| 12482 | if (xhr.status === 200) { |
| 12483 | resolve(xhr.responseText); |
| 12484 | } else { |
| 12485 | lastError = `Status ${xhr.status} from ${url}`; |
| 12486 | console.warn(`Failed to load ${url}, trying next source...`); |
| 12487 | tryNext(); |
| 12488 | } |
| 12489 | }; |
no test coverage detected