hlsPlayback.js 809 B

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