Skip to content Skip to sidebar Skip to footer

Embedding Youtube Video In Chrome Extension

I would like to embed a video hosted on YouTube and play it when the user clicks on a button in popup.html. I was following the solution listed here: Showing a YouTube video in a

Solution 1:

You are using a protocol-relative URL:

src="//www.youtube.com/embed/XXXXXX?html5=1"

At the same time, the embedding page has a URL like

chrome-extension://yourextensionidhere/page.html

This results in an src URL

chrome-extension://www.youtube.com/embed/XXXXXX?html5=1

which is obviously invalid and results in a network error (rendered in a subframe as a grey page with a sad face).

To resolve this, change the protocol-relative URL to explicit https://...

Post a Comment for "Embedding Youtube Video In Chrome Extension"