Cant load youtube api in frame

184 Views Asked by At

Im tying to make a addon and just want to control youtube from the Frame property. In normal javasrcipt and html I can load the youtube api and use the player.playVideo functions but when I try to load the html page into a Frame it appreas there but I get an error: "Type error player.playVideo is not a function"

1

There are 1 best solutions below

5
On

Iframes segregate their content from that of the page into which they are added. If you have the youtube API in the frame, but you're calling player.Playfrom the parent page it wont work because the parent page does not have direct access to the iframe's content (ie. the API). Instead you need to call the api method from the context of the frame such as FrameName.player.Play