plyr
plyr copied to clipboard
Plyr won't initialise using the source api method
I am trying to build from source setter but the player never gets ready.
<div id="player"></div>
document.addEventListener('DOMContentLoaded', function(){
player = new Plyr('#player');
player.source = {
type: 'video',
sources: [
{
src: 'TbN_ANREyHk',
provider: 'youtube',
},
],
};
});
It only works if I set from HTML5 properties:
<div id="player" data-plyr-provider="youtube" data-plyr-embed-id="TbN_ANREyHk"></div>
document.addEventListener('DOMContentLoaded', function(){
player = new Plyr('#player');
});
I confirm this ! Unless data-plyr-provider and data-plyr-embed-id attributes are specified initially in the player element, the player won't initialize.
Would be great to get this fixed! Plyr shouldn't depend on these attributes in the HTML when they can be set in the JS.
I am also facing this issue.
any updates on the fix?