PlaybackSessionManager


@UnstableApi
interface PlaybackSessionManager

Known direct subclasses
DefaultPlaybackSessionManager

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


Manager for active playback sessions.

The manager keeps track of the association between window index and/or media period id to session identifier.

Summary

Nested types

A listener for session updates.

Public functions

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

Returns whether an event time belong to a session.

Unit

Finishes all existing sessions and calls their respective onSessionFinished callback.

String?

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

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.

Unit

Updates or creates sessions based on a player EventTime.

Unit

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

Unit

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

Public functions

belongsToSession

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

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

fun getActiveSessionId(): String?

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

getSessionForMediaPeriodId

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

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

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

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.