Skip to content

Commit

Permalink
Merge pull request #1117 from lingokids/master
Browse files Browse the repository at this point in the history
Android - Keep screen on
  • Loading branch information
cobarx authored Aug 6, 2018
2 parents 91194ed + 3a1d819 commit 7854a23
Showing 1 changed file with 7 additions and 7 deletions.
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

0 comments on commit 7854a23

Please sign in to comment.