diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/DataSourceUtil.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/DataSourceUtil.java index fa3c1230..0077c3b0 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/DataSourceUtil.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/DataSourceUtil.java @@ -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; 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 96a02cba..b67cc598 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -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); }