DefaultPlaybackSessionManager


@UnstableApi
class DefaultPlaybackSessionManager : PlaybackSessionManager


Default PlaybackSessionManager which instantiates a new session for each window in the timeline and also for each ad within the windows.

By default, sessions are identified by Base64-encoded, URL-safe, random strings.

Summary

Constants

const Supplier<String!>!

Default generator for unique session ids that are random, Based64-encoded and URL-safe.

Public constructors

Creates session manager with a DEFAULT_SESSION_ID_GENERATOR to generate session ids.

Creates session manager.

Public functions

synchronized Boolean
belongsToSession(
    eventTime: AnalyticsListener.EventTime!,
    sessionId: String!
)

Returns whether an event time belong to a session.

synchronized Unit

Finishes all existing sessions and calls their respective onSessionFinished callback.

synchronized String?

Returns the session identifier of the session that is currently actively playing, or null if there no such session.

synchronized String!
getSessionForMediaPeriodId(
    timeline: Timeline!,
    mediaPeriodId: MediaSource.MediaPeriodId!
)

Returns the session identifier for the given media period id.

Unit

Sets the listener to be notified of session updates.

synchronized Unit

Updates or creates sessions based on a player EventTime.

synchronized Unit

Updates or creates sessions based on a position discontinuity at EventTime.

synchronized Unit

Updates or creates sessions based on a Timeline change at EventTime.

Constants

DEFAULT_SESSION_ID_GENERATOR

const val DEFAULT_SESSION_ID_GENERATORSupplier<String!>!

Default generator for unique session ids that are random, Based64-encoded and URL-safe.

Public constructors

DefaultPlaybackSessionManager

DefaultPlaybackSessionManager()

Creates session manager with a DEFAULT_SESSION_ID_GENERATOR to generate session ids.

DefaultPlaybackSessionManager

DefaultPlaybackSessionManager(sessionIdGenerator: Supplier<String!>!)

Creates session manager.

Parameters
sessionIdGenerator: Supplier<String!>!

A generator for new session ids. All generated session ids must be unique.

Public functions

belongsToSession

synchronized fun belongsToSession(
    eventTime: AnalyticsListener.EventTime!,
    sessionId: String!
): Boolean

Returns whether an event time belong to a session.

Parameters
eventTime: AnalyticsListener.EventTime!

The EventTime.

sessionId: String!

A session identifier.

Returns
Boolean

Whether the event belongs to the specified session.

finishAllSessions

synchronized fun finishAllSessions(eventTime: AnalyticsListener.EventTime!): Unit

Finishes all existing sessions and calls their respective onSessionFinished callback.

Parameters
eventTime: AnalyticsListener.EventTime!

The event time at which sessions are finished.

getActiveSessionId

synchronized fun getActiveSessionId(): String?

Returns the session identifier of the session that is currently actively playing, or null if there no such session.

getSessionForMediaPeriodId

synchronized fun getSessionForMediaPeriodId(
    timeline: Timeline!,
    mediaPeriodId: MediaSource.MediaPeriodId!
): String!

Returns the session identifier for the given media period id.

Note that this will reserve a new session identifier if it doesn't exist yet, but will not call any Listener callbacks.

Parameters
timeline: Timeline!

The timeline, mediaPeriodId is part of.

mediaPeriodId: MediaSource.MediaPeriodId!

A MediaPeriodId.

setListener

fun setListener(listener: PlaybackSessionManager.Listener!): Unit

Sets the listener to be notified of session updates. Must be called before the session manager is used.

Parameters
listener: PlaybackSessionManager.Listener!

The Listener to be notified of session updates.

updateSessions

synchronized fun updateSessions(eventTime: AnalyticsListener.EventTime!): Unit

Updates or creates sessions based on a player EventTime.

Call updateSessionsWithTimelineChange or updateSessionsWithDiscontinuity if the event is a Timeline change or a position discontinuity respectively.

Parameters
eventTime: AnalyticsListener.EventTime!

The EventTime.

updateSessionsWithDiscontinuity

synchronized fun updateSessionsWithDiscontinuity(
    eventTime: AnalyticsListener.EventTime!,
    @Player.DiscontinuityReason reason: Int
): Unit

Updates or creates sessions based on a position discontinuity at EventTime.

Should be called instead of updateSessions if a position discontinuity occurred.

Parameters
eventTime: AnalyticsListener.EventTime!

The EventTime of the position discontinuity.

@Player.DiscontinuityReason reason: Int

The DiscontinuityReason.

updateSessionsWithTimelineChange

synchronized fun updateSessionsWithTimelineChange(
    eventTime: AnalyticsListener.EventTime!
): Unit

Updates or creates sessions based on a Timeline change at EventTime.

Should be called instead of updateSessions if a Timeline change occurred.

Parameters
eventTime: AnalyticsListener.EventTime!

The EventTime with the timeline change.