Attaching a javascript file on H5P pages in a custom module in drupal 8

Forums: 

I am creating a new module in which a have a js which i want to integrate on pages which have h5p content. At present I am using the hook element info alter as follows

function memodule_element_info_alter(array &$types)

      {

           if (isset($types['html']))

               { $types['html']['#attached']['library'][] = 'mymodule/mymodule';

       }

}

I have used html as I was unable to find $type for h5p. html here attaches the js file to all pages. Can you help me with this problem? Is their another solution for including js in pages with h5p content.

icc's picture

Have you tried implementing the hook_h5p_scripts_alter?

I'm not getting how the function is working i.e. what parameters are used and all that...Can you please elaborate?

Thank You...

icc's picture

Ah, I am sorry I did not notice that it was for Drupal 8. I believe you should be using the hook_library_info_alter.

Thanks, it worked. 

Shall I get all code used in hook_library_info_alter.