psychopy.org | Reference | Downloads | Github

Unable to get iframe video duration

I’m trying to get one of my routines to end when the embedded iframe video ends. I figured using the getDuration from the Youtube API would work but I’m having no luck. Any ideas?

 <!doctype html>
<html style="width: 100%; height: 100%;">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="user-scalable=no">
    <script src="https://www.youtube.com/player_api"></script>
  <style>
    .player {
    pointer-events: none;
    position: absolute;
            }
  </style>
  <script>

function onYouTubeIframeAPIReady() 
	{
    console.log('API ready')
    var player = new YT.Player('player', 
    	{
        events: 
            {
            'onReady': onPlayerReady
            }
       	}
            				   )					
     }    

function onPlayerReady(event) 
  {
  var getDur = event.target.getDuration();
  console.log(getDur);
  }
</script>
</head>
 
  <body style="width: 95vw; height: 95vh; position: relative;">
    <iframe class="player" id="player" style="width: 60%; height: 60%; display: block; position: absolute; top: 60%; left: 60%; transform: translate(-50%, -50%);" src="https://www.youtube.com/embed/F7mKD2Un65I?&amp;cc_load_policy=3&amp;autoplay=1&amp;start=0&amp;fs=0&amp;controls=0&amp;modestbranding=1&amp;disablekb=1&amp;loop=1"></iframe>

    </script>
  </body>
</html>