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 fcddb28c..931bc9fe 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -540,8 +540,15 @@ class ReactExoplayerView extends FrameLayout implements // Initialize handler to run on the main thread activity.runOnUiThread(new Runnable() { public void run() { - // Source initialization must run on the main thread - initializePlayerSource(self, drmSessionManager); + try { + // Source initialization must run on the main thread + initializePlayerSource(self, drmSessionManager); + } catch (Exception ex) { + self.playerNeedsSource = true; + Log.e("ExoPlayer Exception", "Failed to initialize Player!"); + Log.e("ExoPlayer Exception", ex.toString()); + self.eventEmitter.error(ex.toString(), ex, "1001"); + } } }); } @@ -620,7 +627,7 @@ class ReactExoplayerView extends FrameLayout implements private void initializePlayerSource(ReactExoplayerView self, DrmSessionManager drmSessionManager) { ArrayList mediaSourceList = buildTextSources(); - MediaSource videoSource = buildMediaSource(srcUri, extension, drmSessionManager); + MediaSource videoSource = buildMediaSource(self.srcUri, self.extension, drmSessionManager); MediaSource mediaSource; if (mediaSourceList.size() == 0) { mediaSource = videoSource;