Hi, here is what you need to put in the editor in order to show a video that will close the popup at the end. Replace XXXXXXXX by your youtube id.
Have a good day.
<div id="player"></div>
<script type="text/javascript">// <![CDATA[
//Load player api asynchronously.
var tag = document.createElement('script');
tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var done = false;
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '360',
width: '640',
videoId: 'XXXXXXXX',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(evt) {
evt.target.playVideo();
}
function onPlayerStateChange(evt) {
if (evt.data == YT.PlayerState.ENDED && !done) {
document.getElementById('spmCloseButton').click();
done = true;
}
}
// ]]></script>