mirror of
https://github.com/samsonjs/media.git
synced 2026-04-02 10:45:51 +00:00
Remove auto-notification of current cues when adding listener.
Users of addTextOutput should instead query the current cues if they need them. This is more consistent with how other listeners are handled. PiperOrigin-RevId: 310112241
This commit is contained in:
parent
99b62a24d1
commit
95ffc365ca
5 changed files with 21 additions and 9 deletions
|
|
@ -3,6 +3,9 @@
|
|||
### dev-v2 (not yet released)
|
||||
|
||||
* Core library:
|
||||
* Added `TextComponent.getCurrentCues` because the current cues are no
|
||||
longer forwarded to a new `TextOutput` in `SimpleExoPlayer`
|
||||
automatically.
|
||||
* Add opt-in to verify correct thread usage with
|
||||
`SimpleExoPlayer.setThrowsWhenUsingWrongThread(true)`
|
||||
([#4463](https://github.com/google/ExoPlayer/issues/4463)).
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import com.google.android.exoplayer2.device.DeviceInfo;
|
|||
import com.google.android.exoplayer2.device.DeviceListener;
|
||||
import com.google.android.exoplayer2.metadata.MetadataOutput;
|
||||
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.TrackSelectionArray;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
|
|
@ -348,6 +349,9 @@ public interface Player {
|
|||
* @param listener The output to remove.
|
||||
*/
|
||||
void removeTextOutput(TextOutput listener);
|
||||
|
||||
/** Returns the current {@link Cue Cues}. This list may be empty. */
|
||||
List<Cue> getCurrentCues();
|
||||
}
|
||||
|
||||
/** The metadata component of a {@link Player}. */
|
||||
|
|
|
|||
|
|
@ -354,7 +354,6 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
private final CopyOnWriteArraySet<AudioRendererEventListener> audioDebugListeners;
|
||||
private final BandwidthMeter bandwidthMeter;
|
||||
private final AnalyticsCollector analyticsCollector;
|
||||
|
||||
private final AudioBecomingNoisyManager audioBecomingNoisyManager;
|
||||
private final AudioFocusManager audioFocusManager;
|
||||
private final StreamVolumeManager streamVolumeManager;
|
||||
|
|
@ -981,9 +980,6 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
|
||||
@Override
|
||||
public void addTextOutput(TextOutput listener) {
|
||||
if (!currentCues.isEmpty()) {
|
||||
listener.onCues(currentCues);
|
||||
}
|
||||
textOutputs.add(listener);
|
||||
}
|
||||
|
||||
|
|
@ -992,6 +988,12 @@ public class SimpleExoPlayer extends BasePlayer
|
|||
textOutputs.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Cue> getCurrentCues() {
|
||||
verifyApplicationThread();
|
||||
return currentCues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an output to receive text events, removing all existing outputs.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ import java.util.List;
|
|||
public interface TextOutput {
|
||||
|
||||
/**
|
||||
* Called when there is a change in the {@link Cue}s.
|
||||
* Called when there is a change in the {@link Cue Cues}.
|
||||
*
|
||||
* @param cues The {@link Cue}s. May be empty.
|
||||
* @param cues The {@link Cue Cues}. May be empty.
|
||||
*/
|
||||
void onCues(List<Cue> cues);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -580,13 +580,13 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
|
|||
oldTextComponent.removeTextOutput(componentListener);
|
||||
}
|
||||
}
|
||||
if (subtitleView != null) {
|
||||
subtitleView.setCues(null);
|
||||
}
|
||||
this.player = player;
|
||||
if (useController()) {
|
||||
controller.setPlayer(player);
|
||||
}
|
||||
if (subtitleView != null) {
|
||||
subtitleView.setCues(null);
|
||||
}
|
||||
updateBuffering();
|
||||
updateErrorMessage();
|
||||
updateForCurrentTrackSelections(/* isNewPlayer= */ true);
|
||||
|
|
@ -608,6 +608,9 @@ public class PlayerView extends FrameLayout implements AdsLoader.AdViewProvider
|
|||
@Nullable Player.TextComponent newTextComponent = player.getTextComponent();
|
||||
if (newTextComponent != null) {
|
||||
newTextComponent.addTextOutput(componentListener);
|
||||
if (subtitleView != null) {
|
||||
subtitleView.setCues(newTextComponent.getCurrentCues());
|
||||
}
|
||||
}
|
||||
player.addListener(componentListener);
|
||||
maybeShowController(false);
|
||||
|
|
|
|||
Loading…
Reference in a new issue