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

Geoffrey Métais git at videolan.org
Mon Dec 14 12:03:05 CET 2015


vlc-android | branch: 1.7.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Dec 14 12:01:41 2015 +0100| [6b18f175b21284b331e4ed061f3086674fe3f235] | committer: Geoffrey Métais

Set keep screen flag to video player root view

> https://code.videolan.org/videolan/vlc-android/commit/6b18f175b21284b331e4ed061f3086674fe3f235
---

 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 080e2af..b289322 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 c2e8e25..7ab2216 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -158,6 +158,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
 
     private final PlaybackServiceActivity.Helper mHelper = new PlaybackServiceActivity.Helper(this, this);
     private PlaybackService mService;
+    private View mRootView;
     private SurfaceView mSurfaceView = null;
     private SurfaceView mSubtitlesSurfaceView = null;
     private FrameLayout mSurfaceFrame;
@@ -360,6 +361,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mActionBar.setCustomView(R.layout.player_action_bar);
 
         mActionBarView = (ViewGroup) mActionBar.getCustomView();
+        mRootView = findViewById(R.id.player_root);
 
         mTitle = (TextView) mActionBarView.findViewById(R.id.player_overlay_title);
         mSysTime = (TextView) findViewById(R.id.player_overlay_systime);
@@ -733,7 +735,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mSurfacesAttached = true;
         vlcVout.addCallback(this);
         vlcVout.attachViews();
-        mSurfaceView.setKeepScreenOn(true);
+        mRootView.setKeepScreenOn(true);
 
         loadMedia();
 
@@ -766,7 +768,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         vlcVout.removeCallback(this);
         if (mSurfacesAttached)
             vlcVout.detachViews();
-        mSurfaceView.setKeepScreenOn(false);
+        mRootView.setKeepScreenOn(false);
 
         mHandler.removeCallbacksAndMessages(null);
 
@@ -2537,7 +2539,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
      */
     private void play() {
         mService.play();
-        mSurfaceView.setKeepScreenOn(true);
+        mRootView.setKeepScreenOn(true);
     }
 
     /**
@@ -2545,7 +2547,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