From c56fd2d9084bda9f8b3f0e5aa9a86b2ec7b15502 Mon Sep 17 00:00:00 2001 From: Deon Nicholas Date: Tue, 21 Mar 2017 13:24:46 -0700 Subject: [PATCH] [Android] App crash when unmounting video (#533) * Upgrade to ScalableVideoView version 1.0.4 * Fix bug in cleanupMediaPlayerResources * Fix VideoView on Android --- android/build.gradle | 2 +- .../src/main/java/com/brentvatne/react/ReactVideoView.java | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 32ac878a..5c04d95b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -17,5 +17,5 @@ android { dependencies { provided 'com.facebook.react:react-native:+' - compile 'com.yqritc:android-scalablevideoview:1.0.1' + compile 'com.yqritc:android-scalablevideoview:1.0.4' } diff --git a/android/src/main/java/com/brentvatne/react/ReactVideoView.java b/android/src/main/java/com/brentvatne/react/ReactVideoView.java index 0a194c90..5a27bdf2 100644 --- a/android/src/main/java/com/brentvatne/react/ReactVideoView.java +++ b/android/src/main/java/com/brentvatne/react/ReactVideoView.java @@ -194,8 +194,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP } if ( mMediaPlayer != null ) { mMediaPlayerValid = false; - mMediaPlayer.stop(); - mMediaPlayer.release(); + release(); } } @@ -296,9 +295,8 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP event.putMap(ReactVideoViewManager.PROP_SRC, src); mEventEmitter.receiveEvent(getId(), Events.EVENT_LOAD_START.toString(), event); - // not async to prevent random crashes on Android playback from local resource due to race conditions try { - prepare(this); + prepareAsync(this); } catch (Exception e) { e.printStackTrace(); }