Skip to content

Commit

Permalink
Fix videojs overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
jstabenow committed Dec 4, 2024
1 parent aa168db commit c04b924
Showing 1 changed file with 16 additions and 29 deletions.
45 changes: 16 additions & 29 deletions public/_player/videojs/player.html
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit c04b924

Please sign in to comment.