[Android] Video player: Pause video on screen lock

Geoffrey Métais git at videolan.org
Mon Feb 11 15:11:18 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 11 15:10:25 2019 +0100| [3c6ed283c504d5fa8b3fee3b0c244d50d3b1c2d6] | committer: Geoffrey Métais

Video player: Pause video on screen lock

> https://code.videolan.org/videolan/vlc-android/commit/3c6ed283c504d5fa8b3fee3b0c244d50d3b1c2d6
---

 vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 5 +++--
 vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt           | 1 -
 2 files changed, 3 insertions(+), 3 deletions(-)

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 e388fb5c4..b00a9c9b9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -341,7 +341,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
         final SharedPreferences.Editor editor = mSettings.edit();
         editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME, -1);
         // Paused flag - per session too, like the subs list.
-        editor.remove(PreferencesActivity.VIDEO_PAUSED);
         editor.apply();
 
         final IntentFilter filter = new IntentFilter();
@@ -752,7 +751,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
             mPlaybackStarted = false;
             return;
         }
-        mWasPaused = !mService.isPlaying();
+        mWasPaused = !(mService.isPlaying() && isInteractive());
+        if (mWasPaused) mSettings.edit().putBoolean(PreferencesActivity.VIDEO_PAUSED, true).apply();
         if (!isFinishing()) {
             mCurrentAudioTrack = mService.getAudioTrack();
             mCurrentSpuTrack = mService.getSpuTrack();
@@ -1565,6 +1565,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
         // Get possible subtitles
         observeDownloadedSubtitles();
         if (mOptionsDelegate != null) mOptionsDelegate.setup();
+        mSettings.edit().remove(PreferencesActivity.VIDEO_PAUSED).apply();
     }
 
     private void encounteredError() {
diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 1ec658acd..e798825d4 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -640,7 +640,6 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
         editor.putInt(if (audio) "position_in_audio_list" else "position_in_media_list", if (reset) 0 else currentIndex)
         editor.putLong(if (audio) "position_in_song" else "position_in_media", if (reset) 0L else player.getCurrentTime())
         if (!audio) {
-            editor.putBoolean(PreferencesActivity.VIDEO_PAUSED, !player.isPlaying())
             editor.putFloat(PreferencesActivity.VIDEO_SPEED, player.getRate())
         }
         editor.apply()



More information about the Android mailing list