mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Create new class to store cues and timestamp.
We need to pass timestamp for the list of cues so we are defining a new class CueGroup which will store both cues and timestamp. PiperOrigin-RevId: 449212054
This commit is contained in:
parent
b2f46fabf7
commit
a27b5398a8
15 changed files with 244 additions and 32 deletions
|
|
@ -40,7 +40,7 @@ import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.Tracks;
|
import com.google.android.exoplayer2.Tracks;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||||
import com.google.android.exoplayer2.source.TrackGroup;
|
import com.google.android.exoplayer2.source.TrackGroup;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.CueGroup;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
import com.google.android.exoplayer2.util.Clock;
|
import com.google.android.exoplayer2.util.Clock;
|
||||||
|
|
@ -703,10 +703,10 @@ public final class CastPlayer extends BasePlayer {
|
||||||
return VideoSize.UNKNOWN;
|
return VideoSize.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is not supported and returns an empty list. */
|
/** This method is not supported and returns an empty {@link CueGroup}. */
|
||||||
@Override
|
@Override
|
||||||
public ImmutableList<Cue> getCurrentCues() {
|
public CueGroup getCurrentCues() {
|
||||||
return ImmutableList.of();
|
return CueGroup.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is not supported and always returns {@link DeviceInfo#UNKNOWN}. */
|
/** This method is not supported and always returns {@link DeviceInfo#UNKNOWN}. */
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||||
import com.google.android.exoplayer2.metadata.Metadata;
|
import com.google.android.exoplayer2.metadata.Metadata;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.Cue;
|
||||||
|
import com.google.android.exoplayer2.text.CueGroup;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
||||||
import com.google.android.exoplayer2.video.VideoSize;
|
import com.google.android.exoplayer2.video.VideoSize;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -754,7 +755,7 @@ public class ForwardingPlayer implements Player {
|
||||||
|
|
||||||
/** Calls {@link Player#getCurrentCues()} on the delegate and returns the result. */
|
/** Calls {@link Player#getCurrentCues()} on the delegate and returns the result. */
|
||||||
@Override
|
@Override
|
||||||
public List<Cue> getCurrentCues() {
|
public CueGroup getCurrentCues() {
|
||||||
return player.getCurrentCues();
|
return player.getCurrentCues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -994,6 +995,11 @@ public class ForwardingPlayer implements Player {
|
||||||
listener.onCues(cues);
|
listener.onCues(cues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCues(CueGroup cueGroup) {
|
||||||
|
listener.onCues(cueGroup);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMetadata(Metadata metadata) {
|
public void onMetadata(Metadata metadata) {
|
||||||
listener.onMetadata(metadata);
|
listener.onMetadata(metadata);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||||
import com.google.android.exoplayer2.metadata.Metadata;
|
import com.google.android.exoplayer2.metadata.Metadata;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.Cue;
|
||||||
|
import com.google.android.exoplayer2.text.CueGroup;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
||||||
import com.google.android.exoplayer2.util.BundleableUtil;
|
import com.google.android.exoplayer2.util.BundleableUtil;
|
||||||
import com.google.android.exoplayer2.util.FlagSet;
|
import com.google.android.exoplayer2.util.FlagSet;
|
||||||
|
|
@ -1016,16 +1017,28 @@ public interface Player {
|
||||||
/**
|
/**
|
||||||
* Called when there is a change in the {@link Cue Cues}.
|
* Called when there is a change in the {@link Cue Cues}.
|
||||||
*
|
*
|
||||||
* <p>{@code cues} is in ascending order of priority. If any of the cue boxes overlap when
|
* <p>Both {@link #onCues(List)} and {@link #onCues(CueGroup)} are called when there is a change
|
||||||
* displayed, the {@link Cue} nearer the end of the list should be shown on top.
|
* in the cues. You should only implement one or the other.
|
||||||
*
|
*
|
||||||
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
|
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
|
||||||
* other events that happen in the same {@link Looper} message queue iteration.
|
* other events that happen in the same {@link Looper} message queue iteration.
|
||||||
*
|
*
|
||||||
* @param cues The {@link Cue Cues}. May be empty.
|
* @deprecated Use {@link #onCues(CueGroup)} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
default void onCues(List<Cue> cues) {}
|
default void onCues(List<Cue> cues) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when there is a change in the {@link CueGroup}.
|
||||||
|
*
|
||||||
|
* <p>Both {@link #onCues(List)} and {@link #onCues(CueGroup)} are called when there is a change
|
||||||
|
* in the cues. You should only implement one or the other.
|
||||||
|
*
|
||||||
|
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
|
||||||
|
* other events that happen in the same {@link Looper} message queue iteration.
|
||||||
|
*/
|
||||||
|
default void onCues(CueGroup cueGroup) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when there is metadata associated with the current playback time.
|
* Called when there is metadata associated with the current playback time.
|
||||||
*
|
*
|
||||||
|
|
@ -2443,8 +2456,8 @@ public interface Player {
|
||||||
*/
|
*/
|
||||||
VideoSize getVideoSize();
|
VideoSize getVideoSize();
|
||||||
|
|
||||||
/** Returns the current {@link Cue Cues}. This list may be empty. */
|
/** Returns the current {@link CueGroup}. */
|
||||||
List<Cue> getCurrentCues();
|
CueGroup getCurrentCues();
|
||||||
|
|
||||||
/** Gets the device information. */
|
/** Gets the device information. */
|
||||||
DeviceInfo getDeviceInfo();
|
DeviceInfo getDeviceInfo();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.google.android.exoplayer2.text;
|
||||||
|
|
||||||
|
import static java.lang.annotation.ElementType.TYPE_USE;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import androidx.annotation.IntDef;
|
||||||
|
import com.google.android.exoplayer2.Bundleable;
|
||||||
|
import com.google.android.exoplayer2.util.BundleableUtil;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** Class to represent the state of active {@link Cue Cues} at a particular time. */
|
||||||
|
public final class CueGroup implements Bundleable {
|
||||||
|
|
||||||
|
/** Empty {@link CueGroup}. */
|
||||||
|
public static final CueGroup EMPTY = new CueGroup(ImmutableList.of());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The cues in this group.
|
||||||
|
*
|
||||||
|
* <p>This list is in ascending order of priority. If any of the cue boxes overlap when displayed,
|
||||||
|
* the {@link Cue} nearer the end of the list should be shown on top.
|
||||||
|
*
|
||||||
|
* <p>This list may be empty if the group represents a state with no cues.
|
||||||
|
*/
|
||||||
|
public final ImmutableList<Cue> cues;
|
||||||
|
|
||||||
|
/** Creates a CueGroup. */
|
||||||
|
public CueGroup(List<Cue> cues) {
|
||||||
|
this.cues = ImmutableList.copyOf(cues);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bundleable implementation.
|
||||||
|
|
||||||
|
@Documented
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@Target(TYPE_USE)
|
||||||
|
@IntDef({FIELD_CUES})
|
||||||
|
private @interface FieldNumber {}
|
||||||
|
|
||||||
|
private static final int FIELD_CUES = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Bundle toBundle() {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelableArrayList(
|
||||||
|
keyForField(FIELD_CUES), BundleableUtil.toBundleArrayList(filterOutBitmapCues(cues)));
|
||||||
|
return bundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<CueGroup> CREATOR = CueGroup::fromBundle;
|
||||||
|
|
||||||
|
private static final CueGroup fromBundle(Bundle bundle) {
|
||||||
|
List<Cue> cues =
|
||||||
|
BundleableUtil.fromBundleNullableList(
|
||||||
|
Cue.CREATOR,
|
||||||
|
bundle.getParcelableArrayList(keyForField(FIELD_CUES)),
|
||||||
|
/* defaultValue= */ ImmutableList.of());
|
||||||
|
return new CueGroup(cues);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String keyForField(@FieldNumber int field) {
|
||||||
|
return Integer.toString(field, Character.MAX_RADIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters out {@link Cue} objects containing {@link Bitmap}. It is used when transferring cues
|
||||||
|
* between processes to prevent transferring too much data.
|
||||||
|
*/
|
||||||
|
private static ImmutableList<Cue> filterOutBitmapCues(List<Cue> cues) {
|
||||||
|
ImmutableList.Builder<Cue> builder = ImmutableList.builder();
|
||||||
|
for (int i = 0; i < cues.size(); i++) {
|
||||||
|
if (cues.get(i).bitmap != null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
builder.add(cues.get(i));
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.google.android.exoplayer2.text;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.text.SpannedString;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
/** Tests for {@link CueGroup}. */
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class CueGroupTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void bundleAndUnBundleCueGroup() {
|
||||||
|
Cue textCue = new Cue.Builder().setText(SpannedString.valueOf("text")).build();
|
||||||
|
Cue bitmapCue =
|
||||||
|
new Cue.Builder().setBitmap(Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)).build();
|
||||||
|
ImmutableList<Cue> cues = ImmutableList.of(textCue, bitmapCue);
|
||||||
|
CueGroup cueGroup = new CueGroup(cues);
|
||||||
|
|
||||||
|
Parcel parcel = Parcel.obtain();
|
||||||
|
try {
|
||||||
|
parcel.writeBundle(cueGroup.toBundle());
|
||||||
|
parcel.setDataPosition(0);
|
||||||
|
|
||||||
|
Bundle bundle = parcel.readBundle();
|
||||||
|
CueGroup filteredCueGroup = CueGroup.CREATOR.fromBundle(bundle);
|
||||||
|
|
||||||
|
assertThat(filteredCueGroup.cues).containsExactly(textCue);
|
||||||
|
} finally {
|
||||||
|
parcel.recycle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -45,7 +45,7 @@ import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.ShuffleOrder;
|
import com.google.android.exoplayer2.source.ShuffleOrder;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.CueGroup;
|
||||||
import com.google.android.exoplayer2.text.TextRenderer;
|
import com.google.android.exoplayer2.text.TextRenderer;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||||
|
|
@ -348,7 +348,7 @@ public interface ExoPlayer extends Player {
|
||||||
* @deprecated Use {@link Player#getCurrentCues()} instead.
|
* @deprecated Use {@link Player#getCurrentCues()} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
List<Cue> getCurrentCues();
|
CueGroup getCurrentCues();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ import com.google.android.exoplayer2.source.ShuffleOrder;
|
||||||
import com.google.android.exoplayer2.source.TrackGroup;
|
import com.google.android.exoplayer2.source.TrackGroup;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.Cue;
|
||||||
|
import com.google.android.exoplayer2.text.CueGroup;
|
||||||
import com.google.android.exoplayer2.text.TextOutput;
|
import com.google.android.exoplayer2.text.TextOutput;
|
||||||
import com.google.android.exoplayer2.trackselection.ExoTrackSelection;
|
import com.google.android.exoplayer2.trackselection.ExoTrackSelection;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||||
|
|
@ -185,7 +186,7 @@ import java.util.concurrent.TimeoutException;
|
||||||
private AudioAttributes audioAttributes;
|
private AudioAttributes audioAttributes;
|
||||||
private float volume;
|
private float volume;
|
||||||
private boolean skipSilenceEnabled;
|
private boolean skipSilenceEnabled;
|
||||||
private List<Cue> currentCues;
|
private CueGroup currentCueGroup;
|
||||||
@Nullable private VideoFrameMetadataListener videoFrameMetadataListener;
|
@Nullable private VideoFrameMetadataListener videoFrameMetadataListener;
|
||||||
@Nullable private CameraMotionListener cameraMotionListener;
|
@Nullable private CameraMotionListener cameraMotionListener;
|
||||||
private boolean throwsWhenUsingWrongThread;
|
private boolean throwsWhenUsingWrongThread;
|
||||||
|
|
@ -342,7 +343,7 @@ import java.util.concurrent.TimeoutException;
|
||||||
} else {
|
} else {
|
||||||
audioSessionId = Util.generateAudioSessionIdV21(applicationContext);
|
audioSessionId = Util.generateAudioSessionIdV21(applicationContext);
|
||||||
}
|
}
|
||||||
currentCues = ImmutableList.of();
|
currentCueGroup = CueGroup.EMPTY;
|
||||||
throwsWhenUsingWrongThread = true;
|
throwsWhenUsingWrongThread = true;
|
||||||
|
|
||||||
addListener(analyticsCollector);
|
addListener(analyticsCollector);
|
||||||
|
|
@ -925,7 +926,7 @@ import java.util.concurrent.TimeoutException;
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
audioFocusManager.updateAudioFocus(getPlayWhenReady(), Player.STATE_IDLE);
|
audioFocusManager.updateAudioFocus(getPlayWhenReady(), Player.STATE_IDLE);
|
||||||
stopInternal(reset, /* error= */ null);
|
stopInternal(reset, /* error= */ null);
|
||||||
currentCues = ImmutableList.of();
|
currentCueGroup = CueGroup.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -979,7 +980,7 @@ import java.util.concurrent.TimeoutException;
|
||||||
checkNotNull(priorityTaskManager).remove(C.PRIORITY_PLAYBACK);
|
checkNotNull(priorityTaskManager).remove(C.PRIORITY_PLAYBACK);
|
||||||
isPriorityTaskManagerRegistered = false;
|
isPriorityTaskManagerRegistered = false;
|
||||||
}
|
}
|
||||||
currentCues = ImmutableList.of();
|
currentCueGroup = CueGroup.EMPTY;
|
||||||
playerReleased = true;
|
playerReleased = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1576,9 +1577,9 @@ import java.util.concurrent.TimeoutException;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Cue> getCurrentCues() {
|
public CueGroup getCurrentCues() {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
return currentCues;
|
return currentCueGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -2839,13 +2840,17 @@ import java.util.concurrent.TimeoutException;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextOutput implementation
|
// TextOutput implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCues(List<Cue> cues) {
|
public void onCues(List<Cue> cues) {
|
||||||
currentCues = cues;
|
|
||||||
listeners.sendEvent(EVENT_CUES, listener -> listener.onCues(cues));
|
listeners.sendEvent(EVENT_CUES, listener -> listener.onCues(cues));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCues(CueGroup cueGroup) {
|
||||||
|
currentCueGroup = cueGroup;
|
||||||
|
listeners.sendEvent(EVENT_CUES, listener -> listener.onCues(cueGroup));
|
||||||
|
}
|
||||||
|
|
||||||
// MetadataOutput implementation
|
// MetadataOutput implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.ShuffleOrder;
|
import com.google.android.exoplayer2.source.ShuffleOrder;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.CueGroup;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
||||||
|
|
@ -680,7 +680,7 @@ public class SimpleExoPlayer extends BasePlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Cue> getCurrentCues() {
|
public CueGroup getCurrentCues() {
|
||||||
blockUntilConstructorFinished();
|
blockUntilConstructorFinished();
|
||||||
return player.getCurrentCues();
|
return player.getCurrentCues();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import com.google.android.exoplayer2.source.LoadEventInfo;
|
||||||
import com.google.android.exoplayer2.source.MediaLoadData;
|
import com.google.android.exoplayer2.source.MediaLoadData;
|
||||||
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.Cue;
|
||||||
|
import com.google.android.exoplayer2.text.CueGroup;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
||||||
import com.google.android.exoplayer2.util.FlagSet;
|
import com.google.android.exoplayer2.util.FlagSet;
|
||||||
|
|
@ -832,14 +833,27 @@ public interface AnalyticsListener {
|
||||||
/**
|
/**
|
||||||
* Called when there is a change in the {@link Cue Cues}.
|
* Called when there is a change in the {@link Cue Cues}.
|
||||||
*
|
*
|
||||||
* <p>{@code cues} is in ascending order of priority. If any of the cue boxes overlap when
|
* <p>Both {@link #onCues(EventTime, List)} and {@link #onCues(EventTime, CueGroup)} are called
|
||||||
* displayed, the {@link Cue} nearer the end of the list should be shown on top.
|
* when there is a change in the cues. You should only implement one or the other.
|
||||||
*
|
*
|
||||||
* @param eventTime The event time.
|
* @param eventTime The event time.
|
||||||
* @param cues The {@link Cue Cues}. May be empty.
|
* @param cues The {@link Cue Cues}.
|
||||||
|
* @deprecated Use {@link #onCues(EventTime, CueGroup)} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
default void onCues(EventTime eventTime, List<Cue> cues) {}
|
default void onCues(EventTime eventTime, List<Cue> cues) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when there is a change in the {@link CueGroup}.
|
||||||
|
*
|
||||||
|
* <p>Both {@link #onCues(EventTime, List)} and {@link #onCues(EventTime, CueGroup)} are called
|
||||||
|
* when there is a change in the cues. You should only implement one or the other.
|
||||||
|
*
|
||||||
|
* @param eventTime The event time.
|
||||||
|
* @param cueGroup The {@link CueGroup}.
|
||||||
|
*/
|
||||||
|
default void onCues(EventTime eventTime, CueGroup cueGroup) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #onAudioEnabled} and {@link #onVideoEnabled} instead.
|
* @deprecated Use {@link #onAudioEnabled} and {@link #onVideoEnabled} instead.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ import com.google.android.exoplayer2.source.LoadEventInfo;
|
||||||
import com.google.android.exoplayer2.source.MediaLoadData;
|
import com.google.android.exoplayer2.source.MediaLoadData;
|
||||||
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.Cue;
|
||||||
|
import com.google.android.exoplayer2.text.CueGroup;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
||||||
import com.google.android.exoplayer2.util.Clock;
|
import com.google.android.exoplayer2.util.Clock;
|
||||||
import com.google.android.exoplayer2.util.HandlerWrapper;
|
import com.google.android.exoplayer2.util.HandlerWrapper;
|
||||||
|
|
@ -693,6 +694,7 @@ public class DefaultAnalyticsCollector implements AnalyticsCollector {
|
||||||
listener -> listener.onMetadata(eventTime, metadata));
|
listener -> listener.onMetadata(eventTime, metadata));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation") // Implementing and calling deprecated listener method.
|
||||||
@Override
|
@Override
|
||||||
public void onCues(List<Cue> cues) {
|
public void onCues(List<Cue> cues) {
|
||||||
EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
|
EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
|
||||||
|
|
@ -700,6 +702,13 @@ public class DefaultAnalyticsCollector implements AnalyticsCollector {
|
||||||
eventTime, AnalyticsListener.EVENT_CUES, listener -> listener.onCues(eventTime, cues));
|
eventTime, AnalyticsListener.EVENT_CUES, listener -> listener.onCues(eventTime, cues));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCues(CueGroup cueGroup) {
|
||||||
|
EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
|
||||||
|
sendEvent(
|
||||||
|
eventTime, AnalyticsListener.EVENT_CUES, listener -> listener.onCues(eventTime, cueGroup));
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") // Implementing and calling deprecated listener method.
|
@SuppressWarnings("deprecation") // Implementing and calling deprecated listener method.
|
||||||
@Override
|
@Override
|
||||||
public final void onSeekProcessed() {
|
public final void onSeekProcessed() {
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,19 @@ public interface TextOutput {
|
||||||
/**
|
/**
|
||||||
* Called when there is a change in the {@link Cue Cues}.
|
* Called when there is a change in the {@link Cue Cues}.
|
||||||
*
|
*
|
||||||
* <p>{@code cues} is in ascending order of priority. If any of the cue boxes overlap when
|
* <p>Both {@link #onCues(List)} and {@link #onCues(CueGroup)} are called when there is a change
|
||||||
* displayed, the {@link Cue} nearer the end of the list should be shown on top.
|
* in the cues. You should only implement one or the other.
|
||||||
*
|
*
|
||||||
* @param cues The {@link Cue Cues}. May be empty.
|
* @deprecated Use {@link #onCues(CueGroup)} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
void onCues(List<Cue> cues);
|
void onCues(List<Cue> cues);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when there is a change in the {@link CueGroup}.
|
||||||
|
*
|
||||||
|
* <p>Both {@link #onCues(List)} and {@link #onCues(CueGroup)} are called when there is a change
|
||||||
|
* in the cues You should only implement one or the other.
|
||||||
|
*/
|
||||||
|
default void onCues(CueGroup cueGroup) {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -387,6 +387,7 @@ public final class TextRenderer extends BaseRenderer implements Callback {
|
||||||
|
|
||||||
private void invokeUpdateOutputInternal(List<Cue> cues) {
|
private void invokeUpdateOutputInternal(List<Cue> cues) {
|
||||||
output.onCues(cues);
|
output.onCues(cues);
|
||||||
|
output.onCues(new CueGroup(cues));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -605,7 +605,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
||||||
updateAspectRatio();
|
updateAspectRatio();
|
||||||
}
|
}
|
||||||
if (subtitleView != null && player.isCommandAvailable(COMMAND_GET_TEXT)) {
|
if (subtitleView != null && player.isCommandAvailable(COMMAND_GET_TEXT)) {
|
||||||
subtitleView.setCues(player.getCurrentCues());
|
subtitleView.setCues(player.getCurrentCues().cues);
|
||||||
}
|
}
|
||||||
player.addListener(componentListener);
|
player.addListener(componentListener);
|
||||||
maybeShowController(false);
|
maybeShowController(false);
|
||||||
|
|
|
||||||
|
|
@ -555,7 +555,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider {
|
||||||
updateAspectRatio();
|
updateAspectRatio();
|
||||||
}
|
}
|
||||||
if (subtitleView != null && player.isCommandAvailable(COMMAND_GET_TEXT)) {
|
if (subtitleView != null && player.isCommandAvailable(COMMAND_GET_TEXT)) {
|
||||||
subtitleView.setCues(player.getCurrentCues());
|
subtitleView.setCues(player.getCurrentCues().cues);
|
||||||
}
|
}
|
||||||
player.addListener(componentListener);
|
player.addListener(componentListener);
|
||||||
maybeShowController(false);
|
maybeShowController(false);
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.Tracks;
|
import com.google.android.exoplayer2.Tracks;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||||
import com.google.android.exoplayer2.text.Cue;
|
import com.google.android.exoplayer2.text.CueGroup;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
||||||
import com.google.android.exoplayer2.video.VideoSize;
|
import com.google.android.exoplayer2.video.VideoSize;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -344,7 +344,7 @@ public class StubPlayer extends BasePlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Cue> getCurrentCues() {
|
public CueGroup getCurrentCues() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue