Fix videojs overlay
This commit is contained in:
parent
aa168db7d5
commit
c04b924d9e
@ -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() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user