14
14
import android .view .Window ;
15
15
import android .view .accessibility .CaptioningManager ;
16
16
import android .widget .FrameLayout ;
17
- import android .widget .ImageButton ;
18
- import android .widget .ImageView ;
17
+ import android .view .WindowManager ;
19
18
20
19
import com .brentvatne .react .R ;
21
20
import com .brentvatne .receiver .AudioBecomingNoisyReceiver ;
@@ -223,11 +222,13 @@ private void createViews() {
223
222
protected void onAttachedToWindow () {
224
223
super .onAttachedToWindow ();
225
224
initializePlayer ();
225
+ setKeepScreenOn (true );
226
226
}
227
227
228
228
@ Override
229
229
protected void onDetachedFromWindow () {
230
230
super .onDetachedFromWindow ();
231
+ setKeepScreenOn (false );
231
232
/* We want to be able to continue playing audio when switching tabs.
232
233
* Leave this here in case it causes issues.
233
234
*/
@@ -604,9 +605,6 @@ private void startPlayback() {
604
605
} else {
605
606
initializePlayer ();
606
607
}
607
- if (!disableFocus ) {
608
- setKeepScreenOn (true );
609
- }
610
608
}
611
609
612
610
private void pausePlayback () {
@@ -615,7 +613,6 @@ private void pausePlayback() {
615
613
setPlayWhenReady (false );
616
614
}
617
615
}
618
- setKeepScreenOn (false );
619
616
}
620
617
621
618
private void stopPlayback () {
@@ -1188,6 +1185,7 @@ public void setPausedModifier(boolean paused) {
1188
1185
} else {
1189
1186
pausePlayback ();
1190
1187
}
1188
+ setKeepScreenOn (!isPaused );
1191
1189
}
1192
1190
}
1193
1191
0 commit comments