Skip to content

Commit

Permalink
Add setKeepScreenOn to Expo player
Browse files Browse the repository at this point in the history
  • Loading branch information
zhulduz committed Oct 16, 2019
1 parent b97663e commit 78a450b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.view.Window;
import android.view.accessibility.CaptioningManager;
import android.widget.FrameLayout;
import android.view.WindowManager;

import com.brentvatne.react.R;
import com.brentvatne.receiver.AudioBecomingNoisyReceiver;
Expand Down Expand Up @@ -209,11 +210,13 @@ private void createViews() {
protected void onAttachedToWindow() {
super.onAttachedToWindow();
initializePlayer();
setKeepScreenOn(true);
}

@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
setKeepScreenOn(false);
/* We want to be able to continue playing audio when switching tabs.
* Leave this here in case it causes issues.
*/
Expand Down Expand Up @@ -524,9 +527,6 @@ private void startPlayback() {
} else {
initializePlayer();
}
if (!disableFocus) {
setKeepScreenOn(true);
}
}

private void pausePlayback() {
Expand All @@ -535,7 +535,6 @@ private void pausePlayback() {
setPlayWhenReady(false);
}
}
setKeepScreenOn(false);
}

private void stopPlayback() {
Expand Down Expand Up @@ -1099,6 +1098,7 @@ public void setPausedModifier(boolean paused) {
} else {
pausePlayback();
}
setKeepScreenOn(!isPaused);
}
}

Expand Down

0 comments on commit 78a450b

Please sign in to comment.