Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot turn the screen off while video is playing

I have a VideoView in my activity, which I use only as a background, with a video on looping mode.

The screen does not go into sleep mode automatically. I tried manually counting the seconds since the last user interactivity, but I was still not able to force the screen to turn off.

I have tried PowerManager, acquiring locks and goToSleep() function, but I still haven't managed to turn my screen off.

like image 759
radu122 Avatar asked Feb 11 '14 12:02

radu122


1 Answers

I know this is an ancient question, but I thought I'd write an answer anyway since this page shows up in Google searches.

I solved the same problem using this code:

videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
    @Override
    public void onPrepared(MediaPlayer mediaPlayer) {
        mediaPlayer.setScreenOnWhilePlaying(false);
    }
});
like image 60
Johan Levin Avatar answered Sep 28 '22 10:09

Johan Levin