hlsPlayback.js 851 B

12345678910111213141516171819202122232425
  1. // @license http://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
  2. // SPDX-License-Identifier: AGPL-3.0-only
  3. function playVideo(overlay) {
  4. const video = overlay.parentElement.querySelector('video');
  5. const url = video.getAttribute("data-url");
  6. video.setAttribute("controls", "");
  7. overlay.style.display = "none";
  8. if (Hls.isSupported()) {
  9. var hls = new Hls({autoStartLoad: false});
  10. hls.loadSource(url);
  11. hls.attachMedia(video);
  12. hls.on(Hls.Events.MANIFEST_PARSED, function () {
  13. hls.loadLevel = hls.levels.length - 1;
  14. hls.startLoad();
  15. video.play();
  16. });
  17. } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
  18. video.src = url;
  19. video.addEventListener('canplay', function() {
  20. video.play();
  21. });
  22. }
  23. }
  24. // @license-end