mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Set internal state before setting up cast dependencies
Prevents access of fields before initialization. Also set remoteMediaClient in the constructor by using setRemoteMediaClient instead of assigning the field directly, which will (if possible) pull the state of the receiver in the constructor. PiperOrigin-RevId: 276660004
This commit is contained in:
parent
bcf46431dd
commit
fc12457c7e
1 changed files with 5 additions and 5 deletions
|
|
@ -125,11 +125,6 @@ public final class CastPlayer extends BasePlayer {
|
|||
notificationsBatch = new ArrayList<>();
|
||||
ongoingNotificationsTasks = new ArrayDeque<>();
|
||||
|
||||
SessionManager sessionManager = castContext.getSessionManager();
|
||||
sessionManager.addSessionManagerListener(statusListener, CastSession.class);
|
||||
CastSession session = sessionManager.getCurrentCastSession();
|
||||
remoteMediaClient = session != null ? session.getRemoteMediaClient() : null;
|
||||
|
||||
playWhenReady = new StateHolder<>(false);
|
||||
repeatMode = new StateHolder<>(REPEAT_MODE_OFF);
|
||||
playbackState = STATE_IDLE;
|
||||
|
|
@ -138,6 +133,11 @@ public final class CastPlayer extends BasePlayer {
|
|||
currentTrackSelection = EMPTY_TRACK_SELECTION_ARRAY;
|
||||
pendingSeekWindowIndex = C.INDEX_UNSET;
|
||||
pendingSeekPositionMs = C.TIME_UNSET;
|
||||
|
||||
SessionManager sessionManager = castContext.getSessionManager();
|
||||
sessionManager.addSessionManagerListener(statusListener, CastSession.class);
|
||||
CastSession session = sessionManager.getCurrentCastSession();
|
||||
setRemoteMediaClient(session != null ? session.getRemoteMediaClient() : null);
|
||||
updateInternalStateAndNotifyIfChanged();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue