Answer the question
In order to leave comments, you need to log in
YouTube API video playback not working - what to do?
So it goes.
HTML:
<div id="ytapiplayer">
You need Flash player 8+ and JavaScript enabled to view this video.
</div>
const params = { allowScriptAccess: "always" };
const atts = { id: "myytplayer" };
swfobject.embedSWF("http://www.youtube.com/v/MQ3k6BFX2uw?enablejsapi=1&playerapiid=ytplayer&version=3",
"ytapiplayer", "100%", "100%", "8", null, null, params, atts);
const onYouTubePlayerReady = playerId => {
const ytplayer = document.getElementById("myytplayer");
if (ytplayer) {
console.log('before'); // выводится
ytplayer.playVideo();
console.log('after'); // не выводится
}
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question