[ANDROID] Fix video not playing if no adTagUrl passed
This commit is contained in:
parent
915e31a874
commit
c789363c5b
@ -662,15 +662,26 @@ class ReactExoplayerView extends FrameLayout implements
|
||||
private void initializePlayerSource(ReactExoplayerView self, DrmSessionManager drmSessionManager) {
|
||||
ArrayList<MediaSource> mediaSourceList = buildTextSources();
|
||||
MediaSource videoSource = buildMediaSource(self.srcUri, self.extension, drmSessionManager);
|
||||
MediaSource mediaSourceWithAds = null;
|
||||
if (adTagUrl != null) {
|
||||
MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(mediaDataSourceFactory)
|
||||
.setLocalAdInsertionComponents(unusedAdTagUri -> adsLoader, exoPlayerView);
|
||||
DataSpec adTagDataSpec = new DataSpec(adTagUrl);
|
||||
MediaSource mediaSourceWithAds = new AdsMediaSource(videoSource, adTagDataSpec, ImmutableList.of(srcUri, adTagUrl), mediaSourceFactory, adsLoader, exoPlayerView);
|
||||
mediaSourceWithAds = new AdsMediaSource(videoSource, adTagDataSpec, ImmutableList.of(srcUri, adTagUrl), mediaSourceFactory, adsLoader, exoPlayerView);
|
||||
}
|
||||
MediaSource mediaSource;
|
||||
if (mediaSourceList.size() == 0) {
|
||||
if (mediaSourceWithAds != null) {
|
||||
mediaSource = mediaSourceWithAds;
|
||||
} else {
|
||||
mediaSource = videoSource;
|
||||
}
|
||||
} else {
|
||||
if (mediaSourceWithAds != null) {
|
||||
mediaSourceList.add(0, mediaSourceWithAds);
|
||||
} else {
|
||||
mediaSourceList.add(0, videoSource);
|
||||
}
|
||||
MediaSource[] textSourceArray = mediaSourceList.toArray(
|
||||
new MediaSource[mediaSourceList.size()]
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user