A
A
Amongaro2016-10-14 10:32:25
YouTube
Amongaro, 2016-10-14 10:32:25

YouTube API. Replacing another block with a player. How is the player generated?

Hello. There is such a function.

function cteateIframe(videoID, divID){
        var player;

        player = new YT.Player(divID, {
            videoId: videoID,
            events: {
                'onReady': onPlayerReady
            }
        });

        function onPlayerReady(event) {
            event.target.stopVideo();
        }


        return player;
    }

Is it possible to make it return an object that can be used in a function
this.parentNode.replaceChild(iframe, this);
if
var iframe= cteateIframe(this.parentNode.dataset.id, 'youtube-iframe');

and correspondingly
this.parentNode.dataset.id = "<img id="playVideo" ...>"

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question