PlaybackSessionManager
@UnstableApi
public interface PlaybackSessionManager
DefaultPlaybackSessionManager |
Default |
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 |
|---|
public interface PlaybackSessionManager.ListenerA listener for session updates. |
Public methods |
|
|---|---|
abstract boolean |
belongsToSession(Returns whether an event time belong to a session. |
abstract void |
finishAllSessions(AnalyticsListener.EventTime eventTime)Finishes all existing sessions and calls their respective |
abstract @Nullable String |
Returns the session identifier of the session that is currently actively playing, or |
abstract String |
getSessionForMediaPeriodId(Returns the session identifier for the given media period id. |
abstract void |
setListener(PlaybackSessionManager.Listener listener)Sets the listener to be notified of session updates. |
abstract void |
updateSessions(AnalyticsListener.EventTime eventTime)Updates or creates sessions based on a player |
abstract void |
updateSessionsWithDiscontinuity(Updates or creates sessions based on a position discontinuity at |
abstract void |
Updates or creates sessions based on a |
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 |
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, |
MediaSource.MediaPeriodId 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 |
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 |
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 |
@Player.DiscontinuityReason int reason |
The |
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 |