Added isAsset same as iOS implementation

This commit is contained in:
Juan Pablo Garcia 2016-01-07 17:34:11 -03:00
parent c449faa3ff
commit 6350d07879
2 changed files with 8 additions and 4 deletions

View File

@ -58,6 +58,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
private String mSrcUriString = null;
private String mSrcType = "mp4";
private boolean mSrcIsNetwork = false;
private boolean mSrcIsAsset = false;
private ScalableType mResizeMode = ScalableType.LEFT_TOP;
private boolean mRepeat = false;
private boolean mPaused = false;
@ -107,10 +108,11 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
}
}
public void setSrc(final String uriString, final String type, final boolean isNetwork) {
public void setSrc(final String uriString, final String type, final boolean isNetwork, final boolean isAsset) {
mSrcUriString = uriString;
mSrcType = type;
mSrcIsNetwork = isNetwork;
mSrcIsAsset = isAsset;
mMediaPlayerValid = false;
mVideoDuration = 0;
@ -120,7 +122,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
mMediaPlayer.reset();
try {
if (isNetwork) {
if (isNetwork || isAsset) {
setDataSource(uriString);
} else {
setRawData(mThemedReactContext.getResources().getIdentifier(
@ -281,6 +283,6 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
setSrc(mSrcUriString, mSrcType, mSrcIsNetwork);
setSrc(mSrcUriString, mSrcType, mSrcIsNetwork, mSrcIsAsset);
}
}

View File

@ -22,6 +22,7 @@ public class ReactVideoViewManager extends SimpleViewManager<ReactVideoView> {
public static final String PROP_SRC_URI = "uri";
public static final String PROP_SRC_TYPE = "type";
public static final String PROP_SRC_IS_NETWORK = "isNetwork";
public static final String PROP_SRC_IS_ASSET = "isAsset";
public static final String PROP_RESIZE_MODE = "resizeMode";
public static final String PROP_REPEAT = "repeat";
public static final String PROP_PAUSED = "paused";
@ -66,7 +67,8 @@ public class ReactVideoViewManager extends SimpleViewManager<ReactVideoView> {
videoView.setSrc(
src.getString(PROP_SRC_URI),
src.getString(PROP_SRC_TYPE),
src.getBoolean(PROP_SRC_IS_NETWORK)
src.getBoolean(PROP_SRC_IS_NETWORK),
src.getBoolean(PROP_SRC_IS_ASSET)
);
}