Define CueGroup.EMPTY_TIME_ZERO for convenience
We create an empty CueGroup in many places as default or where none is needed. Instead, we can define a constant for this purpose and reuse it. PiperOrigin-RevId: 467944841
This commit is contained in:
parent
d963dfbd3e
commit
59895646e0
@ -113,8 +113,6 @@ public final class CastPlayer extends BasePlayer {
|
|||||||
|
|
||||||
private static final long PROGRESS_REPORT_PERIOD_MS = 1000;
|
private static final long PROGRESS_REPORT_PERIOD_MS = 1000;
|
||||||
private static final long[] EMPTY_TRACK_ID_ARRAY = new long[0];
|
private static final long[] EMPTY_TRACK_ID_ARRAY = new long[0];
|
||||||
private static final CueGroup EMPTY_CUE_GROUP =
|
|
||||||
new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0);
|
|
||||||
|
|
||||||
private final CastContext castContext;
|
private final CastContext castContext;
|
||||||
private final MediaItemConverter mediaItemConverter;
|
private final MediaItemConverter mediaItemConverter;
|
||||||
@ -728,7 +726,7 @@ public final class CastPlayer extends BasePlayer {
|
|||||||
/** This method is not supported and returns an empty {@link CueGroup}. */
|
/** This method is not supported and returns an empty {@link CueGroup}. */
|
||||||
@Override
|
@Override
|
||||||
public CueGroup getCurrentCues() {
|
public CueGroup getCurrentCues() {
|
||||||
return EMPTY_CUE_GROUP;
|
return CueGroup.EMPTY_TIME_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is not supported and always returns {@link DeviceInfo#UNKNOWN}. */
|
/** This method is not supported and always returns {@link DeviceInfo#UNKNOWN}. */
|
||||||
|
@ -35,6 +35,12 @@ import java.util.List;
|
|||||||
|
|
||||||
/** Class to represent the state of active {@link Cue Cues} at a particular time. */
|
/** Class to represent the state of active {@link Cue Cues} at a particular time. */
|
||||||
public final class CueGroup implements Bundleable {
|
public final class CueGroup implements Bundleable {
|
||||||
|
|
||||||
|
/** An empty group with no {@link Cue Cues} and presentation time of zero. */
|
||||||
|
@UnstableApi
|
||||||
|
public static final CueGroup EMPTY_TIME_ZERO =
|
||||||
|
new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cues in this group.
|
* The cues in this group.
|
||||||
*
|
*
|
||||||
|
@ -356,7 +356,7 @@ import java.util.concurrent.TimeoutException;
|
|||||||
} else {
|
} else {
|
||||||
audioSessionId = Util.generateAudioSessionIdV21(applicationContext);
|
audioSessionId = Util.generateAudioSessionIdV21(applicationContext);
|
||||||
}
|
}
|
||||||
currentCueGroup = new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0);
|
currentCueGroup = CueGroup.EMPTY_TIME_ZERO;
|
||||||
throwsWhenUsingWrongThread = true;
|
throwsWhenUsingWrongThread = true;
|
||||||
|
|
||||||
addListener(analyticsCollector);
|
addListener(analyticsCollector);
|
||||||
@ -1001,7 +1001,7 @@ import java.util.concurrent.TimeoutException;
|
|||||||
checkNotNull(priorityTaskManager).remove(C.PRIORITY_PLAYBACK);
|
checkNotNull(priorityTaskManager).remove(C.PRIORITY_PLAYBACK);
|
||||||
isPriorityTaskManagerRegistered = false;
|
isPriorityTaskManagerRegistered = false;
|
||||||
}
|
}
|
||||||
currentCueGroup = new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0);
|
currentCueGroup = CueGroup.EMPTY_TIME_ZERO;
|
||||||
playerReleased = true;
|
playerReleased = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ import androidx.media3.common.util.Consumer;
|
|||||||
import androidx.media3.common.util.Log;
|
import androidx.media3.common.util.Log;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.common.util.Util;
|
import androidx.media3.common.util.Util;
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
@ -175,9 +174,6 @@ public class MediaController implements Player {
|
|||||||
"MediaController method is called from a wrong thread."
|
"MediaController method is called from a wrong thread."
|
||||||
+ " See javadoc of MediaController for details.";
|
+ " See javadoc of MediaController for details.";
|
||||||
|
|
||||||
private static final CueGroup EMPTY_CUE_GROUP =
|
|
||||||
new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0);
|
|
||||||
|
|
||||||
/** A builder for {@link MediaController}. */
|
/** A builder for {@link MediaController}. */
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
|
|
||||||
@ -1595,7 +1591,7 @@ public class MediaController implements Player {
|
|||||||
@Override
|
@Override
|
||||||
public CueGroup getCurrentCues() {
|
public CueGroup getCurrentCues() {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
return isConnected() ? impl.getCurrentCues() : EMPTY_CUE_GROUP;
|
return isConnected() ? impl.getCurrentCues() : CueGroup.EMPTY_TIME_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,8 +108,6 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
|
|
||||||
private static final long AGGREGATES_CALLBACKS_WITHIN_TIMEOUT_MS = 500L;
|
private static final long AGGREGATES_CALLBACKS_WITHIN_TIMEOUT_MS = 500L;
|
||||||
private static final int VOLUME_FLAGS = AudioManager.FLAG_SHOW_UI;
|
private static final int VOLUME_FLAGS = AudioManager.FLAG_SHOW_UI;
|
||||||
private static final CueGroup EMPTY_CUE_GROUP =
|
|
||||||
new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0);
|
|
||||||
|
|
||||||
/* package */ final Context context;
|
/* package */ final Context context;
|
||||||
private final MediaController instance;
|
private final MediaController instance;
|
||||||
@ -1029,7 +1027,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
@Override
|
@Override
|
||||||
public CueGroup getCurrentCues() {
|
public CueGroup getCurrentCues() {
|
||||||
Log.w(TAG, "Session doesn't support getting Cue");
|
Log.w(TAG, "Session doesn't support getting Cue");
|
||||||
return EMPTY_CUE_GROUP;
|
return CueGroup.EMPTY_TIME_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2122,7 +2120,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
/* playlistMetadata= */ playlistMetadata,
|
/* playlistMetadata= */ playlistMetadata,
|
||||||
/* volume= */ 1.0f,
|
/* volume= */ 1.0f,
|
||||||
/* audioAttributes= */ audioAttributes,
|
/* audioAttributes= */ audioAttributes,
|
||||||
/* cueGroup= */ EMPTY_CUE_GROUP,
|
/* cueGroup= */ CueGroup.EMPTY_TIME_ZERO,
|
||||||
/* deviceInfo= */ deviceInfo,
|
/* deviceInfo= */ deviceInfo,
|
||||||
/* deviceVolume= */ deviceVolume,
|
/* deviceVolume= */ deviceVolume,
|
||||||
/* deviceMuted= */ deviceMuted,
|
/* deviceMuted= */ deviceMuted,
|
||||||
|
@ -46,7 +46,6 @@ import androidx.media3.common.Tracks;
|
|||||||
import androidx.media3.common.VideoSize;
|
import androidx.media3.common.VideoSize;
|
||||||
import androidx.media3.common.text.CueGroup;
|
import androidx.media3.common.text.CueGroup;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@ -59,9 +58,6 @@ import java.lang.annotation.Target;
|
|||||||
*/
|
*/
|
||||||
/* package */ class PlayerInfo implements Bundleable {
|
/* package */ class PlayerInfo implements Bundleable {
|
||||||
|
|
||||||
private static final CueGroup EMPTY_CUE_GROUP =
|
|
||||||
new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0);
|
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
@Nullable private PlaybackException playerError;
|
@Nullable private PlaybackException playerError;
|
||||||
@ -376,7 +372,7 @@ import java.lang.annotation.Target;
|
|||||||
MediaMetadata.EMPTY,
|
MediaMetadata.EMPTY,
|
||||||
/* volume= */ 1f,
|
/* volume= */ 1f,
|
||||||
AudioAttributes.DEFAULT,
|
AudioAttributes.DEFAULT,
|
||||||
/* cueGroup = */ EMPTY_CUE_GROUP,
|
CueGroup.EMPTY_TIME_ZERO,
|
||||||
DeviceInfo.UNKNOWN,
|
DeviceInfo.UNKNOWN,
|
||||||
/* deviceVolume= */ 0,
|
/* deviceVolume= */ 0,
|
||||||
/* deviceMuted= */ false,
|
/* deviceMuted= */ false,
|
||||||
@ -906,7 +902,9 @@ import java.lang.annotation.Target;
|
|||||||
: AudioAttributes.CREATOR.fromBundle(audioAttributesBundle);
|
: AudioAttributes.CREATOR.fromBundle(audioAttributesBundle);
|
||||||
@Nullable Bundle cueGroupBundle = bundle.getBundle(keyForField(FIELD_CUE_GROUP));
|
@Nullable Bundle cueGroupBundle = bundle.getBundle(keyForField(FIELD_CUE_GROUP));
|
||||||
CueGroup cueGroup =
|
CueGroup cueGroup =
|
||||||
cueGroupBundle == null ? EMPTY_CUE_GROUP : CueGroup.CREATOR.fromBundle(cueGroupBundle);
|
cueGroupBundle == null
|
||||||
|
? CueGroup.EMPTY_TIME_ZERO
|
||||||
|
: CueGroup.CREATOR.fromBundle(cueGroupBundle);
|
||||||
@Nullable Bundle deviceInfoBundle = bundle.getBundle(keyForField(FIELD_DEVICE_INFO));
|
@Nullable Bundle deviceInfoBundle = bundle.getBundle(keyForField(FIELD_DEVICE_INFO));
|
||||||
DeviceInfo deviceInfo =
|
DeviceInfo deviceInfo =
|
||||||
deviceInfoBundle == null
|
deviceInfoBundle == null
|
||||||
|
@ -112,8 +112,6 @@ import java.util.concurrent.Callable;
|
|||||||
public class MediaSessionProviderService extends Service {
|
public class MediaSessionProviderService extends Service {
|
||||||
|
|
||||||
private static final String TAG = "MSProviderService";
|
private static final String TAG = "MSProviderService";
|
||||||
private static final CueGroup EMPTY_CUE_GROUP =
|
|
||||||
new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0);
|
|
||||||
|
|
||||||
private Map<String, MediaSession> sessionMap = new HashMap<>();
|
private Map<String, MediaSession> sessionMap = new HashMap<>();
|
||||||
private RemoteMediaSessionStub sessionBinder;
|
private RemoteMediaSessionStub sessionBinder;
|
||||||
@ -363,7 +361,9 @@ public class MediaSessionProviderService extends Service {
|
|||||||
}
|
}
|
||||||
Bundle cueGroupBundle = config.getBundle(KEY_CURRENT_CUE_GROUP);
|
Bundle cueGroupBundle = config.getBundle(KEY_CURRENT_CUE_GROUP);
|
||||||
player.cueGroup =
|
player.cueGroup =
|
||||||
cueGroupBundle == null ? EMPTY_CUE_GROUP : CueGroup.CREATOR.fromBundle(cueGroupBundle);
|
cueGroupBundle == null
|
||||||
|
? CueGroup.EMPTY_TIME_ZERO
|
||||||
|
: CueGroup.CREATOR.fromBundle(cueGroupBundle);
|
||||||
@Nullable Bundle deviceInfoBundle = config.getBundle(KEY_DEVICE_INFO);
|
@Nullable Bundle deviceInfoBundle = config.getBundle(KEY_DEVICE_INFO);
|
||||||
if (deviceInfoBundle != null) {
|
if (deviceInfoBundle != null) {
|
||||||
player.deviceInfo = DeviceInfo.CREATOR.fromBundle(deviceInfoBundle);
|
player.deviceInfo = DeviceInfo.CREATOR.fromBundle(deviceInfoBundle);
|
||||||
|
@ -197,8 +197,6 @@ public class MockPlayer implements Player {
|
|||||||
private final ArraySet<Listener> listeners = new ArraySet<>();
|
private final ArraySet<Listener> listeners = new ArraySet<>();
|
||||||
private final ImmutableMap<@Method Integer, ConditionVariable> conditionVariables =
|
private final ImmutableMap<@Method Integer, ConditionVariable> conditionVariables =
|
||||||
createMethodConditionVariables();
|
createMethodConditionVariables();
|
||||||
private static final CueGroup EMPTY_CUE_GROUP =
|
|
||||||
new CueGroup(ImmutableList.of(), /* presentationTimeUs= */ 0);
|
|
||||||
|
|
||||||
@Nullable PlaybackException playerError;
|
@Nullable PlaybackException playerError;
|
||||||
public AudioAttributes audioAttributes;
|
public AudioAttributes audioAttributes;
|
||||||
@ -280,7 +278,7 @@ public class MockPlayer implements Player {
|
|||||||
repeatMode = Player.REPEAT_MODE_OFF;
|
repeatMode = Player.REPEAT_MODE_OFF;
|
||||||
videoSize = VideoSize.UNKNOWN;
|
videoSize = VideoSize.UNKNOWN;
|
||||||
volume = 1.0f;
|
volume = 1.0f;
|
||||||
cueGroup = EMPTY_CUE_GROUP;
|
cueGroup = CueGroup.EMPTY_TIME_ZERO;
|
||||||
deviceInfo = DeviceInfo.UNKNOWN;
|
deviceInfo = DeviceInfo.UNKNOWN;
|
||||||
seekPositionMs = C.TIME_UNSET;
|
seekPositionMs = C.TIME_UNSET;
|
||||||
seekMediaItemIndex = C.INDEX_UNSET;
|
seekMediaItemIndex = C.INDEX_UNSET;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user