title: How to load and play YouTube video into UIWebView in my iOS app?
body: <p>I have a WebView in my iOS app. This webView is loading an web page that contains a youtubeVideo using </p>
  
  <pre><code>myWebView.loadHTMLString
  </code></pre>
  
  <p>The YouTube-video appears good but when I click to play, this show the "not available" message.</p>
  
  <p>The video is loaded in the html webPage using amp:</p>
  
  <pre><code>&lt;script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"&gt;&lt;/script&gt;
  
  &lt;amp-youtube width="480"
    height="270"
    layout="responsive"
    data-videoid="lBTCB7yLs8Y"&gt;
  &lt;/amp-youtube&gt;
  </code></pre>
  
  <p>I can see that the url request then script load the html with shouldStartLoadWithRequest delegate webView function and is the embed url video:
  <a href="https://www.youtube.com/embed/lBTCB7yLs8Y?enablejsapi=1&amp;amp=1&amp;playsinline=1" rel="nofollow noreferrer">https://www.youtube.com/embed/lBTCB7yLs8Y?enablejsapi=1&amp;amp=1&amp;playsinline=1</a></p>
  
  <p>When I added a YouTube video into a webView on another app like this, I only need add YouTube url in baseURL and this works correctly...:</p>
  
  <pre><code>wk.loadHTMLString("&lt;iframe height=\"315\" src=\"https://www.youtube.com/embed/4CEflj1qQ8M?enablejsapi=1&amp;origin=http://example.com\" style=\"width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;\" width=\"560\"&gt;&lt;/iframe&gt;", baseURL: URL(string : "www.youtube.com"))
  </code></pre>
  
  <p>How can now play the video correctly? Thanks!</p>