Skip to content

Commit

Permalink
Release player if native source changes
Browse files Browse the repository at this point in the history
  • Loading branch information
armands-malejevs committed Apr 12, 2023
1 parent a35007e commit b78831f
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public class ReactExoplayerView extends FrameLayout implements
// DASH Offline Source
public static MediaSource offlineMediaSource;
public static CacheDataSource.Factory offlineCacheDataSourceFactory;
private MediaSource activeMediaSource = null;

// React
private final ThemedReactContext themedReactContext;
Expand Down Expand Up @@ -860,6 +861,10 @@ private void initializePlayerSource(ReactExoplayerView self, DrmSessionManager d
ArrayList<MediaSource> mediaSourceList = buildTextSources();
MediaSource videoSource = buildMediaSource(self.srcUri, self.extension, drmSessionManager);

if (videoSource !== activeMediaSource && isUriNativeSource(self.srcUri)) {
releasePlayer();
}
activeMediaSource = videoSource;
videoSource.addEventListener(this.mainHandler, this.mediaSourceEventListener);

MediaSource mediaSource;
Expand Down Expand Up @@ -891,6 +896,7 @@ private void initializePlayerSource(ReactExoplayerView self, DrmSessionManager d
player.seekTo(0, startPosition);
haveResumePosition = true;
}

player.prepare(mediaSource, !haveResumePosition, false);
playerNeedsSource = false;

Expand Down

0 comments on commit b78831f

Please sign in to comment.