Skip to main content

index/functions/getTokenLiveStreamUrl.md

getTokenLiveStreamUrl(tokenName, baseUrl): string

Get redirect URL for a token live stream (HLS)

HTTP Live Streaming (HLS) playlist for live token streams. Returns the master playlist (.m3u8) that references variant streams.

Backend: Redirects to Mux HLS master playlist when stream is active.

Parameters​

ParameterTypeDescription
tokenNamestringToken name (lowercase)
baseUrlstringAPI base URL

Returns​

string

Full redirect URL to HLS playlist

Throws​

Error if token name is invalid or empty

Example​

const liveUrl = getTokenLiveStreamUrl('anime', 'https://api.example.com');
// → "https://api.example.com/v1/tokens/anime/assets/live.m3u8"

// Use with HLS.js
import Hls from 'hls.js';
const video = document.querySelector('video');
if (video && Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(liveUrl);
hls.attachMedia(video);
}

Since​

7.3.0