[Android] App crash when unmounting video (#533)

* Upgrade to ScalableVideoView version 1.0.4

* Fix bug in cleanupMediaPlayerResources

* Fix VideoView on Android
This commit is contained in:
Deon Nicholas 2017-03-21 13:24:46 -07:00 committed by Matt Apperson
parent 9ce1f4b5f4
commit c56fd2d908
2 changed files with 3 additions and 5 deletions

View File

@ -17,5 +17,5 @@ android {
dependencies { dependencies {
provided 'com.facebook.react:react-native:+' provided 'com.facebook.react:react-native:+'
compile 'com.yqritc:android-scalablevideoview:1.0.1' compile 'com.yqritc:android-scalablevideoview:1.0.4'
} }

View File

@ -194,8 +194,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
} }
if ( mMediaPlayer != null ) { if ( mMediaPlayer != null ) {
mMediaPlayerValid = false; mMediaPlayerValid = false;
mMediaPlayer.stop(); release();
mMediaPlayer.release();
} }
} }
@ -296,9 +295,8 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
event.putMap(ReactVideoViewManager.PROP_SRC, src); event.putMap(ReactVideoViewManager.PROP_SRC, src);
mEventEmitter.receiveEvent(getId(), Events.EVENT_LOAD_START.toString(), event); 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 { try {
prepare(this); prepareAsync(this);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }