plyr icon indicating copy to clipboard operation
plyr copied to clipboard

Plyr won't initialise using the source api method

Open realmocaccino opened this issue 5 years ago • 4 comments

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');
 });

realmocaccino avatar Aug 19 '20 06:08 realmocaccino

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.

4ssil avatar Sep 06 '20 20:09 4ssil

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.

AlecRust avatar Jun 06 '21 14:06 AlecRust

I am also facing this issue.

danimalweb avatar Feb 01 '23 21:02 danimalweb

any updates on the fix?

cimenta avatar Sep 16 '23 13:09 cimenta