H5P.instances is empty

Forums: 

I am trying to add a custom event listners to H5P.

But the below code not working for some content types.

H5P.instances is empty for:

https://h5p.org/presentation
https://h5p.org/content-types/crossword
https://h5p.org/find-the-words

H5P.instances is not empty for:

https://h5p.org/collage
https://h5p.org/memory-game

 

$.each(H5P.instances, function(index, instance) { H5P.on(instance, 'xAPI', H5P.xAPICustomFinishListener); });
Summary: 
H5P.instances is empty for some content types
otacke's picture

Hi!

That's because most H5P content types live inside an iframe where its scripts and stylesheets are within a different context. You can check the documentation about customization to learn about injecting scripts to the iframe (alter scripts hook).

Best,
Oliver