From 7a1bc64c0883e2fcd4a742d5e09ed044630ee6c8 Mon Sep 17 00:00:00 2001 From: Olgun Kaya Date: Sun, 1 Aug 2021 14:47:11 +0300 Subject: [PATCH] Since exo add API changed removed the ads media source implementation. --- .../exoplayer/ReactExoplayerView.java | 17 ++--------------- examples/basic/android/app/build.gradle | 2 +- examples/basic/android/settings.gradle | 4 ++-- examples/basic/react-native.config.js | 10 ++++++++++ 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 8e5d7426..930b16ae 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -92,8 +92,7 @@ class ReactExoplayerView extends FrameLayout implements BecomingNoisyListener, AudioManager.OnAudioFocusChangeListener, MetadataOutput, - DefaultDrmSessionEventListener, - AdsMediaSource.MediaSourceFactory { + DefaultDrmSessionEventListener { private static final String TAG = "ReactExoplayerView"; @@ -446,7 +445,7 @@ class ReactExoplayerView extends FrameLayout implements player = ExoPlayerFactory.newSimpleInstance(getContext(), renderersFactory, trackSelector, defaultLoadControl, drmSessionManager, bandwidthMeter); player.addListener(self); - player.addMetadataOutput(self); + player.addMetadataOutput(self); //a random comment here adsLoader.setPlayer(player); exoPlayerView.setPlayer(player); audioBecomingNoisyReceiver.setListener(self); @@ -508,18 +507,6 @@ class ReactExoplayerView extends FrameLayout implements } return new DefaultDrmSessionManager<>(uuid, FrameworkMediaDrm.newInstance(uuid), drmCallback, null, false, 3); - // AdsMediaSource.MediaSourceFactory implementation. - } - - @Override - public MediaSource createMediaSource(Uri uri) { - return buildMediaSource(uri, extension); - } - - @Override - public int[] getSupportedTypes() { - // IMA does not support Smooth Streaming ads. - return new int[] {C.TYPE_DASH, C.TYPE_HLS, C.TYPE_OTHER}; } private MediaSource buildMediaSource(Uri uri, String overrideExtension) { diff --git a/examples/basic/android/app/build.gradle b/examples/basic/android/app/build.gradle index 082873d4..830aaea5 100644 --- a/examples/basic/android/app/build.gradle +++ b/examples/basic/android/app/build.gradle @@ -135,7 +135,7 @@ android { } dependencies { - implementation project(':react-native-video') + implementation project(':react-native-video-inc-ads') implementation "com.facebook.react:react-native:+" // From node_modules implementation 'org.webkit:android-jsc:+' } diff --git a/examples/basic/android/settings.gradle b/examples/basic/android/settings.gradle index 5fc7fca4..d1ca8c11 100644 --- a/examples/basic/android/settings.gradle +++ b/examples/basic/android/settings.gradle @@ -1,6 +1,6 @@ rootProject.name = 'VideoPlayer' -include ':react-native-video' -project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer') +include ':react-native-video-inc-ads' +project(':react-native-video-inc-ads').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video-inc-ads/android-exoplayer') include ':app' diff --git a/examples/basic/react-native.config.js b/examples/basic/react-native.config.js index cedd9d38..7aee24ce 100644 --- a/examples/basic/react-native.config.js +++ b/examples/basic/react-native.config.js @@ -2,4 +2,14 @@ const fs = require('fs'); const path = require('path'); module.exports = { reactNativePath: fs.realpathSync(path.resolve(require.resolve('react-native-windows/package.json'), '..')), + dependencies: { + 'react-native-video-inc-ads': { + platforms: { + android: { + sourceDir: + '../node_modules/react-native-video-inc-ads/android-exoplayer', + }, + }, + }, + }, };