mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Move BasePreloadManager.Listener to a top level PreloadManagerListener
PiperOrigin-RevId: 702351887
This commit is contained in:
parent
d72453a6cd
commit
148641f049
@ -22,6 +22,8 @@
|
|||||||
2000 ms respectively.
|
2000 ms respectively.
|
||||||
* Add `MediaExtractorCompat`, a new class that provides equivalent
|
* Add `MediaExtractorCompat`, a new class that provides equivalent
|
||||||
functionality to platform `MediaExtractor`.
|
functionality to platform `MediaExtractor`.
|
||||||
|
* Move `BasePreloadManager.Listener` to a top level
|
||||||
|
`PreloadManagerListener`.
|
||||||
* Transformer:
|
* Transformer:
|
||||||
* Update parameters of `VideoFrameProcessor.registerInputStream` and
|
* Update parameters of `VideoFrameProcessor.registerInputStream` and
|
||||||
`VideoFrameProcessor.Listener.onInputStreamRegistered` to use `Format`.
|
`VideoFrameProcessor.Listener.onInputStreamRegistered` to use `Format`.
|
||||||
|
@ -62,21 +62,11 @@ public abstract class BasePreloadManager<T> {
|
|||||||
public abstract BasePreloadManager<T> build();
|
public abstract BasePreloadManager<T> build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Listener for events in a preload manager. */
|
|
||||||
public interface Listener {
|
|
||||||
|
|
||||||
/** Called when the given {@link MediaItem} has completed preloading. */
|
|
||||||
void onCompleted(MediaItem mediaItem);
|
|
||||||
|
|
||||||
/** Called when an {@linkplain PreloadException error} occurs. */
|
|
||||||
void onError(PreloadException exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Object lock;
|
private final Object lock;
|
||||||
protected final Comparator<T> rankingDataComparator;
|
protected final Comparator<T> rankingDataComparator;
|
||||||
private final TargetPreloadStatusControl<T> targetPreloadStatusControl;
|
private final TargetPreloadStatusControl<T> targetPreloadStatusControl;
|
||||||
private final MediaSource.Factory mediaSourceFactory;
|
private final MediaSource.Factory mediaSourceFactory;
|
||||||
private final ListenerSet<Listener> listeners;
|
private final ListenerSet<PreloadManagerListener> listeners;
|
||||||
private final Map<MediaItem, MediaSourceHolder> mediaItemMediaSourceHolderMap;
|
private final Map<MediaItem, MediaSourceHolder> mediaItemMediaSourceHolderMap;
|
||||||
private final Handler applicationHandler;
|
private final Handler applicationHandler;
|
||||||
|
|
||||||
@ -103,26 +93,26 @@ public abstract class BasePreloadManager<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a {@link Listener} to listen to the preload events.
|
* Adds a {@link PreloadManagerListener} to listen to the preload events.
|
||||||
*
|
*
|
||||||
* <p>This method can be called from any thread.
|
* <p>This method can be called from any thread.
|
||||||
*/
|
*/
|
||||||
public void addListener(Listener listener) {
|
public void addListener(PreloadManagerListener listener) {
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a {@link Listener}.
|
* Removes a {@link PreloadManagerListener}.
|
||||||
*
|
*
|
||||||
* @throws IllegalStateException If this method is called from the wrong thread.
|
* @throws IllegalStateException If this method is called from the wrong thread.
|
||||||
*/
|
*/
|
||||||
public void removeListener(Listener listener) {
|
public void removeListener(PreloadManagerListener listener) {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all the {@linkplain Listener listeners}.
|
* Clears all the {@linkplain PreloadManagerListener listeners}.
|
||||||
*
|
*
|
||||||
* @throws IllegalStateException If this method is called from the wrong thread.
|
* @throws IllegalStateException If this method is called from the wrong thread.
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 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
|
||||||
|
*
|
||||||
|
* https://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 androidx.media3.exoplayer.source.preload;
|
||||||
|
|
||||||
|
import androidx.media3.common.MediaItem;
|
||||||
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for events in a preload manager.
|
||||||
|
*
|
||||||
|
* <p>All methods have no-op default implementations to allow selective overrides.
|
||||||
|
*/
|
||||||
|
@UnstableApi
|
||||||
|
public interface PreloadManagerListener {
|
||||||
|
|
||||||
|
/** Called when the given {@link MediaItem} has completed preloading. */
|
||||||
|
default void onCompleted(MediaItem mediaItem) {}
|
||||||
|
|
||||||
|
/** Called when an {@linkplain PreloadException error} occurs. */
|
||||||
|
default void onError(PreloadException exception) {}
|
||||||
|
}
|
@ -902,7 +902,7 @@ public class DefaultPreloadManagerTest {
|
|||||||
preloadThread.quit();
|
preloadThread.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TestPreloadManagerListener implements BasePreloadManager.Listener {
|
private static class TestPreloadManagerListener implements PreloadManagerListener {
|
||||||
|
|
||||||
public final List<MediaItem> onCompletedMediaItemRecords;
|
public final List<MediaItem> onCompletedMediaItemRecords;
|
||||||
public final List<PreloadException> onErrorPreloadExceptionRecords;
|
public final List<PreloadException> onErrorPreloadExceptionRecords;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user