mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Remove Player.Listener inheritance of TextOutput
PiperOrigin-RevId: 390630998
This commit is contained in:
parent
743b33e821
commit
38e5864f87
@ -17,6 +17,10 @@
|
||||
application code with Android 12's `Surface.CHANGE_FRAME_RATE_ALWAYS`.
|
||||
* GVR extension:
|
||||
* Remove `GvrAudioProcessor`, which has been deprecated since 2.11.0.
|
||||
* UI
|
||||
* `SubtitleView` no longer implements `TextOutput`. `SubtitleView`
|
||||
implements `Player.Listener`, so can be registered to a player with
|
||||
`Player.addListener`.
|
||||
* Remove deprecated symbols:
|
||||
* Remove `Renderer.VIDEO_SCALING_MODE_*` constants. Use identically named
|
||||
constants in `C` instead.
|
||||
|
@ -27,7 +27,6 @@ import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||
import com.google.android.exoplayer2.metadata.Metadata;
|
||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||
import com.google.android.exoplayer2.text.Cue;
|
||||
import com.google.android.exoplayer2.text.TextOutput;
|
||||
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||
import com.google.android.exoplayer2.util.FlagSet;
|
||||
@ -868,7 +867,7 @@ public interface Player {
|
||||
*
|
||||
* <p>All methods have no-op default implementations to allow selective overrides.
|
||||
*/
|
||||
interface Listener extends TextOutput, EventListener {
|
||||
interface Listener extends EventListener {
|
||||
|
||||
@Override
|
||||
default void onTimelineChanged(Timeline timeline, @TimelineChangeReason int reason) {}
|
||||
@ -987,7 +986,14 @@ public interface Player {
|
||||
*/
|
||||
default void onRenderedFirstFrame() {}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 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
|
||||
* displayed, the {@link Cue} nearer the end of the list should be shown on top.
|
||||
*
|
||||
* @param cues The {@link Cue Cues}. May be empty.
|
||||
*/
|
||||
default void onCues(List<Cue> cues) {}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,6 @@ import com.google.android.exoplayer2.source.MediaSource;
|
||||
import com.google.android.exoplayer2.source.MediaSourceFactory;
|
||||
import com.google.android.exoplayer2.source.ShuffleOrder;
|
||||
import com.google.android.exoplayer2.text.Cue;
|
||||
import com.google.android.exoplayer2.text.TextOutput;
|
||||
import com.google.android.exoplayer2.text.TextRenderer;
|
||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
||||
@ -386,24 +385,6 @@ public interface ExoPlayer extends Player {
|
||||
/** The text component of an {@link ExoPlayer}. */
|
||||
interface TextComponent {
|
||||
|
||||
/**
|
||||
* Registers an output to receive text events.
|
||||
*
|
||||
* @param listener The output to register.
|
||||
* @deprecated Use {@link #addListener(Listener)}.
|
||||
*/
|
||||
@Deprecated
|
||||
void addTextOutput(TextOutput listener);
|
||||
|
||||
/**
|
||||
* Removes a text output.
|
||||
*
|
||||
* @param listener The output to remove.
|
||||
* @deprecated Use {@link #removeListener(Listener)}.
|
||||
*/
|
||||
@Deprecated
|
||||
void removeTextOutput(TextOutput listener);
|
||||
|
||||
/** Returns the current {@link Cue Cues}. This list may be empty. */
|
||||
List<Cue> getCurrentCues();
|
||||
}
|
||||
|
@ -424,7 +424,6 @@ public class SimpleExoPlayer extends BasePlayer
|
||||
private final ExoPlayerImpl player;
|
||||
private final ComponentListener componentListener;
|
||||
private final FrameMetadataListener frameMetadataListener;
|
||||
private final CopyOnWriteArraySet<TextOutput> textOutputs;
|
||||
private final CopyOnWriteArraySet<Listener> listeners;
|
||||
private final AnalyticsCollector analyticsCollector;
|
||||
private final AudioBecomingNoisyManager audioBecomingNoisyManager;
|
||||
@ -505,7 +504,6 @@ public class SimpleExoPlayer extends BasePlayer
|
||||
detachSurfaceTimeoutMs = builder.detachSurfaceTimeoutMs;
|
||||
componentListener = new ComponentListener();
|
||||
frameMetadataListener = new FrameMetadataListener();
|
||||
textOutputs = new CopyOnWriteArraySet<>();
|
||||
listeners = new CopyOnWriteArraySet<>();
|
||||
Handler eventHandler = new Handler(builder.looper);
|
||||
renderers =
|
||||
@ -1046,21 +1044,6 @@ public class SimpleExoPlayer extends BasePlayer
|
||||
.send();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void addTextOutput(TextOutput listener) {
|
||||
// Don't verify application thread. We allow calls to this method from any thread.
|
||||
Assertions.checkNotNull(listener);
|
||||
textOutputs.add(listener);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void removeTextOutput(TextOutput listener) {
|
||||
// Don't verify application thread. We allow calls to this method from any thread.
|
||||
textOutputs.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Cue> getCurrentCues() {
|
||||
verifyApplicationThread();
|
||||
@ -1087,7 +1070,6 @@ public class SimpleExoPlayer extends BasePlayer
|
||||
@Override
|
||||
public void addListener(Listener listener) {
|
||||
Assertions.checkNotNull(listener);
|
||||
addTextOutput(listener);
|
||||
listeners.add(listener);
|
||||
EventListener eventListener = listener;
|
||||
addListener(eventListener);
|
||||
@ -1104,7 +1086,6 @@ public class SimpleExoPlayer extends BasePlayer
|
||||
@Override
|
||||
public void removeListener(Listener listener) {
|
||||
Assertions.checkNotNull(listener);
|
||||
removeTextOutput(listener);
|
||||
listeners.remove(listener);
|
||||
EventListener eventListener = listener;
|
||||
removeListener(eventListener);
|
||||
@ -2057,8 +2038,9 @@ public class SimpleExoPlayer extends BasePlayer
|
||||
@Override
|
||||
public void onCues(List<Cue> cues) {
|
||||
currentCues = cues;
|
||||
for (TextOutput textOutput : textOutputs) {
|
||||
textOutput.onCues(cues);
|
||||
// TODO(internal b/187152483): Events should be dispatched via ListenerSet
|
||||
for (Listener listeners : listeners) {
|
||||
listeners.onCues(cues);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,8 @@ import android.widget.FrameLayout;
|
||||
import androidx.annotation.Dimension;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
import com.google.android.exoplayer2.text.Cue;
|
||||
import com.google.android.exoplayer2.text.TextOutput;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
@ -40,7 +40,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** A view for displaying subtitle {@link Cue}s. */
|
||||
public final class SubtitleView extends FrameLayout implements TextOutput {
|
||||
public final class SubtitleView extends FrameLayout implements Player.Listener {
|
||||
|
||||
/**
|
||||
* An output for displaying subtitles.
|
||||
|
Loading…
x
Reference in New Issue
Block a user