load new source if it is different (#502)

This commit is contained in:
Andrew Jack 2017-03-21 20:26:23 +00:00 committed by Matt Apperson
parent 087adef1b9
commit 79a9ea540d
2 changed files with 19 additions and 1 deletions

View File

@ -7,7 +7,6 @@ import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSourceFactory;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.util.Util;

View File

@ -520,20 +520,39 @@ class ReactExoplayerView extends FrameLayout implements
public void setSrc(final Uri uri, final String extension) {
if (uri != null) {
boolean isOriginalSourceNull = srcUri == null;
boolean isSourceEqual = uri.equals(srcUri);
this.srcUri = uri;
this.extension = extension;
this.mediaDataSourceFactory = DataSourceUtil.getDefaultDataSourceFactory(getContext(), BANDWIDTH_METER);
if (!isOriginalSourceNull && !isSourceEqual) {
reloadSource();
}
}
}
public void setRawSrc(final Uri uri, final String extension) {
if (uri != null) {
boolean isOriginalSourceNull = srcUri == null;
boolean isSourceEqual = uri.equals(srcUri);
this.srcUri = uri;
this.extension = extension;
this.mediaDataSourceFactory = DataSourceUtil.getRawDataSourceFactory(getContext());
if (!isOriginalSourceNull && !isSourceEqual) {
reloadSource();
}
}
}
private void reloadSource() {
playerNeedsSource = true;
initializePlayer();
}
public void setResizeModeModifier(@ResizeMode.Mode int resizeMode) {
exoPlayerView.setResizeMode(resizeMode);
}