fix(android): ads build and enable ads in android sample (#3376)
* fix: refactor androidx core version management * chore: fix missing import rework for media3 * fix: enable IMA in sample * chore: rename stub fie * chore: code review, fix variable name * chore: reorder imports * chore: fix linking in sample * chore: fix stub management * chore: few cleans and ensure we don't use ima is disabled --------- Co-authored-by: olivier <olivier.bouillet@ifeelsmart.com>
This commit is contained in:
@@ -61,6 +61,7 @@ import androidx.media3.exoplayer.drm.FrameworkMediaDrm;
|
||||
import androidx.media3.exoplayer.drm.HttpMediaDrmCallback;
|
||||
import androidx.media3.exoplayer.drm.UnsupportedDrmException;
|
||||
import androidx.media3.exoplayer.hls.HlsMediaSource;
|
||||
import androidx.media3.exoplayer.ima.ImaAdsLoader;
|
||||
import androidx.media3.exoplayer.mediacodec.MediaCodecInfo;
|
||||
import androidx.media3.exoplayer.mediacodec.MediaCodecUtil;
|
||||
import androidx.media3.exoplayer.smoothstreaming.DefaultSsChunkSource;
|
||||
@@ -103,7 +104,6 @@ import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.google.ads.interactivemedia.v3.api.AdEvent;
|
||||
import com.google.android.exoplayer2.ext.ima.ImaAdsLoader;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.net.CookieHandler;
|
||||
@@ -617,10 +617,14 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||
.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF);
|
||||
|
||||
// Create an AdsLoader.
|
||||
adsLoader = new ImaAdsLoader.Builder(themedReactContext).setAdEventListener(this).build();
|
||||
adsLoader = new ImaAdsLoader.Builder(themedReactContext)
|
||||
.setAdEventListener(this)
|
||||
.build();
|
||||
|
||||
MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(mediaDataSourceFactory)
|
||||
.setLocalAdInsertionComponents(unusedAdTagUri -> adsLoader, exoPlayerView);
|
||||
DefaultMediaSourceFactory mediaSourceFactory = new DefaultMediaSourceFactory(mediaDataSourceFactory);
|
||||
if (adsLoader != null) {
|
||||
mediaSourceFactory.setLocalAdInsertionComponents(unusedAdTagUri -> adsLoader, exoPlayerView);
|
||||
}
|
||||
|
||||
player = new ExoPlayer.Builder(getContext(), renderersFactory)
|
||||
.setTrackSelector(self.trackSelector)
|
||||
@@ -665,8 +669,8 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||
ArrayList<MediaSource> mediaSourceList = buildTextSources();
|
||||
MediaSource videoSource = buildMediaSource(self.srcUri, self.extension, drmSessionManager, cropStartMs, cropEndMs);
|
||||
MediaSource mediaSourceWithAds = null;
|
||||
if (adTagUrl != null) {
|
||||
MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(mediaDataSourceFactory)
|
||||
if (adTagUrl != null && adsLoader != null) {
|
||||
DefaultMediaSourceFactory mediaSourceFactory = new DefaultMediaSourceFactory(mediaDataSourceFactory)
|
||||
.setLocalAdInsertionComponents(unusedAdTagUri -> adsLoader, exoPlayerView);
|
||||
DataSpec adTagDataSpec = new DataSpec(adTagUrl);
|
||||
mediaSourceWithAds = new AdsMediaSource(videoSource, adTagDataSpec, ImmutableList.of(srcUri, adTagUrl), mediaSourceFactory, adsLoader, exoPlayerView);
|
||||
|
@@ -1,65 +0,0 @@
|
||||
package com.google.android.exoplayer2.ext.ima;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.AdViewProvider;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.datasource.DataSpec;
|
||||
import androidx.media3.exoplayer.ExoPlayer;
|
||||
import androidx.media3.exoplayer.source.ads.AdsLoader;
|
||||
import androidx.media3.exoplayer.source.ads.AdsMediaSource;
|
||||
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ImaAdsLoader implements AdsLoader {
|
||||
public void setPlayer(ExoPlayer player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayer(@Nullable Player player) {
|
||||
|
||||
}
|
||||
|
||||
public void release() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSupportedContentTypes(int... ints) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(AdsMediaSource adsMediaSource, DataSpec dataSpec, Object adsId, AdViewProvider adViewProvider, EventListener eventListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(AdsMediaSource adsMediaSource, EventListener eventListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePrepareComplete(AdsMediaSource adsMediaSource, int i, int i1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePrepareError(AdsMediaSource adsMediaSource, int i, int i1, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public Builder(ThemedReactContext themedReactContext) {
|
||||
|
||||
}
|
||||
|
||||
public Builder setAdEventListener(Object reactExoplayerView) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ImaAdsLoader build() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user