Excluding some content types from the "Save content state" option

Forums: 

Hello, I need to exclude a specific content type (the interactive video) from resuming at the last state while keeping the "Save content State"option enabled globally.

I am looking for a simple way to achieve this exclusion without having to hack the module code. I understand the content state is managed by the getCurrentState() function implementation.

The platforms are Drupal 7 and 9.

Thank you in advance for any help.

otacke's picture

Hi fortran77!

I don't think there's a special hook for this purpose, but you could add another script when Interactive Video is loaded that overloads or deletes the getCurrentState function on the instance. There is a hook that you can use to add your scripts to the iframe, see https://h5p.org/drupal-customization

Best, 

Oliver 

I guess my goal is simply to rewind the video to time 0 each time the page is reloaded regardless of saved state or reached interactions. I tried overriding getCurrentState but this does not seem to help. What would be the way to rewind the video regardless of interactions after it has loaded but before it starts playing?

otacke's picture

In that case you'd probably want to attach a listener to the video instance, wait for it to be loaded and then seek to 0.

Thank you Oliver.

I tried the 'loaded' event but that did not work.

After searching the library code I found the 'stateChange' event that seems to fire at a better time, then using instance.video.play() and instance.video.seek(0) I seem to be able to set the video time to 0, but still the overall behavior of the player appears to be a little erratic.

Does anybody know where the full list of H5P video events can be referenced?

Thanks again.

 

otacke's picture

Hi!

If you have found the repository then you should have found https://github.com/h5p/h5p-video as well.

Cheers,

Oliver

papi Jo's picture

It would be useful if the "Save content state" were an individual option in each H5P content rather than an overall feature.

Hi Oliver, thank you so much for the help.

One more question: what would be the proper way to check for the current H5P content type? Is there eg a specific property of the H5P object that stores the H5P type loaded on the current page? I tried the H5P.instances but was getting an empty array so I have been relying on the wrapping html class names but I imagine there is a better way.