Using 'nocookie' youtube api. Is this valid?


#1

Is this a valid javiscript code?
https://jsfiddle.net/2u41jtqm/

This code here: Added
host: 'https://www.youtube-nocookie.com',

Removed:
host: 'https://www.youtube-nocookie.com',

https://jsfiddle.net/2u41jtqm/1/


<div id="player"  class='video-frame' ></div>

<script>
  var tag = document.createElement('script');
  tag.src = "https://www.youtube.com/player_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  var player;

  function onYouTubePlayerAPIReady() {
    player = new YT.Player('player', {
      height: '315',
      width: '560',
      host: 'https://www.youtube-nocookie.com',
      videoId: 'bHQqvYy5KYo',
      playerVars: {
        autoplay: 0,
        loop: 0,
        controls: 1,
        showinfo: 1,
        autohide: 0,
        rel: 0,
        iv_load_policy: 3,
        cc_load_policy: 0,
        fs: 0,
        disablekb: 1,
        end: 281,
      },

      events: {
        'onReady': onPlayerReady
      }
    });
  }

  function onPlayerReady(event) {
    event.target.setVolume(100);
    event.target.stopVideo();

  }

</script>

#2

Can you answer this for me? @Paul_Wilkins
https://jsfiddle.net/8aebp5zt/50/

Does inspect element tell you anything?

Is this valid?

  host: 'https://www.youtube-nocookie.com',

 window.onYouTubePlayerAPIReady = function() {
    new YT.Player(document.querySelector(".js-player"), {
      height: '315',
      width: '560',
      host: 'https://www.youtube-nocookie.com',
      videoId: 'M7lc1UVf-VE',

It shows someone using it here:


#3

Yes, it seems to work.


#4

I was wondering because I couldn’t find any documentation on it at all.

I found someone talking about it here: It’s towards the bottom.