deprecate and rename onLoadingChanged

PiperOrigin-RevId: 294222083
This commit is contained in:
bachinger 2020-02-10 16:10:01 +00:00 committed by kim-vde
parent 5725acb789
commit 0eb0267131
9 changed files with 27 additions and 8 deletions

View File

@ -10,6 +10,7 @@
* Add `Player.onPlaybackStateChanged` and deprecate
`Player.onPlayerStateChanged`.
* Deprecate and rename getPlaybackError to getPlayerError for consistency.
* Deprecate and rename onLoadingChanged to onIsLoadingChanged for consistency.
* Make `MediaSourceEventListener.LoadEventInfo` and
`MediaSourceEventListener.MediaLoadData` top-level classes.
* Rename `MediaCodecRenderer.onOutputFormatChanged` to

View File

@ -1202,7 +1202,11 @@ import java.util.concurrent.TimeoutException;
playbackInfo.trackGroups, playbackInfo.trackSelectorResult.selections));
}
if (isLoadingChanged) {
invokeAll(listenerSnapshot, listener -> listener.onLoadingChanged(playbackInfo.isLoading));
invokeAll(
listenerSnapshot,
listener -> {
listener.onIsLoadingChanged(playbackInfo.isLoading);
});
}
if (playbackStateChanged) {
invokeAll(

View File

@ -407,6 +407,13 @@ public interface Player {
*
* @param isLoading Whether the source is currently being loaded.
*/
@SuppressWarnings("deprecation")
default void onIsLoadingChanged(boolean isLoading) {
onLoadingChanged(isLoading);
}
/** @deprecated Use {@link #onIsLoadingChanged(boolean)} instead. */
@Deprecated
default void onLoadingChanged(boolean isLoading) {}
/**

View File

@ -1931,7 +1931,7 @@ public class SimpleExoPlayer extends BasePlayer
// Player.EventListener implementation.
@Override
public void onLoadingChanged(boolean isLoading) {
public void onIsLoadingChanged(boolean isLoading) {
if (priorityTaskManager != null) {
if (isLoading && !isPriorityTaskManagerRegistered) {
priorityTaskManager.add(C.PRIORITY_PLAYBACK);

View File

@ -431,10 +431,10 @@ public class AnalyticsCollector
}
@Override
public final void onLoadingChanged(boolean isLoading) {
public final void onIsLoadingChanged(boolean isLoading) {
EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
for (AnalyticsListener listener : listeners) {
listener.onLoadingChanged(eventTime, isLoading);
listener.onIsLoadingChanged(eventTime, isLoading);
}
}

View File

@ -227,6 +227,13 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param isLoading Whether the player is loading.
*/
@SuppressWarnings("deprecation")
default void onIsLoadingChanged(EventTime eventTime, boolean isLoading) {
onLoadingChanged(eventTime, isLoading);
}
/** @deprecated Use {@link #onIsLoadingChanged(EventTime, boolean)} instead. */
@Deprecated
default void onLoadingChanged(EventTime eventTime, boolean isLoading) {}
/**

View File

@ -91,7 +91,7 @@ public class EventLogger implements AnalyticsListener {
// AnalyticsListener
@Override
public void onLoadingChanged(EventTime eventTime, boolean isLoading) {
public void onIsLoadingChanged(EventTime eventTime, boolean isLoading) {
logd(eventTime, "loading", Boolean.toString(isLoading));
}

View File

@ -1393,7 +1393,7 @@ public final class AnalyticsCollectorTest {
}
@Override
public void onLoadingChanged(EventTime eventTime, boolean isLoading) {
public void onIsLoadingChanged(EventTime eventTime, boolean isLoading) {
reportedEvents.add(new ReportedEvent(EVENT_LOADING_CHANGED, eventTime));
}

View File

@ -984,7 +984,7 @@ public abstract class Action {
/**
* Waits for a specified loading state, returning either immediately or after a call to {@link
* Player.EventListener#onLoadingChanged(boolean)}.
* Player.EventListener#onIsLoadingChanged(boolean)}.
*/
public static final class WaitForIsLoading extends Action {
@ -1015,7 +1015,7 @@ public abstract class Action {
player.addListener(
new Player.EventListener() {
@Override
public void onLoadingChanged(boolean isLoading) {
public void onIsLoadingChanged(boolean isLoading) {
if (targetIsLoading == isLoading) {
player.removeListener(this);
nextAction.schedule(player, trackSelector, surface, handler);