[Android] Video player: delay first player call, prevent ANR

Geoffrey Métais git at videolan.org
Mon Apr 1 11:45:37 CEST 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Apr  1 11:20:50 2019 +0200| [8e1cdf32ecd1b9a881c85181a4f8c1a068fb459d] | committer: Geoffrey Métais

Video player: delay first player call, prevent ANR

> https://code.videolan.org/videolan/vlc-android/commit/8e1cdf32ecd1b9a881c85181a4f8c1a068fb459d
---

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java        | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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 7a35201d1..d9029e2fe 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2930,7 +2930,12 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
             if (Permissions.checkReadStoragePermission(this, true) && !mSwitchingView)
                 mHandler.sendEmptyMessage(START_PLAYBACK);
             mSwitchingView = false;
-            if (mService.getVolume() > 100 && !audioBoostEnabled) mService.setVolume(100);
+            mHandler.post(new Runnable() {
+                @Override
+                public void run() { // delay mediaplayer loading, prevent ANR
+                    if (mService.getVolume() > 100 && !audioBoostEnabled) mService.setVolume(100);
+                }
+            });
             mService.addCallback(this);
         } else {
             if (mService != null) mService.removeCallback(this);



More information about the Android mailing list