Side-loaded text tracks

Code samples

Use config.remoteTextTracks to add side-loaded (“sidecar”) subtitle files that aren’t present in the manifest. Each entry follows RemoteTextTrack, and mimeType must match a format whose module is imported, for example text/vtt or text/srt with the VTT module.

Note

With MSE playback, side-loaded text tracks are only supported for video on demand (VOD). Adding them to a live stream fails with the CANNOT_ADD_EXTERNAL_TEXT_TO_LIVE_STREAM error.

<link rel="stylesheet" href="./clpp.styles.css">
<video id="video" width="640" height="360" controls crossorigin="anonymous"></video>
<script type="module">
  import { clpp } from "@castlabs/prestoplay";
  import "@castlabs/prestoplay/cl.mse";
  import "@castlabs/prestoplay/cl.vtt";
  import "@castlabs/prestoplay/cl.htmlcue";

  const player = new clpp.Player('video', { });

  player.open({
    source: '...',
    remoteTextTracks: [
      {
        url: 'https://example.com/subtitles/en.vtt',
        kind: 'subtitles',
        language: 'eng',
        mimeType: 'text/vtt',
        label: 'English'
      },
      {
        url: 'https://example.com/subtitles/es.vtt',
        kind: 'subtitles',
        language: 'spa',
        mimeType: 'text/vtt',
        label: 'Spanish'
      }
    ]
  });
</script>
Next topic: Text displayers
Previous topic: WebVTT and SRT