hlsPlayback.js 730 B

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