[Android] Set keep screen flag on root video player view

Geoffrey Métais git at videolan.org
Mon Dec 14 11:55:59 CET 2015


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Dec 14 11:54:51 2015 +0100| [40fe3690b6e0c178544197937bde4675bbc29232] | committer: Geoffrey Métais

Set keep screen flag on root video player view

> https://code.videolan.org/videolan/vlc-android/commit/40fe3690b6e0c178544197937bde4675bbc29232
---

 vlc-android/res/layout/player.xml                              |  7 ++++---
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java    | 10 ++++++----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/vlc-android/res/layout/player.xml b/vlc-android/res/layout/player.xml
index 79b382d..266891b 100644
--- a/vlc-android/res/layout/player.xml
+++ b/vlc-android/res/layout/player.xml
@@ -1,8 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/player_root"
     android:layout_width="fill_parent"
-    android:layout_height="fill_parent" >
+    android:layout_height="fill_parent"
+    android:keepScreenOn="true" >
 
     <!--
      the double FrameLayout is necessary here to do cropping on the bottom right
@@ -25,8 +27,7 @@
             <SurfaceView
                 android:id="@+id/player_surface"
                 android:layout_width="1dp"
-                android:layout_height="1dp"
-                android:keepScreenOn="true" />
+                android:layout_height="1dp" />
 
             <SurfaceView
                 android:id="@+id/subtitles_surface"
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 6f00bc4..14b4c30 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -168,6 +168,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     private PlaybackService mService;
     private SurfaceView mSurfaceView = null;
     private SurfaceView mSubtitlesSurfaceView = null;
+    private View mRootView;
     private FrameLayout mSurfaceFrame;
     private MediaRouter mMediaRouter;
     private MediaRouter.SimpleCallback mMediaRouterCallback;
@@ -371,6 +372,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mActionBar.setDisplayShowCustomEnabled(true);
         mActionBar.setCustomView(R.layout.player_action_bar);
 
+        mRootView = findViewById(R.id.player_root);
         mActionBarView = (ViewGroup) mActionBar.getCustomView();
 
         mTitle = (TextView) mActionBarView.findViewById(R.id.player_overlay_title);
@@ -778,7 +780,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         if (mMediaRouter != null)
             mediaRouterAddCallback(true);
 
-        mSurfaceView.setKeepScreenOn(true);
+        mRootView.setKeepScreenOn(true);
     }
 
     @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@@ -850,7 +852,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
 
     private void cleanUI() {
 
-        mSurfaceView.setKeepScreenOn(false);
+        mRootView.setKeepScreenOn(false);
 
         if (mDetector != null) {
             mDetector.setOnDoubleTapListener(null);
@@ -2653,7 +2655,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
      */
     private void play() {
         mService.play();
-        mSurfaceView.setKeepScreenOn(true);
+        mRootView.setKeepScreenOn(true);
     }
 
     /**
@@ -2661,7 +2663,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
      */
     private void pause() {
         mService.pause();
-        mSurfaceView.setKeepScreenOn(false);
+        mRootView.setKeepScreenOn(false);
     }
 
     /*



More information about the Android mailing list