Interface PlaybackSessionManager
-
- All Known Implementing Classes:
DefaultPlaybackSessionManager
public interface PlaybackSessionManagerManager for active playback sessions.The manager keeps track of the association between window index and/or media period id to session identifier.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfacePlaybackSessionManager.ListenerA listener for session updates.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanbelongsToSession(AnalyticsListener.EventTime eventTime, String sessionId)Returns whether an event time belong to a session.voidfinishAllSessions(AnalyticsListener.EventTime eventTime)Finishes all existing sessions and calls their respectivePlaybackSessionManager.Listener.onSessionFinished(EventTime, String, boolean)callback.StringgetActiveSessionId()Returns the session identifier of the session that is currently actively playing, ornullif there no such session.StringgetSessionForMediaPeriodId(Timeline timeline, MediaSource.MediaPeriodId mediaPeriodId)Returns the session identifier for the given media period id.voidsetListener(PlaybackSessionManager.Listener listener)Sets the listener to be notified of session updates.voidupdateSessions(AnalyticsListener.EventTime eventTime)Updates or creates sessions based on a playerAnalyticsListener.EventTime.voidupdateSessionsWithDiscontinuity(AnalyticsListener.EventTime eventTime, @com.google.android.exoplayer2.Player.DiscontinuityReason int reason)Updates or creates sessions based on a position discontinuity atAnalyticsListener.EventTime.voidupdateSessionsWithTimelineChange(AnalyticsListener.EventTime eventTime)Updates or creates sessions based on aTimelinechange atAnalyticsListener.EventTime.
-
-
-
Method Detail
-
setListener
void setListener(PlaybackSessionManager.Listener listener)
Sets the listener to be notified of session updates. Must be called before the session manager is used.- Parameters:
listener- ThePlaybackSessionManager.Listenerto be notified of session updates.
-
getSessionForMediaPeriodId
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
PlaybackSessionManager.Listenercallbacks.- Parameters:
timeline- The timeline,mediaPeriodIdis part of.mediaPeriodId- AMediaSource.MediaPeriodId.
-
belongsToSession
boolean belongsToSession(AnalyticsListener.EventTime eventTime, String sessionId)
Returns whether an event time belong to a session.- Parameters:
eventTime- TheAnalyticsListener.EventTime.sessionId- A session identifier.- Returns:
- Whether the event belongs to the specified session.
-
updateSessions
void updateSessions(AnalyticsListener.EventTime eventTime)
Updates or creates sessions based on a playerAnalyticsListener.EventTime.Call
updateSessionsWithTimelineChange(EventTime)orupdateSessionsWithDiscontinuity(EventTime, int)if the event is aTimelinechange or a position discontinuity respectively.- Parameters:
eventTime- TheAnalyticsListener.EventTime.
-
updateSessionsWithTimelineChange
void updateSessionsWithTimelineChange(AnalyticsListener.EventTime eventTime)
Updates or creates sessions based on aTimelinechange atAnalyticsListener.EventTime.Should be called instead of
updateSessions(EventTime)if aTimelinechange occurred.- Parameters:
eventTime- TheAnalyticsListener.EventTimewith the timeline change.
-
updateSessionsWithDiscontinuity
void updateSessionsWithDiscontinuity(AnalyticsListener.EventTime eventTime, @DiscontinuityReason @com.google.android.exoplayer2.Player.DiscontinuityReason int reason)
Updates or creates sessions based on a position discontinuity atAnalyticsListener.EventTime.Should be called instead of
updateSessions(EventTime)if a position discontinuity occurred.- Parameters:
eventTime- TheAnalyticsListener.EventTimeof the position discontinuity.reason- ThePlayer.DiscontinuityReason.
-
getActiveSessionId
@Nullable String getActiveSessionId()
Returns the session identifier of the session that is currently actively playing, ornullif there no such session.
-
finishAllSessions
void finishAllSessions(AnalyticsListener.EventTime eventTime)
Finishes all existing sessions and calls their respectivePlaybackSessionManager.Listener.onSessionFinished(EventTime, String, boolean)callback.- Parameters:
eventTime- The event time at which sessions are finished.
-
-