Fix videojs overlay

This commit is contained in:
Jan Stabenow 2024-12-04 10:07:32 +01:00
parent aa168db7d5
commit c04b924d9e

View File

@ -114,36 +114,23 @@
var player = videojs('player', config);
if(playerConfig.logo.image.length != 0) {
var overlay = null;
var imgTag = new Image();
imgTag.onLoad = function () {
imgTag.setAttribute('width', this.width);
imgTag.setAttribute('height'.this.height);
const imgTag = new Image();
imgTag.src = playerConfig.logo.image;
imgTag.onload = function () {
const logoWidth = imgTag.width;
const logoHeight = imgTag.height;
const overlayPosition = playerConfig.logo.position || 'top-left';
const overlayLink = playerConfig.logo.link || '#';
player.overlay({
overlays: [{
content: `<a href="${overlayLink}" target="_blank"><img src="${playerConfig.logo.image + '?' + Math.random()}" alt="Logo" width="${logoWidth}" height="${logoHeight}"></a>`,
start: 'play',
end: 'pause',
align: overlayPosition,
showBackground: false
}]
});
};
imgTag.src = playerConfig.logo.image + '?' + Math.random();
if (playerConfig.logo.link.length !== 0) {
var aTag = document.createElement('a');
aTag.setAttribute('href', playerConfig.logo.link);
aTag.setAttribute('target', '_blank');
aTag.appendChild(imgTag);
overlay = aTag.outerHTML;
} else {
overlay = imgTag.outerHTML;
}
player.overlay({
align: playerConfig.logo.position,
overlays: [
{
showBackground: false,
content: overlay,
start: 'play',
end: 'pause',
},
],
});
}
player.ready(function() {