• Resolved gievo2

    (@gievo2)


    Forgive me I am a little rough with javascript and the youtube api.

    I’ve been banging my head against the wall trying to set up a external play button from the iframe with this plugin.

    I have followed the instructions to the tee from here. https://tutorialzine.com/2015/08/how-to-control-youtubes-video-player-with-javascript

    This is my code. (as the ID of the loaded iframe changes on each page refresh, i have changed the selector to grab by class as there is only 1 player on the page.

    var player;
    
    function onYouTubeIframeAPIReady() {
        player1 = new YT.Player(document.querySelector('.yotu-video-placeholder'), {
            width: 600,
            height: 400,
            playerVars: {
                color: 'white',
            },
            events: {
                onReady: initialize
            }
        });
    }
    
    function initialize(){
    }
    $('#play-button').on('click', function () {
        player.playVideo();
    });

    Thank you for your work on this amazing plugin,

    Regards
    ~Will

    • This topic was modified 6 years ago by gievo2.
  • The topic ‘player.playVideo() seems to be not working with this plugin.’ is closed to new replies.