[Android] VideoPlayerActivity: pause playback if the lockscreen is displayed
Sébastien Toque
git at videolan.org
Wed Sep 26 20:41:30 CEST 2012
vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Wed Sep 26 20:41:21 2012 +0200| [77e983aa4400d2fdc181a1d18da28864ed38b23f] | committer: Sébastien Toque
VideoPlayerActivity: pause playback if the lockscreen is displayed
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=77e983aa4400d2fdc181a1d18da28864ed38b23f
---
.../videolan/vlc/gui/video/VideoPlayerActivity.java | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
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 f00a962..7e481c4 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -45,6 +45,7 @@ import org.videolan.vlc.widget.SlidingPanel;
import android.annotation.TargetApi;
import android.app.Activity;
+import android.app.KeyguardManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
@@ -382,6 +383,21 @@ public class VideoPlayerActivity extends Activity {
load();
+ /*
+ * if the activity has been paused by pressing the power button,
+ * pressing it again will show the lock screen.
+ * But onResume will also be called, even if vlc-android is still in the background.
+ * To workaround that, pause playback if the lockscreen is displayed
+ */
+ mHandler.postDelayed(new Runnable() {
+ public void run() {
+ if (mLibVLC != null && mLibVLC.isPlaying()) {
+ KeyguardManager km = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
+ if (km.inKeyguardRestrictedInputMode())
+ mLibVLC.pause();
+ }
+ }}, 500);
+
showOverlay();
super.onResume();
More information about the Android
mailing list