How can I prevent screen turning off or entering ambient mode during video playback?

To avoid draining the battery, an Android device that is left idle quickly falls asleep. On Android TV it might enter Ambient Mode, stopping the video playback.

To prevent this from happening you can either add android:keepScreenOn attribute to your PlayerView, or add FLAG_KEEP_SCREEN_ON to your activity’s window.

You can find more details in the Android Developer Documentation here.