PlaybackSessionManager


@UnstableApi
public 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 methods

abstract boolean
belongsToSession(
    AnalyticsListener.EventTime eventTime,
    String sessionId
)

Returns whether an event time belong to a session.

abstract void

Finishes all existing sessions and calls their respective onSessionFinished callback.

abstract @Nullable String

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

abstract String
getSessionForMediaPeriodId(
    Timeline timeline,
    MediaSource.MediaPeriodId mediaPeriodId
)

Returns the session identifier for the given media period id.

abstract void

Sets the listener to be notified of session updates.

abstract void

Updates or creates sessions based on a player EventTime.

abstract void

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

abstract void

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

Public methods

belongsToSession

abstract boolean belongsToSession(
    AnalyticsListener.EventTime eventTime,
    String sessionId
)

Returns whether an event time belong to a session.

Parameters
AnalyticsListener.EventTime eventTime

The EventTime.

String sessionId

A session identifier.

Returns
boolean

Whether the event belongs to the specified session.

finishAllSessions

abstract void finishAllSessions(AnalyticsListener.EventTime eventTime)

Finishes all existing sessions and calls their respective onSessionFinished callback.

Parameters
AnalyticsListener.EventTime eventTime

The event time at which sessions are finished.

getActiveSessionId

abstract @Nullable String getActiveSessionId()

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

getSessionForMediaPeriodId

abstract String getSessionForMediaPeriodId(
    Timeline timeline,
    MediaSource.MediaPeriodId mediaPeriodId
)

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.

MediaSource.MediaPeriodId mediaPeriodId

A MediaPeriodId.

setListener

abstract void setListener(PlaybackSessionManager.Listener listener)

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

Parameters
PlaybackSessionManager.Listener listener

The Listener to be notified of session updates.

updateSessions

abstract void updateSessions(AnalyticsListener.EventTime eventTime)

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
AnalyticsListener.EventTime eventTime

The EventTime.

updateSessionsWithDiscontinuity

abstract void updateSessionsWithDiscontinuity(
    AnalyticsListener.EventTime eventTime,
    @Player.DiscontinuityReason int reason
)

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

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

Parameters
AnalyticsListener.EventTime eventTime

The EventTime of the position discontinuity.

@Player.DiscontinuityReason int reason

The DiscontinuityReason.

updateSessionsWithTimelineChange

abstract void updateSessionsWithTimelineChange(
    AnalyticsListener.EventTime eventTime
)

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

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

Parameters
AnalyticsListener.EventTime eventTime

The EventTime with the timeline change.