1

I'm in way over my head on this one.

The goal is to be able to hit spacebar for play/pause, and f for fullscreen when the page loads.

I'm loading the YouTube embed like this:

<script src="https://www.youtube.com/iframe_api"></script>

<iframe
    id="player"
    frameborder="0"
    allowfullscreen="1"
    allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
    width="1280"
    height="720"
    src="https://www.youtube.com/embed/<?php echo $video_id; ?>?autoplay=1&amp;modestbranding=1&amp;iv_load_policy=3&amp;enablejsapi=1">
</iframe>

The question is, can I focus the iframe controls using postMessage? Or any other method?

If so which element in the iframe do I need to focus to be able to get it done? I think it's html5-video-container > video.

Don't think I even need the YouTube jsapi, but it's there for now.

I've been over this SO question about a dozen times and many others, as well.

Jeff
  • 5,535
  • 13
  • 43
  • 72

1 Answers1

0

You can't do it because you cannot insert the javascript required for postMessage to work into youtube's iframe.

Yes, I see that you created the iframe yourself on your page, but that's not how it works.

Jeff
  • 5,535
  • 13
  • 43
  • 72