h5p-player-setup
Self-host the H5P player
@missing-elements/h5p-offline-player is one custom element, <h5p-player>. It plays a .h5p
package from a URL or a picked file: the archive is read in place and a Service Worker serves
its files to the H5P runtime. Everything runs on infrastructure the user controls: no H5P
server, no backend, no third-party service. A site either installs it, or embeds it — an
iframe of a player page on a separate domain the site's organisation runs. Installed, three things matter: the
element (h5p-player.js), the worker (h5p-sw.js) and the runtime, which is a second package,
@missing-elements/h5p-runtime, because it is GPL-3.0 while the player is MIT. Only the worker
has to be served from the site's own origin; browsers refuse a cross-origin Service Worker.
1. Pick the setup
Decide by what is on the site's origin, not by its tooling. An H5P package is JavaScript and
the player runs it on the origin that serves the frame: installed on the site, a package can
read the page, its non-HttpOnly cookies and storage, and call the site's APIs as the signed-in
user. Ask, or read from the project: does the site have signed-in users; who makes the
packages; does it need results with the learner's identity, resume="host", cmi5 or a file
picker; can it host a file at all.