When I create an instance of YT.Player(HTMLIFrameElement, { options }) I get back an object that has:
- destroy
- setSize
- getIframe
- addEventListener
- getVideoEmbedCode
- getOptions
- getOption
But not playVideo, pauseVideo etc as described in the documentation.
I got a demo here: http://siesta-annotations.surge.sh/Siesta_webviewer_test/?page=3
I am creating the iframes via the DOM in trait.playable.youtube.js and adding the iframe to a documentFragment that eventually will be added to a div:
const element = document.createElement('iframe')element.src = `https://www.youtube.com/embed/${id}?rel=0;&autoplay=${this.options.autostart ? 1 : 0};&enablejsapi=1;&origin=${location.hostname};`element.style = this.inlineStyleI then create an instance of YT.Player:
// nasty initialization because we're outside webpack and this is a demoif (global.YT.loaded) { this.player = new global.YT.Player(element, { events: {'onStateChange': this.stateHandler,'onReady': onPlayerReady } })} else { const oldHandler = global.onYouTubeIframeAPIReady global.onYouTubeIframeAPIReady = () => { if (oldHandler) oldHandler() this.player = new global.YT.Player(element, { events: {'onStateChange': this.stateHandler,'onReady': onPlayerReady } }) }}The instance of YT.Player looks something like this:
It looks like the minification process went very wrong. What am I doing wrong - how should I initialise YT.Player for my use-case?
