今天我将 exoplayer 从2.9.5 升级到 2.10.4,在旧版本中一切正常,但在新版本中,他们添加了 AdsLoader.AdViewProvider,我不知道如何实现它。我尽力了,但问题没有解决。我想在 exoplayer 中播放广告。
MediaSource mediaSourceWithAds = new AdsMediaSource(contentMediaSource, mediaDataSourceFactory, adsLoader, new AdsLoader.AdViewProvider() {
@Override
public ViewGroup getAdViewGroup() {
return adFrameLayout;
}
@Override
public View[] getAdOverlayViews() {
return new View[0];
}
});
player.prepare(mediaSourceWithAds);
升级到新版本后出现此异常
java.lang.AbstractMethodError: abstract method "void com.google.android.exoplayer2.source.ads.AdsLoader.start(com.google.android.exoplayer2.source.ads.AdsLoader$EventListener, com.google.android.exoplayer2.source.ads.AdsLoader$AdViewProvider)"
at com.google.android.exoplayer2.source.ads.AdsMediaSource.lambda$prepareSourceInternal$0$AdsMediaSource(AdsMediaSource.java:220)
at com.google.android.exoplayer2.source.ads.-$$Lambda$AdsMediaSource$zcXBZahV9F-k_KJACPO-bl_WWX0.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:180)
at android.app.ActivityThread.main(ActivityThread.java:6950)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:835)