From a27b5398a8156bd1ec0202adf65abfa5920c8ba9 Mon Sep 17 00:00:00 2001 From: rohks Date: Tue, 17 May 2022 15:10:15 +0100 Subject: [PATCH] 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 --- .../exoplayer2/ext/cast/CastPlayer.java | 8 +- .../android/exoplayer2/ForwardingPlayer.java | 8 +- .../com/google/android/exoplayer2/Player.java | 23 +++- .../android/exoplayer2/text/CueGroup.java | 100 ++++++++++++++++++ .../android/exoplayer2/text/CueGroupTest.java | 55 ++++++++++ .../google/android/exoplayer2/ExoPlayer.java | 4 +- .../android/exoplayer2/ExoPlayerImpl.java | 21 ++-- .../android/exoplayer2/SimpleExoPlayer.java | 4 +- .../analytics/AnalyticsListener.java | 20 +++- .../analytics/DefaultAnalyticsCollector.java | 9 ++ .../android/exoplayer2/text/TextOutput.java | 15 ++- .../android/exoplayer2/text/TextRenderer.java | 1 + .../android/exoplayer2/ui/PlayerView.java | 2 +- .../exoplayer2/ui/StyledPlayerView.java | 2 +- .../exoplayer2/testutil/StubPlayer.java | 4 +- 15 files changed, 244 insertions(+), 32 deletions(-) create mode 100644 library/common/src/main/java/com/google/android/exoplayer2/text/CueGroup.java create mode 100644 library/common/src/test/java/com/google/android/exoplayer2/text/CueGroupTest.java diff --git a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java index 7136107b3d..fec512c88e 100644 --- a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java +++ b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java @@ -40,7 +40,7 @@ import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Tracks; import com.google.android.exoplayer2.audio.AudioAttributes; 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.util.Assertions; import com.google.android.exoplayer2.util.Clock; @@ -703,10 +703,10 @@ public final class CastPlayer extends BasePlayer { 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 - public ImmutableList getCurrentCues() { - return ImmutableList.of(); + public CueGroup getCurrentCues() { + return CueGroup.EMPTY; } /** This method is not supported and always returns {@link DeviceInfo#UNKNOWN}. */ diff --git a/library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java b/library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java index da3a35e17e..b29bc40809 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java @@ -24,6 +24,7 @@ import androidx.annotation.Nullable; import com.google.android.exoplayer2.audio.AudioAttributes; import com.google.android.exoplayer2.metadata.Metadata; 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.video.VideoSize; import java.util.List; @@ -754,7 +755,7 @@ public class ForwardingPlayer implements Player { /** Calls {@link Player#getCurrentCues()} on the delegate and returns the result. */ @Override - public List getCurrentCues() { + public CueGroup getCurrentCues() { return player.getCurrentCues(); } @@ -994,6 +995,11 @@ public class ForwardingPlayer implements Player { listener.onCues(cues); } + @Override + public void onCues(CueGroup cueGroup) { + listener.onCues(cueGroup); + } + @Override public void onMetadata(Metadata metadata) { listener.onMetadata(metadata); diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Player.java b/library/common/src/main/java/com/google/android/exoplayer2/Player.java index 12560c5ef2..ebf2d158a6 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/Player.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/Player.java @@ -34,6 +34,7 @@ import androidx.annotation.Nullable; import com.google.android.exoplayer2.audio.AudioAttributes; import com.google.android.exoplayer2.metadata.Metadata; 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.util.BundleableUtil; 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}. * - *

{@code cues} 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. + *

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. * *

{@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. * - * @param cues The {@link Cue Cues}. May be empty. + * @deprecated Use {@link #onCues(CueGroup)} instead. */ + @Deprecated default void onCues(List cues) {} + /** + * Called when there is a change in the {@link CueGroup}. + * + *

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. + * + *

{@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. * @@ -2443,8 +2456,8 @@ public interface Player { */ VideoSize getVideoSize(); - /** Returns the current {@link Cue Cues}. This list may be empty. */ - List getCurrentCues(); + /** Returns the current {@link CueGroup}. */ + CueGroup getCurrentCues(); /** Gets the device information. */ DeviceInfo getDeviceInfo(); diff --git a/library/common/src/main/java/com/google/android/exoplayer2/text/CueGroup.java b/library/common/src/main/java/com/google/android/exoplayer2/text/CueGroup.java new file mode 100644 index 0000000000..5ee0658984 --- /dev/null +++ b/library/common/src/main/java/com/google/android/exoplayer2/text/CueGroup.java @@ -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. + * + *

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. + * + *

This list may be empty if the group represents a state with no cues. + */ + public final ImmutableList cues; + + /** Creates a CueGroup. */ + public CueGroup(List 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 CREATOR = CueGroup::fromBundle; + + private static final CueGroup fromBundle(Bundle bundle) { + List 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 filterOutBitmapCues(List cues) { + ImmutableList.Builder 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(); + } +} diff --git a/library/common/src/test/java/com/google/android/exoplayer2/text/CueGroupTest.java b/library/common/src/test/java/com/google/android/exoplayer2/text/CueGroupTest.java new file mode 100644 index 0000000000..7df2044f6a --- /dev/null +++ b/library/common/src/test/java/com/google/android/exoplayer2/text/CueGroupTest.java @@ -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 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(); + } + } +} diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java index 78e7780746..31bd19b6fd 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java @@ -45,7 +45,7 @@ import com.google.android.exoplayer2.source.DefaultMediaSourceFactory; import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.ShuffleOrder; 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.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; @@ -348,7 +348,7 @@ public interface ExoPlayer extends Player { * @deprecated Use {@link Player#getCurrentCues()} instead. */ @Deprecated - List getCurrentCues(); + CueGroup getCurrentCues(); } /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java index 3b2fed887b..b71fe13381 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java @@ -71,6 +71,7 @@ import com.google.android.exoplayer2.source.ShuffleOrder; import com.google.android.exoplayer2.source.TrackGroup; 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.TextOutput; import com.google.android.exoplayer2.trackselection.ExoTrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; @@ -185,7 +186,7 @@ import java.util.concurrent.TimeoutException; private AudioAttributes audioAttributes; private float volume; private boolean skipSilenceEnabled; - private List currentCues; + private CueGroup currentCueGroup; @Nullable private VideoFrameMetadataListener videoFrameMetadataListener; @Nullable private CameraMotionListener cameraMotionListener; private boolean throwsWhenUsingWrongThread; @@ -342,7 +343,7 @@ import java.util.concurrent.TimeoutException; } else { audioSessionId = Util.generateAudioSessionIdV21(applicationContext); } - currentCues = ImmutableList.of(); + currentCueGroup = CueGroup.EMPTY; throwsWhenUsingWrongThread = true; addListener(analyticsCollector); @@ -925,7 +926,7 @@ import java.util.concurrent.TimeoutException; verifyApplicationThread(); audioFocusManager.updateAudioFocus(getPlayWhenReady(), Player.STATE_IDLE); stopInternal(reset, /* error= */ null); - currentCues = ImmutableList.of(); + currentCueGroup = CueGroup.EMPTY; } @Override @@ -979,7 +980,7 @@ import java.util.concurrent.TimeoutException; checkNotNull(priorityTaskManager).remove(C.PRIORITY_PLAYBACK); isPriorityTaskManagerRegistered = false; } - currentCues = ImmutableList.of(); + currentCueGroup = CueGroup.EMPTY; playerReleased = true; } @@ -1576,9 +1577,9 @@ import java.util.concurrent.TimeoutException; } @Override - public List getCurrentCues() { + public CueGroup getCurrentCues() { verifyApplicationThread(); - return currentCues; + return currentCueGroup; } @Override @@ -2839,13 +2840,17 @@ import java.util.concurrent.TimeoutException; } // TextOutput implementation - @Override public void onCues(List cues) { - currentCues = 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 @Override diff --git a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java index 656d046476..5e4edfda81 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java @@ -34,7 +34,7 @@ import com.google.android.exoplayer2.source.DefaultMediaSourceFactory; import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.ShuffleOrder; 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.TrackSelectionParameters; import com.google.android.exoplayer2.trackselection.TrackSelector; @@ -680,7 +680,7 @@ public class SimpleExoPlayer extends BasePlayer } @Override - public List getCurrentCues() { + public CueGroup getCurrentCues() { blockUntilConstructorFinished(); return player.getCurrentCues(); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsListener.java b/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsListener.java index b2ddd82862..5cce607660 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsListener.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsListener.java @@ -55,6 +55,7 @@ import com.google.android.exoplayer2.source.LoadEventInfo; import com.google.android.exoplayer2.source.MediaLoadData; import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId; 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.TrackSelectionParameters; 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}. * - *

{@code cues} 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. + *

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 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 cues) {} + /** + * Called when there is a change in the {@link CueGroup}. + * + *

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. */ diff --git a/library/core/src/main/java/com/google/android/exoplayer2/analytics/DefaultAnalyticsCollector.java b/library/core/src/main/java/com/google/android/exoplayer2/analytics/DefaultAnalyticsCollector.java index 62840851ab..14d1f546cd 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/analytics/DefaultAnalyticsCollector.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/analytics/DefaultAnalyticsCollector.java @@ -48,6 +48,7 @@ import com.google.android.exoplayer2.source.LoadEventInfo; import com.google.android.exoplayer2.source.MediaLoadData; import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId; 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.util.Clock; import com.google.android.exoplayer2.util.HandlerWrapper; @@ -693,6 +694,7 @@ public class DefaultAnalyticsCollector implements AnalyticsCollector { listener -> listener.onMetadata(eventTime, metadata)); } + @SuppressWarnings("deprecation") // Implementing and calling deprecated listener method. @Override public void onCues(List cues) { EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime(); @@ -700,6 +702,13 @@ public class DefaultAnalyticsCollector implements AnalyticsCollector { 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. @Override public final void onSeekProcessed() { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/TextOutput.java b/library/core/src/main/java/com/google/android/exoplayer2/text/TextOutput.java index 12c781c5f9..f1779350bc 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/TextOutput.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/TextOutput.java @@ -23,10 +23,19 @@ public interface TextOutput { /** * Called when there is a change in the {@link Cue Cues}. * - *

{@code cues} 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. + *

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. * - * @param cues The {@link Cue Cues}. May be empty. + * @deprecated Use {@link #onCues(CueGroup)} instead. */ + @Deprecated void onCues(List cues); + + /** + * Called when there is a change in the {@link CueGroup}. + * + *

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) {} } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/TextRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/text/TextRenderer.java index 887174d90b..311b57a059 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/TextRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/TextRenderer.java @@ -387,6 +387,7 @@ public final class TextRenderer extends BaseRenderer implements Callback { private void invokeUpdateOutputInternal(List cues) { output.onCues(cues); + output.onCues(new CueGroup(cues)); } /** diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java index 5ebb2caa8d..df075d5d61 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java @@ -605,7 +605,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider { updateAspectRatio(); } if (subtitleView != null && player.isCommandAvailable(COMMAND_GET_TEXT)) { - subtitleView.setCues(player.getCurrentCues()); + subtitleView.setCues(player.getCurrentCues().cues); } player.addListener(componentListener); maybeShowController(false); diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java index 7e79982bb9..c49f721311 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java @@ -555,7 +555,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { updateAspectRatio(); } if (subtitleView != null && player.isCommandAvailable(COMMAND_GET_TEXT)) { - subtitleView.setCues(player.getCurrentCues()); + subtitleView.setCues(player.getCurrentCues().cues); } player.addListener(componentListener); maybeShowController(false); diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/StubPlayer.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/StubPlayer.java index 7221fa7015..638b4b8fcb 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/StubPlayer.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/StubPlayer.java @@ -31,7 +31,7 @@ import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Tracks; 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.video.VideoSize; import java.util.List; @@ -344,7 +344,7 @@ public class StubPlayer extends BasePlayer { } @Override - public List getCurrentCues() { + public CueGroup getCurrentCues() { throw new UnsupportedOperationException(); }