Skip to content

Teleport SDK Integration with Shaka Player ​

This section provides instructions for integrating the Teleport SDK with the Shaka Player media player for DASH and HLS content playback.

1. Script Connection ​

Ensure that you have connected the main Teleport SDK script and the loader for Shaka Player. You can use separate scripts or a ready-made bundle.

Separate Scripts: ​

html
<!-- Main Teleport SDK script -->
<script src="https://cdn.teleport.media/stable/teleport.js"></script>
<!-- Loader for Shaka Player -->
<script src="https://cdn.teleport.media/stable/teleport.shaka.js"></script>

Bundle (includes SDK, loader, and polyfills): ​

html
<script src="https://cdn.teleport.media/stable/teleport.shaka.bundle.js"></script>

2. Teleport SDK Initialization ​

After connecting the scripts, you need to initialize the Teleport SDK, passing your API key and the player instance.

js
// 1. Initialize Shaka Player
shaka.polyfill.installAll();
const videoElement = document.getElementById('video'); // Replace 'video' with the ID of your <video> element
const player = new shaka.Player(videoElement);

// 2. Initialize Teleport SDK
teleport.initialize({
    apiKey: "YOUR_API_KEY", // Your API key from the Teleport cabinet
    loader: {
        type: "shaka", // Plugin identifier for Shaka Player
        params: {
            player: player, // Pass the Shaka Player instance
            shakaModule: shaka // (Since v1.95.72) Optional: Shaka Player module
        }
    }
})
.then(function (instance) {
    console.log('Teleport SDK successfully initialized for Shaka Player!', instance);
    // Here you can load your manifest
    player.load('YOUR_MANIFEST_URL'); // URL of your DASH/HLS manifest
})
.catch(function (error) {
    console.error('Teleport SDK initialization error:', error);
});

// Optional: release Teleport resources when closing the page
window.addEventListener("unload", function () {
    if (tlprt) {
        tlprt.dispose();
        tlprt = null;
    }
});

Using with ES Modules / Bundlers (since v1.95.72) ​

Starting from version 1.95.72, Teleport SDK supports running without requiring shaka in the global scope (window.shaka).

If Shaka Player is imported locally in your project (e.g. import shaka from 'shaka-player'), pass the library object via shakaModule:

js
import shaka from 'shaka-player';

// Initialize player
shaka.polyfill.installAll();
const player = new shaka.Player(videoElement);

teleport.initialize({
    apiKey: "YOUR_API_KEY",
    loader: {
        type: "shaka",
        params: {
            player: player,
            shakaModule: shaka // Direct pass of the Shaka Player module (available since v1.95.72)
        }
    }
});

Instance Isolation (since v1.95.72)

Starting with version 1.95.72, the plugin isolates network interception per instance: Teleport only handles traffic for the player passed to params.player. Other Shaka Player instances on the page not connected to Teleport continue normal direct CDN playback without Teleport plugin interception.

Additional Configuration

For finer tuning of Teleport SDK behavior (e.g., URL cleaning, segment quality detection), refer to the Customization section.