(media, imgSrc)
| 12520 | }); |
| 12521 | } |
| 12522 | async function initVideojs(media, imgSrc) { |
| 12523 | await loadVideoJsLibrary(); |
| 12524 | const videoOptions = { |
| 12525 | autoplay: true |
| 12526 | }; |
| 12527 | media.className = "video-js vjs-default-skin vjs-fluid"; |
| 12528 | media.width = 1920; |
| 12529 | media.height = 1080; |
| 12530 | const player = videojs(media, videoOptions); |
| 12531 | player.on('loadedmetadata', function() { |
| 12532 | const vhs = player.tech({ IWillNotUseThisInPlugins: true }).vhs; |
| 12533 | if (!vhs) { |
| 12534 | console.warn('VHS engine not found.'); |
| 12535 | return; |
| 12536 | } |
| 12537 | const representations = vhs.representations(); |
| 12538 | if (!representations || representations.length === 0) { |
| 12539 | return; |
| 12540 | } |
| 12541 | let highestBandwidth = 0; |
| 12542 | let highestRepresentation = null; |
| 12543 | for (let i = 0; i < representations.length; i++) { |
| 12544 | const representation = representations[i]; |
| 12545 | if (representation.bandwidth > highestBandwidth) { |
| 12546 | highestBandwidth = representation.bandwidth; |
| 12547 | highestRepresentation = representation; |
| 12548 | } |
| 12549 | } |
| 12550 | if (highestRepresentation) { |
| 12551 | representations.forEach(representation => { |
| 12552 | representation.enabled(representation.id === highestRepresentation.id); |
| 12553 | }); |
| 12554 | } |
| 12555 | const originalWidth = highestRepresentation ? highestRepresentation.width : player.videoWidth(); |
| 12556 | const originalHeight = highestRepresentation ? highestRepresentation.height : player.videoHeight(); |
| 12557 | this.addClass('vjs-has-started'); |
| 12558 | media.naturalWidth = originalWidth; |
| 12559 | media.naturalHeight = originalHeight; |
| 12560 | media.onload(); |
| 12561 | }); |
| 12562 | player.src({ |
| 12563 | src: imgSrc, |
| 12564 | fluid: true, |
| 12565 | type: 'application/x-mpegURL' |
| 12566 | }); |
| 12567 | } |
| 12568 | function getCookie(cname) { |
| 12569 | let name = cname + "="; |
| 12570 | var ca = document.cookie.split(';'); |
no test coverage detected