prevent the screen from turning off while playing a video

This commit is contained in:
tibbi 2016-09-25 23:16:34 +02:00
parent e57242374b
commit 08f7a57c55
1 changed files with 3 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
@ -199,12 +200,14 @@ public class VideoFragment extends ViewPagerFragment
}
mPlayOutline.setImageDrawable(null);
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} else {
if (mMediaPlayer != null) {
mMediaPlayer.pause();
}
mPlayOutline.setImageDrawable(getResources().getDrawable(R.mipmap.play_outline_big));
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}