Elliott
Elliott

Reputation: 4628

JW Player 7: Update logo after setup

Can the official JW Player Javascript API or an unofficial workaround be used to update the logo attribute after the player has already been set up (without having to set it up from scratch)?

Upvotes: 0

Views: 398

Answers (1)

jherrieven
jherrieven

Reputation: 425

Because JW7 uses HTML5 to render the supporting player UI elements, it is very easy to modify these elements on the fly using JavaScript.

The following JS function would allow you to modify the logo by calling it and passing the player id and the URL to the new logo image:

function changeJWLogo(playerId, logoUrl){
    var logoElem = document.querySelector('#'+playerId + ' .jw-logo');
    logoElem.style.backgroundImage='url('+logoUrl+')';
}

Example usage:

changeJWLogo('container','http://powered-by-haiku.co.uk/wp-content/uploads/2012/05/haiku.gif');

You could call this function immediately after the player has been setup using the onReady event listener:

jwplayer().on("ready", function(){ ... });

Or at any other time as required.

Upvotes: 1

Related Questions