hls.js is a JavaScript library that implements the HTTP Live Streaming client. It uses HTML5 video and MediaSource Extensions for playback.

Supported versions of HLS.js

Teleport.js is compatible with HLS.js version 0.7.0 and later.

Before start

Before teleport.js in initialized the first time, you need to validate the domain and get the API key in Teleport client area.


To load chunks from P2P you need:

  1. Create an instance of HLS.js.
  2. Initialize Teleport with loader params and API key as an argument.


<!doctype html>
<html lang="en">
        <meta charset="UTF-8">
        <title>TELEPORT HLSJS EXAMPLE</title>
        <video id="video" width="640" controls autoplay></video>
        <script src="https://cdn.jsdelivr.net/hls.js/latest/hls.min.js"></script>
        <script src="https://cdn.teleport.media/stable/teleport.hlsjs.bundle.js"></script>
            var tlprt;
            var STREAM_URL = "<manifest URL>";
            var API_KEY = "<YOUR APIKEY>";

            function initApp() {
                // Create player
                var hls = new Hls();
                var video = document.getElementById('video');


                hls.on(Hls.Events.MANIFEST_PARSED, function () {

                // Init Teleport
                            apiKey: API_KEY,
                            loader: {          // Loader configuration
                                type: "hlsjs", // Plagin ID
                                params: {
                                    hlsjs: hls // Player instance
                        .then(function (instance) {
                            // save teleport instance
                            tlprt = instance;

                            console.log("The video has now been loaded!");
                            // Subscribe to on close window event for free used resources
                            window.addEventListener("unload", function () {
                                if (tlprt) {
                                    tlprt = null;

            function onError(error) {
                // Log the error
                console.error("Error code", error.code, "object", error);

            document.addEventListener("DOMContentLoaded", initApp);

API docs could be found here