PandaWhisperer / svelte-youtube

YouTube IFrame Player API for Svelte
22 stars 8 forks source link

event.target is null #4

Open thesayyn opened 3 years ago

thesayyn commented 3 years ago

The doc says that we can access the underlying youtube API with ready events target property which is null in my case.

willwillems commented 3 years ago

For a quick fix export the player variable in the svelte YT component and bind:player in the parent to access the payer instance.

MarcSallent commented 2 years ago

bind:player didn't work for me (or I did it wrong)

however, I could access the player from event.detail.target in the onReady event

// script
let player
function onReady(event) {
    player = event.detail.target
    player.playVideo()
}

// html
<YouTube on:ready={onReady}></YouTube>
dlgudw123 commented 1 year ago

MarcSallent THANK YOU SO MUCH I had not found the solution before read this.