I searched the youtube API's and web but could not run into an tutorial that demonstrates the following:
Assume we got an embed like this:
<iframe id="ytplayer" type="text/html" width="640" height="360"
src=""
frameborder="0"></iframe>
And we got a button like this:
<button onclick="playVideo()">Play Video</button>
And the playVideo function, does its own business logic and then say come up with a SRC url like this:
srcURL = 'https://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1';
At this point, to start the video, I currently do this ( and it works )
document.getElementById("ytplayer").src = srcURL;
My approach does works but limited. It does start the video but how do you stop it, pause it?
The tutorials I run into all got a starting point like this:
... player = new YT.Player('player', { ...
But that does not apply here. Is there a way to tell the browser, hey your ytplayer is in the iframe itself, then all the startVideo, stopVideo methods of the YT would work.