Precache
The precache feature allows an application to prepare a session for playback at a later time. Once the application intends to use a fully precached session, the workflow for creating the session and fetching the manifest has already been completed. At this moment, the player only needs to start downloading chunks and initiate the playback. Implementing this approach results in a reduction in startup times.
1. Check your player compatibility
If you are implementing SmartLib with a player integration (Analytics integration, Analytics only integration and Ad insertion integration), refer to With player integration (official player) or With player integration (generic player).
For other cases, refer to Without player integration.
With player integration (official player)
Depending on the support of a "precache ended" event and the status of our integration on our end, an additional step may be necessary:
- If both the player and the platform are supported, step 3 is not required
- If either the player or the platform is not supported, step 3 is required
Name | Platforms | Status |
---|---|---|
With player integration (generic player)
In case of a Generic player integration, an additional method needs to be invoked once the player starts buffering the content and initiate the playback (when the application intends to use the precached session).
- Android
- iOS & tvOS
- Web
// Notify the lib that the application intends to use the precached session
mYourPlayerApi.notifyPrecacheEnded();
// Notify the lib that the application intends to use the precached session
[self.yourPlayerApi notifyPrecacheEnded];
// Notify the lib that the application intends to use the precached session
this.yourPlayerApi.notifyPrecacheEnded();
In that case, step 3 is not required.
Without player integration
As there is no player to initiate the event, the application itself has to trigger it. In that case, step 3 is required.
2. Configure the streaming session
To enable the precache, set the SESSION_PRECACHE
option to true. It has to be done before starting the session (i.e calling getURL
).
- Android
- iOS & tvOS
- Web
// Create a new streaming session object (1 per video session) and store it
StreamingSession session = SmartLib.getInstance().createStreamingSession();
// Set the precache option to true
session.setOption(StreamingSessionOptions.SESSION_PRECACHE, true);
// Create a new streaming session object (1 per video session) and store it
StreamingSession *session = [SmartLib createStreamingSession];
// Set the precache option to YES
[session setOption:SMARTLIB_SESSION_PRECACHE valueWithBool:YES];
// Create a new streaming session object (1 per video session) and store it
const session = SmartLib.getInstance().createStreamingSession();
// Set the precache option to true
session.setOption(StreamingSessionOptions.SESSION_PRECACHE, true);
3. Notify about precache ended
This step is necessary only if your player is not currently supported or is incompatible with the precache feature.
Once the application intends to use a precached session, call this method and resume the player buffering.
- Android
- iOS & tvOS
- Web
// Notify the lib that the application intends to use the precached session
session.precacheEnded();
// Notify the lib that the application intends to use the precached session
[session precacheEnded];
// Notify the lib that the application intends to use the precached session
session.precacheEnded();