How to implement an HLS stream into hbbtv

186 Views Asked by At

The problem is implementing an HTTP Live Streaming (also known as HLS) in HbbTV I cannot find a solution for it

I tried this for example

<!DOCTYPE html>
<html>
<head>
  <title>HbbTV Stream</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script type="text/javascript">
    function initApp() {
      var videoElement = document.createElement("video");
      videoElement.setAttribute("type", "application/vnd.apple.mpegurl");
      videoElement.setAttribute("src", "http.//example.com/test.m3u8");
      videoElement.setAttribute("data-fullscreen", "true");
      videoElement.setAttribute("data-pauseonexit", "true");
      videoElement.setAttribute("autoplay", "");
      videoElement.addEventListener("error", function(e) {
        console.log("Video error:", e);
      });
      document.body.appendChild(videoElement);
    }
  </script>
</head>
<body onload="initApp()">
</body>
</html>
1

There are 1 best solutions below

0
Anonymous Coward On

It won't help on older devices but if you are targeting HBBTV 2.0.3 or later, devices should have support for Media Source Extensions, so you could try use a javascript-based player such as hls.js or similar.