Skip to content

HLS (HTTP Live Streaming) support#156

Closed
eduardokraus wants to merge 1 commit intoh5p:masterfrom
EduardoKrausME:master
Closed

HLS (HTTP Live Streaming) support#156
eduardokraus wants to merge 1 commit intoh5p:masterfrom
EduardoKrausME:master

Conversation

@eduardokraus
Copy link

This PR adds support for HLS (HTTP Live Streaming) in the H5P video player.
Now, .m3u8 files can be used as a video source, enabling adaptive playback across different bandwidths and devices.

Main changes

  • Added automatic detection of .m3u8 URLs.
  • Integrated hls.js for browsers without native HLS support.
  • Kept fallback to the HTML5 player when native support is available (e.g., Safari).
  • Updated the player initialization logic to handle HLS streams transparently for the user.

@otacke
Copy link
Contributor

otacke commented Aug 20, 2025

Disclaimer: I am not part of H5P Group, so feel free to conpletely ignore my suggestions (which are based on a quick glance only anyway and not exhaustive).

Essentially the same recommendations to speed up the review process and to avoid unnecessary feedback loops that I gave you for #155

  • You should ensure that your code adheres to the H5P Coding styleguide, e. g. indentation, positioning of else, use of == instead using ===, ...
  • While old H5P code uses ES5, newly written code should use ES6.
  • Are you sure this works without also modifying the list of providers in the AV widget?
  • You might want to check if this works properly for both, standalone videos and videos used in InteractiveVideo. This has caused issued here and there for other video handlers before.

@eduardokraus
Copy link
Author

  • 1,2: Yes, the edit was made directly in the original html5.js file from H5P.
  • 3: Yes, because the validation only checks for the .m3u8 extension before verifying whether the file has native browser support. It’s not necessary to edit the AV Widget, especially since html5 H5P doesn’t provide a specific entry for it.
  • 4: The tests were carried out with both interactive and simple videos, individually as well as inside the Interactive Book resource.

@eduardokraus
Copy link
Author

In this PR I added support for videos with the .m3u8 (HLS) extension for browsers without native support.

The behavior works as follows:

  • If the video URL has the .m3u8 extension, the browser is checked for native HLS support. If native support exists, the video plays normally.
  • If not, the HLS.js library is dynamically loaded, and then the hls.loadSource method is called to load and prepare the video for playback, ensuring compatibility in browsers that don’t support .m3u8 natively.

👉 This way, the player now provides consistent HLS stream support both in browsers with native support and in those that rely on HLS.js.

@otacke
Copy link
Contributor

otacke commented Aug 20, 2025

@eduardokraus
1 and 2) You merely edited an existing file, that's true. But all newly written code should use ES6 (incl. arrow functions). Also your code does not follow the the coding style guide.

  1. Great. I'd have expected that this file extension would need to be white listed in H5P core before it can be used. The default extensions that are allowed are set in https://github.com/h5p/h5p-php-library/blob/1afd89a8bd1df4843dd946a82aaff35d62fdc507/h5p.classes.php#L2108.

  2. Excellent!

@eduardokraus
Copy link
Author

@otacke #157

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants