Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android - Keep screen on #1117

Merged
merged 8 commits into from
Aug 6, 2018
14 changes: 7 additions & 7 deletions android/src/main/java/com/brentvatne/react/ReactVideoView.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.os.Handler;
import android.util.Log;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.view.View;
import android.view.Window;
import android.webkit.CookieManager;
Expand Down Expand Up @@ -96,7 +97,6 @@ public String toString() {
private Handler videoControlHandler = new Handler();
private MediaController mediaController;


private String mSrcUriString = null;
private String mSrcType = "mp4";
private ReadableMap mRequestHeaders = null;
Expand Down Expand Up @@ -359,7 +359,6 @@ public void setRepeatModifier(final boolean repeat) {
}

public void setPausedModifier(final boolean paused) {

mPaused = paused;

if (!mMediaPlayerValid) {
Expand All @@ -382,6 +381,7 @@ public void setPausedModifier(final boolean paused) {
mProgressUpdateHandler.post(mProgressUpdateRunnable);
}
}
setKeepScreenOn(!mPaused);
}

// reduces the volume based on stereoPan
Expand Down Expand Up @@ -501,7 +501,6 @@ public void setControls(boolean controls) {
this.mUseNativeControls = controls;
}


@Override
public void onPrepared(MediaPlayer mp) {

Expand Down Expand Up @@ -625,21 +624,22 @@ public int getAudioSessionId() {

@Override
public void onCompletion(MediaPlayer mp) {

isCompleted = true;
mEventEmitter.receiveEvent(getId(), Events.EVENT_END.toString(), null);
if (!mRepeat) {
setKeepScreenOn(false);
}
}

@Override
protected void onDetachedFromWindow() {

mMediaPlayerValid = false;
super.onDetachedFromWindow();
setKeepScreenOn(false);
}

@Override
protected void onAttachedToWindow() {

super.onAttachedToWindow();

if(mMainVer>0) {
Expand All @@ -648,7 +648,7 @@ protected void onAttachedToWindow() {
else {
setSrc(mSrcUriString, mSrcType, mSrcIsNetwork, mSrcIsAsset, mRequestHeaders);
}

setKeepScreenOn(true);
}

@Override
Expand Down