mirror of
https://github.com/androidx/media.git
synced 2025-05-05 06:30:24 +08:00
Remove player listener on the application thread of the player
PiperOrigin-RevId: 497183220 (cherry picked from commit 965606f7a7626b95087845191f9b6d4c33ced2e7)
This commit is contained in:
parent
1e97da9472
commit
25c964d71d
@ -36,6 +36,7 @@ import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Pair;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.IntDef;
|
||||
@ -493,7 +494,8 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
||||
this.applicationAdEventListener = applicationAdEventListener;
|
||||
this.applicationAdErrorListener = applicationAdErrorListener;
|
||||
componentListener = new ComponentListener();
|
||||
mainHandler = Util.createHandlerForCurrentLooper();
|
||||
Assertions.checkArgument(player.getApplicationLooper() == Looper.getMainLooper());
|
||||
mainHandler = new Handler(Looper.getMainLooper());
|
||||
Uri streamRequestUri = checkNotNull(mediaItem.localConfiguration).uri;
|
||||
isLiveStream = ImaServerSideAdInsertionUriBuilder.isLiveStream(streamRequestUri);
|
||||
adsId = ImaServerSideAdInsertionUriBuilder.getAdsId(streamRequestUri);
|
||||
@ -570,8 +572,11 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
||||
super.releaseSourceInternal();
|
||||
if (loader != null) {
|
||||
loader.release();
|
||||
mainHandler.post(
|
||||
() -> {
|
||||
player.removeListener(componentListener);
|
||||
mainHandler.post(() -> setStreamManager(/* streamManager= */ null));
|
||||
setStreamManager(/* streamManager= */ null);
|
||||
});
|
||||
loader = null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user