Commit b8b6ddf3 by tonihei Committed by christosts

Correctly filter PlayerInfo by available getter commands.

When bundling PlayerInfo, we need to remove information if the
controller is not allowed to access it. This was only partially
done at the moment.

PiperOrigin-RevId: 502852798
(cherry picked from commit 69cfba7c)
parent 0606ab0c
...@@ -286,16 +286,31 @@ public interface Player { ...@@ -286,16 +286,31 @@ public interface Player {
@UnstableApi @UnstableApi
@Override @Override
public Bundle toBundle() { public Bundle toBundle() {
return toBundle(/* canAccessCurrentMediaItem= */ true, /* canAccessTimeline= */ true);
}
/**
* Returns a {@link Bundle} representing the information stored in this object, filtered by
* available commands.
*
* @param canAccessCurrentMediaItem Whether the {@link Bundle} should contain information
* accessbile with {@link #COMMAND_GET_CURRENT_MEDIA_ITEM}.
* @param canAccessTimeline Whether the {@link Bundle} should contain information accessbile
* with {@link #COMMAND_GET_TIMELINE}.
*/
@UnstableApi
public Bundle toBundle(boolean canAccessCurrentMediaItem, boolean canAccessTimeline) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putInt(FIELD_MEDIA_ITEM_INDEX, mediaItemIndex); bundle.putInt(FIELD_MEDIA_ITEM_INDEX, canAccessTimeline ? mediaItemIndex : 0);
if (mediaItem != null) { if (mediaItem != null && canAccessCurrentMediaItem) {
bundle.putBundle(FIELD_MEDIA_ITEM, mediaItem.toBundle()); bundle.putBundle(FIELD_MEDIA_ITEM, mediaItem.toBundle());
} }
bundle.putInt(FIELD_PERIOD_INDEX, periodIndex); bundle.putInt(FIELD_PERIOD_INDEX, canAccessTimeline ? periodIndex : 0);
bundle.putLong(FIELD_POSITION_MS, positionMs); bundle.putLong(FIELD_POSITION_MS, canAccessCurrentMediaItem ? positionMs : 0);
bundle.putLong(FIELD_CONTENT_POSITION_MS, contentPositionMs); bundle.putLong(FIELD_CONTENT_POSITION_MS, canAccessCurrentMediaItem ? contentPositionMs : 0);
bundle.putInt(FIELD_AD_GROUP_INDEX, adGroupIndex); bundle.putInt(FIELD_AD_GROUP_INDEX, canAccessCurrentMediaItem ? adGroupIndex : C.INDEX_UNSET);
bundle.putInt(FIELD_AD_INDEX_IN_AD_GROUP, adIndexInAdGroup); bundle.putInt(
FIELD_AD_INDEX_IN_AD_GROUP, canAccessCurrentMediaItem ? adIndexInAdGroup : C.INDEX_UNSET);
return bundle; return bundle;
} }
...@@ -303,15 +318,14 @@ public interface Player { ...@@ -303,15 +318,14 @@ public interface Player {
@UnstableApi public static final Creator<PositionInfo> CREATOR = PositionInfo::fromBundle; @UnstableApi public static final Creator<PositionInfo> CREATOR = PositionInfo::fromBundle;
private static PositionInfo fromBundle(Bundle bundle) { private static PositionInfo fromBundle(Bundle bundle) {
int mediaItemIndex = bundle.getInt(FIELD_MEDIA_ITEM_INDEX, /* defaultValue= */ C.INDEX_UNSET); int mediaItemIndex = bundle.getInt(FIELD_MEDIA_ITEM_INDEX, /* defaultValue= */ 0);
@Nullable Bundle mediaItemBundle = bundle.getBundle(FIELD_MEDIA_ITEM); @Nullable Bundle mediaItemBundle = bundle.getBundle(FIELD_MEDIA_ITEM);
@Nullable @Nullable
MediaItem mediaItem = MediaItem mediaItem =
mediaItemBundle == null ? null : MediaItem.CREATOR.fromBundle(mediaItemBundle); mediaItemBundle == null ? null : MediaItem.CREATOR.fromBundle(mediaItemBundle);
int periodIndex = bundle.getInt(FIELD_PERIOD_INDEX, /* defaultValue= */ C.INDEX_UNSET); int periodIndex = bundle.getInt(FIELD_PERIOD_INDEX, /* defaultValue= */ 0);
long positionMs = bundle.getLong(FIELD_POSITION_MS, /* defaultValue= */ C.TIME_UNSET); long positionMs = bundle.getLong(FIELD_POSITION_MS, /* defaultValue= */ 0);
long contentPositionMs = long contentPositionMs = bundle.getLong(FIELD_CONTENT_POSITION_MS, /* defaultValue= */ 0);
bundle.getLong(FIELD_CONTENT_POSITION_MS, /* defaultValue= */ C.TIME_UNSET);
int adGroupIndex = bundle.getInt(FIELD_AD_GROUP_INDEX, /* defaultValue= */ C.INDEX_UNSET); int adGroupIndex = bundle.getInt(FIELD_AD_GROUP_INDEX, /* defaultValue= */ C.INDEX_UNSET);
int adIndexInAdGroup = int adIndexInAdGroup =
bundle.getInt(FIELD_AD_INDEX_IN_AD_GROUP, /* defaultValue= */ C.INDEX_UNSET); bundle.getInt(FIELD_AD_INDEX_IN_AD_GROUP, /* defaultValue= */ C.INDEX_UNSET);
...@@ -2281,6 +2295,9 @@ public interface Player { ...@@ -2281,6 +2295,9 @@ public interface Player {
* <p>Note: When the repeat mode is {@link #REPEAT_MODE_ONE}, this method behaves the same as when * <p>Note: When the repeat mode is {@link #REPEAT_MODE_ONE}, this method behaves the same as when
* the current repeat mode is {@link #REPEAT_MODE_OFF}. See {@link #REPEAT_MODE_ONE} for more * the current repeat mode is {@link #REPEAT_MODE_OFF}. See {@link #REPEAT_MODE_ONE} for more
* details. * details.
*
* <p>This method must only be called if {@link #COMMAND_GET_TIMELINE} is {@linkplain
* #getAvailableCommands() available}.
*/ */
boolean hasPreviousMediaItem(); boolean hasPreviousMediaItem();
...@@ -2367,6 +2384,9 @@ public interface Player { ...@@ -2367,6 +2384,9 @@ public interface Player {
* <p>Note: When the repeat mode is {@link #REPEAT_MODE_ONE}, this method behaves the same as when * <p>Note: When the repeat mode is {@link #REPEAT_MODE_ONE}, this method behaves the same as when
* the current repeat mode is {@link #REPEAT_MODE_OFF}. See {@link #REPEAT_MODE_ONE} for more * the current repeat mode is {@link #REPEAT_MODE_OFF}. See {@link #REPEAT_MODE_ONE} for more
* details. * details.
*
* <p>This method must only be called if {@link #COMMAND_GET_TIMELINE} is {@linkplain
* #getAvailableCommands() available}.
*/ */
boolean hasNextMediaItem(); boolean hasNextMediaItem();
......
...@@ -1162,7 +1162,11 @@ public class MediaSession { ...@@ -1162,7 +1162,11 @@ public class MediaSession {
throws RemoteException {} throws RemoteException {}
default void onPeriodicSessionPositionInfoChanged( default void onPeriodicSessionPositionInfoChanged(
int seq, SessionPositionInfo sessionPositionInfo) throws RemoteException {} int seq,
SessionPositionInfo sessionPositionInfo,
boolean canAccessCurrentMediaItem,
boolean canAccessTimeline)
throws RemoteException {}
// Mostly matched with MediaController.ControllerCallback // Mostly matched with MediaController.ControllerCallback
......
...@@ -601,6 +601,38 @@ import org.checkerframework.checker.initialization.qual.Initialized; ...@@ -601,6 +601,38 @@ import org.checkerframework.checker.initialization.qual.Initialized;
} }
} }
private void dispatchOnPeriodicSessionPositionInfoChanged(
SessionPositionInfo sessionPositionInfo) {
ConnectedControllersManager<IBinder> controllersManager =
sessionStub.getConnectedControllersManager();
List<ControllerInfo> controllers =
sessionStub.getConnectedControllersManager().getConnectedControllers();
for (int i = 0; i < controllers.size(); i++) {
ControllerInfo controller = controllers.get(i);
boolean canAccessCurrentMediaItem =
controllersManager.isPlayerCommandAvailable(
controller, Player.COMMAND_GET_CURRENT_MEDIA_ITEM);
boolean canAccessTimeline =
controllersManager.isPlayerCommandAvailable(controller, Player.COMMAND_GET_TIMELINE);
dispatchRemoteControllerTaskWithoutReturn(
controller,
(controllerCb, seq) ->
controllerCb.onPeriodicSessionPositionInfoChanged(
seq, sessionPositionInfo, canAccessCurrentMediaItem, canAccessTimeline));
}
try {
sessionLegacyStub
.getControllerLegacyCbForBroadcast()
.onPeriodicSessionPositionInfoChanged(
/* seq= */ 0,
sessionPositionInfo,
/* canAccessCurrentMediaItem= */ true,
/* canAccessTimeline= */ true);
} catch (RemoteException e) {
Log.e(TAG, "Exception in using media1 API", e);
}
}
protected void dispatchRemoteControllerTaskWithoutReturn(RemoteControllerTask task) { protected void dispatchRemoteControllerTaskWithoutReturn(RemoteControllerTask task) {
List<ControllerInfo> controllers = List<ControllerInfo> controllers =
sessionStub.getConnectedControllersManager().getConnectedControllers(); sessionStub.getConnectedControllersManager().getConnectedControllers();
...@@ -719,8 +751,7 @@ import org.checkerframework.checker.initialization.qual.Initialized; ...@@ -719,8 +751,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
} }
} }
SessionPositionInfo sessionPositionInfo = playerWrapper.createSessionPositionInfoForBundling(); SessionPositionInfo sessionPositionInfo = playerWrapper.createSessionPositionInfoForBundling();
dispatchRemoteControllerTaskWithoutReturn( dispatchOnPeriodicSessionPositionInfoChanged(sessionPositionInfo);
(callback, seq) -> callback.onPeriodicSessionPositionInfoChanged(seq, sessionPositionInfo));
schedulePeriodicSessionPositionInfoChanges(); schedulePeriodicSessionPositionInfoChanges();
} }
......
...@@ -1175,7 +1175,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ...@@ -1175,7 +1175,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Override @Override
public void onPeriodicSessionPositionInfoChanged( public void onPeriodicSessionPositionInfoChanged(
int unusedSeq, SessionPositionInfo unusedSessionPositionInfo) throws RemoteException { int unusedSeq,
SessionPositionInfo unusedSessionPositionInfo,
boolean unusedCanAccessCurrentMediaItem,
boolean unusedCanAccessTimeline)
throws RemoteException {
sessionImpl sessionImpl
.getSessionCompat() .getSessionCompat()
.setPlaybackState(sessionImpl.getPlayerWrapper().createPlaybackStateCompat()); .setPlaybackState(sessionImpl.getPlayerWrapper().createPlaybackStateCompat());
......
...@@ -1684,9 +1684,14 @@ import java.util.concurrent.ExecutionException; ...@@ -1684,9 +1684,14 @@ import java.util.concurrent.ExecutionException;
@Override @Override
public void onPeriodicSessionPositionInfoChanged( public void onPeriodicSessionPositionInfoChanged(
int sequenceNumber, SessionPositionInfo sessionPositionInfo) throws RemoteException { int sequenceNumber,
SessionPositionInfo sessionPositionInfo,
boolean canAccessCurrentMediaItem,
boolean canAccessTimeline)
throws RemoteException {
iController.onPeriodicSessionPositionInfoChanged( iController.onPeriodicSessionPositionInfoChanged(
sequenceNumber, sessionPositionInfo.toBundle()); sequenceNumber,
sessionPositionInfo.toBundle(canAccessCurrentMediaItem, canAccessTimeline));
} }
@Override @Override
......
...@@ -801,38 +801,53 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; ...@@ -801,38 +801,53 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
public Bundle toBundle( public Bundle toBundle(
Player.Commands availableCommands, boolean excludeTimeline, boolean excludeTracks) { Player.Commands availableCommands, boolean excludeTimeline, boolean excludeTracks) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
boolean canAccessCurrentMediaItem =
availableCommands.contains(Player.COMMAND_GET_CURRENT_MEDIA_ITEM);
boolean canAccessTimeline = availableCommands.contains(Player.COMMAND_GET_TIMELINE);
if (playerError != null) { if (playerError != null) {
bundle.putBundle(FIELD_PLAYBACK_ERROR, playerError.toBundle()); bundle.putBundle(FIELD_PLAYBACK_ERROR, playerError.toBundle());
} }
bundle.putInt(FIELD_MEDIA_ITEM_TRANSITION_REASON, mediaItemTransitionReason); bundle.putInt(FIELD_MEDIA_ITEM_TRANSITION_REASON, mediaItemTransitionReason);
bundle.putBundle(FIELD_SESSION_POSITION_INFO, sessionPositionInfo.toBundle()); bundle.putBundle(
bundle.putBundle(FIELD_OLD_POSITION_INFO, oldPositionInfo.toBundle()); FIELD_SESSION_POSITION_INFO,
bundle.putBundle(FIELD_NEW_POSITION_INFO, newPositionInfo.toBundle()); sessionPositionInfo.toBundle(canAccessCurrentMediaItem, canAccessTimeline));
bundle.putBundle(
FIELD_OLD_POSITION_INFO,
oldPositionInfo.toBundle(canAccessCurrentMediaItem, canAccessTimeline));
bundle.putBundle(
FIELD_NEW_POSITION_INFO,
newPositionInfo.toBundle(canAccessCurrentMediaItem, canAccessTimeline));
bundle.putInt(FIELD_DISCONTINUITY_REASON, discontinuityReason); bundle.putInt(FIELD_DISCONTINUITY_REASON, discontinuityReason);
bundle.putBundle(FIELD_PLAYBACK_PARAMETERS, playbackParameters.toBundle()); bundle.putBundle(FIELD_PLAYBACK_PARAMETERS, playbackParameters.toBundle());
bundle.putInt(FIELD_REPEAT_MODE, repeatMode); bundle.putInt(FIELD_REPEAT_MODE, repeatMode);
bundle.putBoolean(FIELD_SHUFFLE_MODE_ENABLED, shuffleModeEnabled); bundle.putBoolean(FIELD_SHUFFLE_MODE_ENABLED, shuffleModeEnabled);
if (!excludeTimeline && availableCommands.contains(Player.COMMAND_GET_TIMELINE)) { if (!excludeTimeline && canAccessTimeline) {
bundle.putBundle(FIELD_TIMELINE, timeline.toBundle()); bundle.putBundle(FIELD_TIMELINE, timeline.toBundle());
} }
bundle.putBundle(FIELD_VIDEO_SIZE, videoSize.toBundle()); bundle.putBundle(FIELD_VIDEO_SIZE, videoSize.toBundle());
if (availableCommands.contains(Player.COMMAND_GET_MEDIA_ITEMS_METADATA)) { if (availableCommands.contains(Player.COMMAND_GET_MEDIA_ITEMS_METADATA)) {
bundle.putBundle(FIELD_PLAYLIST_METADATA, playlistMetadata.toBundle()); bundle.putBundle(FIELD_PLAYLIST_METADATA, playlistMetadata.toBundle());
} }
if (availableCommands.contains(Player.COMMAND_GET_VOLUME)) {
bundle.putFloat(FIELD_VOLUME, volume); bundle.putFloat(FIELD_VOLUME, volume);
}
if (availableCommands.contains(Player.COMMAND_GET_AUDIO_ATTRIBUTES)) {
bundle.putBundle(FIELD_AUDIO_ATTRIBUTES, audioAttributes.toBundle()); bundle.putBundle(FIELD_AUDIO_ATTRIBUTES, audioAttributes.toBundle());
}
if (availableCommands.contains(Player.COMMAND_GET_TEXT)) { if (availableCommands.contains(Player.COMMAND_GET_TEXT)) {
bundle.putBundle(FIELD_CUE_GROUP, cueGroup.toBundle()); bundle.putBundle(FIELD_CUE_GROUP, cueGroup.toBundle());
} }
bundle.putBundle(FIELD_DEVICE_INFO, deviceInfo.toBundle()); bundle.putBundle(FIELD_DEVICE_INFO, deviceInfo.toBundle());
if (availableCommands.contains(Player.COMMAND_GET_DEVICE_VOLUME)) {
bundle.putInt(FIELD_DEVICE_VOLUME, deviceVolume); bundle.putInt(FIELD_DEVICE_VOLUME, deviceVolume);
bundle.putBoolean(FIELD_DEVICE_MUTED, deviceMuted); bundle.putBoolean(FIELD_DEVICE_MUTED, deviceMuted);
}
bundle.putBoolean(FIELD_PLAY_WHEN_READY, playWhenReady); bundle.putBoolean(FIELD_PLAY_WHEN_READY, playWhenReady);
bundle.putInt(FIELD_PLAYBACK_SUPPRESSION_REASON, playbackSuppressionReason); bundle.putInt(FIELD_PLAYBACK_SUPPRESSION_REASON, playbackSuppressionReason);
bundle.putInt(FIELD_PLAYBACK_STATE, playbackState); bundle.putInt(FIELD_PLAYBACK_STATE, playbackState);
bundle.putBoolean(FIELD_IS_PLAYING, isPlaying); bundle.putBoolean(FIELD_IS_PLAYING, isPlaying);
bundle.putBoolean(FIELD_IS_LOADING, isLoading); bundle.putBoolean(FIELD_IS_LOADING, isLoading);
if (availableCommands.contains(Player.COMMAND_GET_TIMELINE)) { if (availableCommands.contains(Player.COMMAND_GET_MEDIA_ITEMS_METADATA)) {
bundle.putBundle(FIELD_MEDIA_METADATA, mediaMetadata.toBundle()); bundle.putBundle(FIELD_MEDIA_METADATA, mediaMetadata.toBundle());
} }
bundle.putLong(FIELD_SEEK_BACK_INCREMENT_MS, seekBackIncrementMs); bundle.putLong(FIELD_SEEK_BACK_INCREMENT_MS, seekBackIncrementMs);
...@@ -842,7 +857,6 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; ...@@ -842,7 +857,6 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
bundle.putBundle(FIELD_CURRENT_TRACKS, currentTracks.toBundle()); bundle.putBundle(FIELD_CURRENT_TRACKS, currentTracks.toBundle());
} }
bundle.putBundle(FIELD_TRACK_SELECTION_PARAMETERS, trackSelectionParameters.toBundle()); bundle.putBundle(FIELD_TRACK_SELECTION_PARAMETERS, trackSelectionParameters.toBundle());
return bundle; return bundle;
} }
......
...@@ -1031,19 +1031,18 @@ import java.util.List; ...@@ -1031,19 +1031,18 @@ import java.util.List;
* <p>This excludes window uid and period uid that wouldn't be preserved when bundling. * <p>This excludes window uid and period uid that wouldn't be preserved when bundling.
*/ */
public PositionInfo createPositionInfoForBundling() { public PositionInfo createPositionInfoForBundling() {
if (!isCommandAvailable(COMMAND_GET_CURRENT_MEDIA_ITEM)) { boolean canAccessCurrentMediaItem = isCommandAvailable(COMMAND_GET_CURRENT_MEDIA_ITEM);
return SessionPositionInfo.DEFAULT_POSITION_INFO; boolean canAccessTimeline = isCommandAvailable(COMMAND_GET_TIMELINE);
}
return new PositionInfo( return new PositionInfo(
/* windowUid= */ null, /* windowUid= */ null,
getCurrentMediaItemIndex(), canAccessTimeline ? getCurrentMediaItemIndex() : 0,
getCurrentMediaItem(), canAccessCurrentMediaItem ? getCurrentMediaItem() : null,
/* periodUid= */ null, /* periodUid= */ null,
getCurrentPeriodIndex(), canAccessTimeline ? getCurrentPeriodIndex() : 0,
getCurrentPosition(), canAccessCurrentMediaItem ? getCurrentPosition() : 0,
getContentPosition(), canAccessCurrentMediaItem ? getContentPosition() : 0,
getCurrentAdGroupIndex(), canAccessCurrentMediaItem ? getCurrentAdGroupIndex() : C.INDEX_UNSET,
getCurrentAdIndexInAdGroup()); canAccessCurrentMediaItem ? getCurrentAdIndexInAdGroup() : C.INDEX_UNSET);
} }
/** /**
...@@ -1052,20 +1051,18 @@ import java.util.List; ...@@ -1052,20 +1051,18 @@ import java.util.List;
* <p>This excludes window uid and period uid that wouldn't be preserved when bundling. * <p>This excludes window uid and period uid that wouldn't be preserved when bundling.
*/ */
public SessionPositionInfo createSessionPositionInfoForBundling() { public SessionPositionInfo createSessionPositionInfoForBundling() {
if (!isCommandAvailable(COMMAND_GET_CURRENT_MEDIA_ITEM)) { boolean canAccessCurrentMediaItem = isCommandAvailable(COMMAND_GET_CURRENT_MEDIA_ITEM);
return SessionPositionInfo.DEFAULT;
}
return new SessionPositionInfo( return new SessionPositionInfo(
createPositionInfoForBundling(), createPositionInfoForBundling(),
isPlayingAd(), canAccessCurrentMediaItem && isPlayingAd(),
/* eventTimeMs= */ SystemClock.elapsedRealtime(), /* eventTimeMs= */ SystemClock.elapsedRealtime(),
getDuration(), canAccessCurrentMediaItem ? getDuration() : C.TIME_UNSET,
getBufferedPosition(), canAccessCurrentMediaItem ? getBufferedPosition() : 0,
getBufferedPercentage(), canAccessCurrentMediaItem ? getBufferedPercentage() : 0,
getTotalBufferedDuration(), canAccessCurrentMediaItem ? getTotalBufferedDuration() : 0,
getCurrentLiveOffset(), canAccessCurrentMediaItem ? getCurrentLiveOffset() : C.TIME_UNSET,
getContentDuration(), canAccessCurrentMediaItem ? getContentDuration() : C.TIME_UNSET,
getContentBufferedPosition()); canAccessCurrentMediaItem ? getContentBufferedPosition() : 0);
} }
public PlayerInfo createPlayerInfoForBundling() { public PlayerInfo createPlayerInfoForBundling() {
......
...@@ -170,17 +170,28 @@ import com.google.common.base.Objects; ...@@ -170,17 +170,28 @@ import com.google.common.base.Objects;
@Override @Override
public Bundle toBundle() { public Bundle toBundle() {
return toBundle(/* canAccessCurrentMediaItem= */ true, /* canAccessTimeline= */ true);
}
public Bundle toBundle(boolean canAccessCurrentMediaItem, boolean canAccessTimeline) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putBundle(FIELD_POSITION_INFO, positionInfo.toBundle()); bundle.putBundle(
bundle.putBoolean(FIELD_IS_PLAYING_AD, isPlayingAd); FIELD_POSITION_INFO, positionInfo.toBundle(canAccessCurrentMediaItem, canAccessTimeline));
bundle.putBoolean(FIELD_IS_PLAYING_AD, canAccessCurrentMediaItem && isPlayingAd);
bundle.putLong(FIELD_EVENT_TIME_MS, eventTimeMs); bundle.putLong(FIELD_EVENT_TIME_MS, eventTimeMs);
bundle.putLong(FIELD_DURATION_MS, durationMs); bundle.putLong(FIELD_DURATION_MS, canAccessCurrentMediaItem ? durationMs : C.TIME_UNSET);
bundle.putLong(FIELD_BUFFERED_POSITION_MS, bufferedPositionMs); bundle.putLong(FIELD_BUFFERED_POSITION_MS, canAccessCurrentMediaItem ? bufferedPositionMs : 0);
bundle.putInt(FIELD_BUFFERED_PERCENTAGE, bufferedPercentage); bundle.putInt(FIELD_BUFFERED_PERCENTAGE, canAccessCurrentMediaItem ? bufferedPercentage : 0);
bundle.putLong(FIELD_TOTAL_BUFFERED_DURATION_MS, totalBufferedDurationMs); bundle.putLong(
bundle.putLong(FIELD_CURRENT_LIVE_OFFSET_MS, currentLiveOffsetMs); FIELD_TOTAL_BUFFERED_DURATION_MS, canAccessCurrentMediaItem ? totalBufferedDurationMs : 0);
bundle.putLong(FIELD_CONTENT_DURATION_MS, contentDurationMs); bundle.putLong(
bundle.putLong(FIELD_CONTENT_BUFFERED_POSITION_MS, contentBufferedPositionMs); FIELD_CURRENT_LIVE_OFFSET_MS,
canAccessCurrentMediaItem ? currentLiveOffsetMs : C.TIME_UNSET);
bundle.putLong(
FIELD_CONTENT_DURATION_MS, canAccessCurrentMediaItem ? contentDurationMs : C.TIME_UNSET);
bundle.putLong(
FIELD_CONTENT_BUFFERED_POSITION_MS,
canAccessCurrentMediaItem ? contentBufferedPositionMs : 0);
return bundle; return bundle;
} }
...@@ -196,8 +207,7 @@ import com.google.common.base.Objects; ...@@ -196,8 +207,7 @@ import com.google.common.base.Objects;
boolean isPlayingAd = bundle.getBoolean(FIELD_IS_PLAYING_AD, /* defaultValue= */ false); boolean isPlayingAd = bundle.getBoolean(FIELD_IS_PLAYING_AD, /* defaultValue= */ false);
long eventTimeMs = bundle.getLong(FIELD_EVENT_TIME_MS, /* defaultValue= */ C.TIME_UNSET); long eventTimeMs = bundle.getLong(FIELD_EVENT_TIME_MS, /* defaultValue= */ C.TIME_UNSET);
long durationMs = bundle.getLong(FIELD_DURATION_MS, /* defaultValue= */ C.TIME_UNSET); long durationMs = bundle.getLong(FIELD_DURATION_MS, /* defaultValue= */ C.TIME_UNSET);
long bufferedPositionMs = long bufferedPositionMs = bundle.getLong(FIELD_BUFFERED_POSITION_MS, /* defaultValue= */ 0);
bundle.getLong(FIELD_BUFFERED_POSITION_MS, /* defaultValue= */ C.TIME_UNSET);
int bufferedPercentage = bundle.getInt(FIELD_BUFFERED_PERCENTAGE, /* defaultValue= */ 0); int bufferedPercentage = bundle.getInt(FIELD_BUFFERED_PERCENTAGE, /* defaultValue= */ 0);
long totalBufferedDurationMs = long totalBufferedDurationMs =
bundle.getLong(FIELD_TOTAL_BUFFERED_DURATION_MS, /* defaultValue= */ 0); bundle.getLong(FIELD_TOTAL_BUFFERED_DURATION_MS, /* defaultValue= */ 0);
...@@ -206,7 +216,7 @@ import com.google.common.base.Objects; ...@@ -206,7 +216,7 @@ import com.google.common.base.Objects;
long contentDurationMs = long contentDurationMs =
bundle.getLong(FIELD_CONTENT_DURATION_MS, /* defaultValue= */ C.TIME_UNSET); bundle.getLong(FIELD_CONTENT_DURATION_MS, /* defaultValue= */ C.TIME_UNSET);
long contentBufferedPositionMs = long contentBufferedPositionMs =
bundle.getLong(FIELD_CONTENT_BUFFERED_POSITION_MS, /* defaultValue= */ C.TIME_UNSET); bundle.getLong(FIELD_CONTENT_BUFFERED_POSITION_MS, /* defaultValue= */ 0);
return new SessionPositionInfo( return new SessionPositionInfo(
positionInfo, positionInfo,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment