Skip to main content

Stream Concurrency

The stream concurrency library is a personalization library that facilitates stream concurrency check during playback and aborts playback if check fails. The library facilitates check for concurrent streams of any content at different stages of playback and abort playback if the number of concurrent streams exceeds allowed limit.

The StreamConcurrencyService is the interface for stream check contract which has all the APIs to perform different stream operations (Put & Delete). The streamConcurrencyResolver is composed on stream concurrency service to validate stream checks with Player and ComposablePlayer.

Usage

Create StreamConcurrencyService

const streamConcurrencyService = flStreamConcurrency.createStreamConcurrencyService(
streamConcurrencyEndPointUrl,
platformAuthorizer,
);

Create createStreamConcurrencyResolver

const streamConcurrencyConfiguration = {
endPointUrl: endpoint,
syncIntervalMS: 3000,
};
// deviceId is the unique id against which stream concurrency is done
const streamConcurrencyResolver = createStreamConcurrencyResolver(
deviceId,
streamConcurrencyConfiguration,
platformAuthorizer,
streamConcurrencyService,
);

Stream Check for Content

The StreamConcurrencyResolver has methods to check streams at different stages of playback. One could invoke these method during playback on their own or use it along with ComposablePlayer to automate the same. For using it with ComposablePlayer add the functions with stream concurrency resolver as inputs to addStateChangeStep(:) to validate stream check during playback state change and playback progress respectively

// Using streamConcurrencyResolver with ComposablePlayer
composablePlayer.addStateChangeStep(
streamConcurrencyResolver.processPlayerStateChange,
);