Introducing MMM-YouTubeWebView Module
doctorwhen last edited by
I have released the initial version of the MMM-YouTubeWebView MagicMirror module at https://gitlab.com/doctorfree/MMM-YouTubeWebView
This module allows embedding of YouTube videos, either singly or as a list of YouTube video IDs, or as a public YouTube playlist ID. The module uses the Electron webview tag rather than an iframe in an attempt to avert YouTube blocking the requested video for any of several reasons.
The webview tag is used to embed ‘guest’ content in the MagicMirror Electron app. The guest content is contained within the webview container. An embedded page within MagicMirror controls how the guest content is laid out and rendered.
Unlike an iframe, the webview runs in a separate process than MagicMirror. It doesn’t have the same permissions and all interactions between MagicMirror and embedded content will be asynchronous. This keeps MagicMirror safe from the embedded content.
Under the hood webview is implemented with Out-of-Process iframes (OOPIFs).
The webview tag is essentially a custom element using shadow DOM to wrap an
iframe element inside it. So the behavior of webview is very similar to a
cross-domain iframe. As such, it can be used to safely avoid cross-domain
policy restrictions that may prevent access to web content.
This module is based upon both the MMM-WebView module and the MMM-EmbedYoutube module with added functionality. There are some limitations to embedding with webview. These are detailed in the README. There may be a better way to do what I have done here. Possibly I should be using the Electron BrowserView instead. I would be open to suggestion. However, this release does accomplish what I set out to do - I can play my YouTube playlists and lists of YouTube videos without YouTube telling me the video is unavailable which is what I was seeing when using an iframe.
This is the initial release so I expect there will be significant changes in the near term. I’ve thoroughly tested it but expect issues will arise. The module is a work-in-progress and in active development.
Any feedback will be greatly appreciated.