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

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


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

Video player: delay first player call, prevent ANR

> https://code.videolan.org/videolan/vlc-android/commit/09fa2ed8a4b48fd3ac10f3b7908f4bc902eae41b
---

 .../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..feff16da4 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);
+            if (mService.getVolume() > 100 && !audioBoostEnabled) mHandler.post(new Runnable() {
+                @Override
+                public void run() { // delay mediaplayer loading, prevent ANR
+                    mService.setVolume(100);
+                }
+            });
             mService.addCallback(this);
         } else {
             if (mService != null) mService.removeCallback(this);



More information about the Android mailing list