explicitly release androids mediaplayer when component is unmounted (#319)
This commit is contained in:
parent
83dd4c3ba9
commit
6dfbb1e2a5
@ -148,6 +148,17 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanupMediaPlayerResources() {
|
||||
if ( mediaController != null ) {
|
||||
mediaController.hide();
|
||||
}
|
||||
if ( mMediaPlayer != null ) {
|
||||
mMediaPlayerValid = false;
|
||||
mMediaPlayer.stop();
|
||||
mMediaPlayer.release();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSrc(final String uriString, final String type, final boolean isNetwork, final boolean isAsset) {
|
||||
|
||||
mSrcUriString = uriString;
|
||||
|
@ -43,6 +43,12 @@ public class ReactVideoViewManager extends SimpleViewManager<ReactVideoView> {
|
||||
return new ReactVideoView(themedReactContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDropViewInstance(ReactVideoView view) {
|
||||
super.onDropViewInstance(view);
|
||||
view.cleanupMediaPlayerResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Map getExportedCustomDirectEventTypeConstants() {
|
||||
|
Loading…
Reference in New Issue
Block a user