title: How to embed some YouTube videos on non-public domain pages?
body: <p>I am currently writing an audioplayer with which YouTube videos can be played &amp; controlled with hotkeys. However, I am having an issue: Videos that should be available for embedding get a "Not available" error for some reason. </p>
  
  <p>An example of the embedding code:</p>
  
  <pre><code>&lt;iframe width="560" height="315" src="https://www.youtube.com/embed/d6QE4EJrIFc" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>When I paste this into any random .html file and open it in my browser, I get the error stated above. However, when I paste the video in <code>JSFiddle</code> it can be embedded perfectly fine: <a href="https://jsfiddle.net/vnkLzh9r/3/" rel="nofollow noreferrer">https://jsfiddle.net/vnkLzh9r/3/</a></p>
  
  <p>The above trick with JSFiddle is something I got from this <a href="https://stackoverflow.com/a/55661292/6297856">StackOverflow answer</a>.</p>
  
  <p>As far as I am aware, there are no settings on YouTube to disalow embedding of videos on non-public domains, but yet that seems to be the problem here. Can anyone confirm if that is the underlying issue?</p>
  
  <p>In addition, is there a way for me to embed these videos without having to rely on a public domain? </p>
  
  <p><strong>Update</strong></p>
  
  <p>Okay, I have put the iFrame in an Angular project and hosted the project with NG serve. Then I access the page with <a href="http://localhost:4200" rel="nofollow noreferrer">http://localhost:4200</a> and the iframe actually works &amp; plays the video. For some reason, when I open the .html file with just the iframe in it, that the video does not want to play? In addition, I have the following debug info of the YT player:</p>
  
  <pre><code>{
    "ns": "yt",
    "el": "embedded",
    "cpn": "nVMH8LozAhZ1QLVb",
    "docid": "d6QE4EJrIFc",
    "ver": 2,
    "cmt": "0",
    "ei": "uUlYXfnOCoLj-gbKsYSAAQ",
    "fs": "0",
    "rt": "311.975",
    "euri": "",
    "lact": 1,
    "cl": "263586394",
    "mos": 0,
    "state": "80",
    "volume": 77,
    "c": "WEB_EMBEDDED_PLAYER",
    "cver": "20190816",
    "cplayer": "UNIPLAYER",
    "cbr": "Firefox",
    "cbrver": "68.0",
    "cos": "Windows",
    "cosver": "10.0",
    "hl": "en_US",
    "cr": "NL",
    "len": "254",
    "fexp": "23744176,23751767,23788875,23804281,23818122,23818585,23827085,23829162,23832308,23834462,9449243",
    "size": "315:560",
    "inview": "1",
    "vct": "0.000",
    "vd": "NaN",
    "vpl": "",
    "vbu": "",
    "vpa": "1",
    "vsk": "0",
    "ven": "0",
    "vpr": "1",
    "vrs": "0",
    "vns": "0",
    "vec": "null",
    "vvol": "0.77",
    "creationTime": 313013,
    "totalVideoFrames": 0,
    "droppedVideoFrames": 0,
    "corruptedVideoFrames": 0,
    "debug_error": {
      "errorCode": "auth",
      "errorDetail": "0",
      "errorMessage": "Video unavailable",
      "Ph": "",
      "Uz": "0"
    },
    "relative_loudness": "NaN",
    "user_qual": "hd1080",
    "debug_videoId": "d6QE4EJrIFc",
    "0sz": false,
    "op": "",
    "yof": false,
    "dis": "",
    "gpu": "ANGLE_(NVIDIA_GeForce_GTX_1070_Ti_Direct3D11_vs_5_0_ps_5_0)",
    "cgr": true,
    "debug_playbackQuality": "unknown",
    "debug_date": "Sat Aug 17 2019 20:44:08 GMT+0200 (Central European Summer Time)"
  }
  </code></pre>