svelte-youtube icon indicating copy to clipboard operation
svelte-youtube copied to clipboard

event.target is null

Open thesayyn opened this issue 3 years ago • 3 comments

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

thesayyn avatar Apr 12 '21 19:04 thesayyn

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

willwillems avatar May 27 '21 12:05 willwillems

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>

MarcSallent avatar Jun 16 '22 08:06 MarcSallent

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

dlgudw123 avatar Jun 04 '23 07:06 dlgudw123