Skip to content

Instantly share code, notes, and snippets.

@pierreabreup
Created March 8, 2020 17:08
Show Gist options
  • Save pierreabreup/5a0bb1ef7b0e82765d4144918c8cd6e1 to your computer and use it in GitHub Desktop.
Save pierreabreup/5a0bb1ef7b0e82765d4144918c8cd6e1 to your computer and use it in GitHub Desktop.
Tracking xAPI statemente event on H5P
import React from 'react'
import PropTypes from 'prop-types'
const H5pContent = ({ iframeSrc }) => {
const handleContentRef = dom => {
if (dom) {
dom.onload = () => {
dom.contentWindow.H5P.externalDispatcher.on('xAPI', function(event) {
console.log('INITIAL STATEMENT ON externalDispatcher')
console.log(event.data.statement)
})
}
}
}
return (
<iframe
title='h5p-embed'
ref={handleContentRef}
src={iframeSrc}
frameBorder='0'
allowFullScreen='allowfullscreen'
/>
)
}
H5pContent.propTypes = {
iframeSrc: PropTypes.string.isRequired,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment