[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) {
|
private void initializePlayerSource(ReactExoplayerView self, DrmSessionManager drmSessionManager) {
|
||||||
ArrayList<MediaSource> mediaSourceList = buildTextSources();
|
ArrayList<MediaSource> mediaSourceList = buildTextSources();
|
||||||
MediaSource videoSource = buildMediaSource(self.srcUri, self.extension, drmSessionManager);
|
MediaSource videoSource = buildMediaSource(self.srcUri, self.extension, drmSessionManager);
|
||||||
MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(mediaDataSourceFactory)
|
MediaSource mediaSourceWithAds = null;
|
||||||
.setLocalAdInsertionComponents(unusedAdTagUri -> adsLoader, exoPlayerView);
|
if (adTagUrl != null) {
|
||||||
DataSpec adTagDataSpec = new DataSpec(adTagUrl);
|
MediaSource.Factory mediaSourceFactory = new DefaultMediaSourceFactory(mediaDataSourceFactory)
|
||||||
MediaSource mediaSourceWithAds = new AdsMediaSource(videoSource, adTagDataSpec, ImmutableList.of(srcUri, adTagUrl), mediaSourceFactory, adsLoader, exoPlayerView);
|
.setLocalAdInsertionComponents(unusedAdTagUri -> adsLoader, exoPlayerView);
|
||||||
|
DataSpec adTagDataSpec = new DataSpec(adTagUrl);
|
||||||
|
mediaSourceWithAds = new AdsMediaSource(videoSource, adTagDataSpec, ImmutableList.of(srcUri, adTagUrl), mediaSourceFactory, adsLoader, exoPlayerView);
|
||||||
|
}
|
||||||
MediaSource mediaSource;
|
MediaSource mediaSource;
|
||||||
if (mediaSourceList.size() == 0) {
|
if (mediaSourceList.size() == 0) {
|
||||||
mediaSource = mediaSourceWithAds;
|
if (mediaSourceWithAds != null) {
|
||||||
|
mediaSource = mediaSourceWithAds;
|
||||||
|
} else {
|
||||||
|
mediaSource = videoSource;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mediaSourceList.add(0, mediaSourceWithAds);
|
if (mediaSourceWithAds != null) {
|
||||||
|
mediaSourceList.add(0, mediaSourceWithAds);
|
||||||
|
} else {
|
||||||
|
mediaSourceList.add(0, videoSource);
|
||||||
|
}
|
||||||
MediaSource[] textSourceArray = mediaSourceList.toArray(
|
MediaSource[] textSourceArray = mediaSourceList.toArray(
|
||||||
new MediaSource[mediaSourceList.size()]
|
new MediaSource[mediaSourceList.size()]
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user