sampotts / plyr

A simple HTML5, YouTube and Vimeo player
https://plyr.io
MIT License
26.32k stars 2.92k forks source link

Plyr won't initialise using the source api method #1936

Open realmocaccino opened 4 years ago

realmocaccino commented 4 years ago

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');
 });
4ssil commented 4 years ago

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.

AlecRust commented 3 years ago

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.

danimalweb commented 1 year ago

I am also facing this issue.

cimenta commented 11 months ago

any updates on the fix?