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 759989ef..2022c108 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -537,13 +537,13 @@ class ReactExoplayerView extends FrameLayout implements @Override public void run () { // Source initialization must run on the main thread - initializePlayerSource(self, drmSessionManager, srcUri); + initializePlayerSource(self, drmSessionManager); } }); } }); - } else { - initializePlayerSource(self, null, srcUri); + } else if (srcUri != null) { + initializePlayerSource(self, null); } @@ -560,8 +560,8 @@ class ReactExoplayerView extends FrameLayout implements private void initializePlayerCore(ReactExoplayerView self) { ExoTrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(); - self.trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); - self.trackSelector.setParameters(self.trackSelector.buildUponParameters() + trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); + trackSelector.setParameters(trackSelector.buildUponParameters() .setMaxVideoBitrate(maxBitRate == 0 ? Integer.MAX_VALUE : maxBitRate)); DefaultAllocator allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE); @@ -579,21 +579,21 @@ class ReactExoplayerView extends FrameLayout implements DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(getContext()) .setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF); - self.player = new SimpleExoPlayer.Builder(getContext(), renderersFactory) + player = new SimpleExoPlayer.Builder(getContext(), renderersFactory) .setTrackSelector​(trackSelector) .setBandwidthMeter(bandwidthMeter) .setLoadControl(loadControl) .build(); - self.player.addListener(self); - self.player.addMetadataOutput(self); - self.exoPlayerView.setPlayer(player); - self.audioBecomingNoisyReceiver.setListener(self); - self.bandwidthMeter.addEventListener(new Handler(), self); + player.addListener(self); + player.addMetadataOutput(self); + exoPlayerView.setPlayer(player); + audioBecomingNoisyReceiver.setListener(self); + bandwidthMeter.addEventListener(new Handler(), self); setPlayWhenReady(!isPaused); - self.playerNeedsSource = true; + playerNeedsSource = true; PlaybackParameters params = new PlaybackParameters(rate, 1f); - self.player.setPlaybackParameters(params); + player.setPlaybackParameters(params); } private DrmSessionManager initializePlayerDrm(ReactExoplayerView self) { @@ -613,9 +613,9 @@ class ReactExoplayerView extends FrameLayout implements return drmSessionManager; } - private void initializePlayerSource(ReactExoplayerView self, DrmSessionManager drmSessionManager, Uri srcUri) { + private void initializePlayerSource(ReactExoplayerView self, DrmSessionManager drmSessionManager) { ArrayList mediaSourceList = buildTextSources(); - MediaSource videoSource = self.buildMediaSource(srcUri, self.extension, drmSessionManager); + MediaSource videoSource = buildMediaSource(srcUri, extension, drmSessionManager); MediaSource mediaSource; if (mediaSourceList.size() == 0) { mediaSource = videoSource;