MC playlist *********** Note: The multi-controller (MC) playlist API is experimental. "McPlaylist" (https://players.castlabs.com/web/latest/docs/api/clpp.playlist.McPlaylist.md) — experimental. Reduces zap time between live TV channels by preloading neighboring items, each with its own player instance. Code samples: * Fast channel zapping (https://raw.githubusercontent.com/castlabs/prestoplay-web-code-samples/refs/heads/main/examples/live/fast_zapping.js): switches between live DASH channels with "McPlaylist" and shows the zap time. Configure for fast switching ============================ Set "streaming.rebufferingGoal" and "streaming.bufferingGoal" below the video segment duration for fastest channel switching. player.open({ source: { url: "https://.../index.mpd", }, streaming: { // For 2-second segments, set both goals below 2 seconds rebufferingGoal: 1, bufferingGoal: 1, startAtSegmentBoundary: true, ignoreDrift: true, }, }); For DRM-protected streams, install the "PersistentLicenseComponent" (https://players.castlabs.com/web/latest/docs/api/clpp.persistent.PersistentLicenseComponent.md) and assign an "offlineId" to each protected stream — see Persistent DRM licenses. Browser support for persistent licenses is limited, so this helps only on some platforms. import "@castlabs/prestoplay/cl.mse"; import "@castlabs/prestoplay/cl.hls"; import "@castlabs/prestoplay/cl.dash"; import "@castlabs/prestoplay/cl.persistent"; player.open({ source: { url: "https://.../index.mpd", }, drm: { env: "...", customData: { /* ... */ }, offlineId: "drm-session-4fb0b23a50101171ec90656", // unique ID for local storage }, }); Create the playlist =================== Pass the Castlabs license and viewer ID through "config": const playlist = new clpp.playlist.McPlaylist({ anchorId: "video-anchor", config: { license: "", viewerId: "", }, // preloadMedia: true, // autoplayNext: true, }); * "autoplayNext" starts the next item automatically when playback ends. It's intended for VOD content. * "preloadMedia" prebuffers upcoming items to reduce transition time. It's intended for VOD content. Set items and navigate ====================== "setItems(configs)" and "setIndex(i)" set content. "playFirst()", "playNext()", and "playPrev()" navigate. "hasNext()" and "hasPrev()" report availability. "on('update', fn)" fires on state changes; "on('error', fn)" fires on background errors such as preload failures. const playlist = new clpp.playlist.McPlaylist({ anchorId: "video-anchor" }); playlist.setItems([ { source: { url: "https://.../Manifest.mpd" }, autoplay: true, }, { source: { url: "https://.../index.mpd" }, autoplay: true, }, ]); playlist.setIndex(0); playlist.on("update", () => { const canPlayNext = playlist.hasNext(); const canPlayPrev = playlist.hasPrev(); }); playlist.on("error", (error) => { console.error("Playlist error", error); }); await playlist.playNext(); Each item exposes its player and preload state through "playlist.getCurrent()", "getNext()", and "getPrev()", and the currently active player through "playlist.getCurrentPlayer()". Call "playlist.destroy()" to release all players when you're done with the playlist.