Merge pull request #1117 from lingokids/master

Android - Keep screen on
This commit is contained in:
Hampton Maxwell 2018-08-05 17:35:15 -07:00 committed by GitHub
commit 7854a23d13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.WindowManager;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import android.webkit.CookieManager; import android.webkit.CookieManager;
@ -96,7 +97,6 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
private Handler videoControlHandler = new Handler(); private Handler videoControlHandler = new Handler();
private MediaController mediaController; private MediaController mediaController;
private String mSrcUriString = null; private String mSrcUriString = null;
private String mSrcType = "mp4"; private String mSrcType = "mp4";
private ReadableMap mRequestHeaders = null; private ReadableMap mRequestHeaders = null;
@ -359,7 +359,6 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
} }
public void setPausedModifier(final boolean paused) { public void setPausedModifier(final boolean paused) {
mPaused = paused; mPaused = paused;
if (!mMediaPlayerValid) { if (!mMediaPlayerValid) {
@ -382,6 +381,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
mProgressUpdateHandler.post(mProgressUpdateRunnable); mProgressUpdateHandler.post(mProgressUpdateRunnable);
} }
} }
setKeepScreenOn(!mPaused);
} }
// reduces the volume based on stereoPan // reduces the volume based on stereoPan
@ -501,7 +501,6 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
this.mUseNativeControls = controls; this.mUseNativeControls = controls;
} }
@Override @Override
public void onPrepared(MediaPlayer mp) { public void onPrepared(MediaPlayer mp) {
@ -625,21 +624,22 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
@Override @Override
public void onCompletion(MediaPlayer mp) { public void onCompletion(MediaPlayer mp) {
isCompleted = true; isCompleted = true;
mEventEmitter.receiveEvent(getId(), Events.EVENT_END.toString(), null); mEventEmitter.receiveEvent(getId(), Events.EVENT_END.toString(), null);
if (!mRepeat) {
setKeepScreenOn(false);
}
} }
@Override @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
mMediaPlayerValid = false; mMediaPlayerValid = false;
super.onDetachedFromWindow(); super.onDetachedFromWindow();
setKeepScreenOn(false);
} }
@Override @Override
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
super.onAttachedToWindow(); super.onAttachedToWindow();
if(mMainVer>0) { if(mMainVer>0) {
@ -648,7 +648,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
else { else {
setSrc(mSrcUriString, mSrcType, mSrcIsNetwork, mSrcIsAsset, mRequestHeaders); setSrc(mSrcUriString, mSrcType, mSrcIsNetwork, mSrcIsAsset, mRequestHeaders);
} }
setKeepScreenOn(true);
} }
@Override @Override