[Android] Load VLC librairies later, and in background

Geoffrey Métais git at videolan.org
Thu Jan 25 10:32:16 CET 2018


vlc-android | branch: chromecast | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 25 09:51:32 2018 +0100| [2b2d61f5c4b78fa6a0a9c9f296ae60c2c091cc79] | committer: Geoffrey Métais

Load VLC librairies later, and in background

> https://code.videolan.org/videolan/vlc-android/commit/2b2d61f5c4b78fa6a0a9c9f296ae60c2c091cc79
---

 .../src/org/videolan/medialibrary/Medialibrary.java       |  2 ++
 vlc-android/src/org/videolan/vlc/VLCApplication.java      | 15 ++++-----------
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index 3ec20e529..5d278ab55 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -15,6 +15,7 @@ import android.support.v4.content.LocalBroadcastManager;
 import android.text.TextUtils;
 import android.util.Log;
 
+import org.videolan.libvlc.LibVLC;
 import org.videolan.libvlc.util.VLCUtil;
 import org.videolan.medialibrary.interfaces.DevicesDiscoveryCb;
 import org.videolan.medialibrary.interfaces.EntryPointsEventsCb;
@@ -87,6 +88,7 @@ public class Medialibrary {
         if (extFilesDir == null || !extFilesDir.exists()
                 || dbDirectory == null || !dbDirectory.canWrite())
             return ML_INIT_FAILED;
+        LibVLC.loadLibraries();
         int initCode = nativeInit(dbDirectory+ VLC_MEDIA_DB_NAME, extFilesDir+ THUMBS_FOLDER_NAME);
         mIsInitiated = initCode != ML_INIT_FAILED;
         return initCode;
diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index d9789d8b8..df1ee8bce 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -36,7 +36,6 @@ import android.support.v4.util.SimpleArrayMap;
 import android.util.Log;
 
 import org.videolan.libvlc.Dialog;
-import org.videolan.libvlc.LibVLC;
 import org.videolan.libvlc.util.AndroidUtil;
 import org.videolan.medialibrary.Medialibrary;
 import org.videolan.vlc.gui.DialogActivity;
@@ -94,21 +93,17 @@ public class VLCApplication extends Application {
 
         setLocale();
 
-        LibVLC.loadLibraries();
-
         runBackground(new Runnable() {
             @Override
             public void run() {
 
-                if (AndroidUtil.isOOrLater)
-                    NotificationHelper.createNotificationChannels();
+                if (AndroidUtil.isOOrLater) NotificationHelper.createNotificationChannels();
                 // Prepare cache folder constants
                 AudioUtil.prepareCacheFolder(instance);
 
                 sTV = AndroidDevices.isAndroidTv || (!AndroidDevices.isChromeBook && !AndroidDevices.hasTsp);
 
-                if (!VLCInstance.testCompatibleCPU(instance))
-                    return;
+                if (!VLCInstance.testCompatibleCPU(instance)) return;
                 Dialog.setCallbacks(VLCInstance.get(), mDialogCallbacks);
 
                 // Disable remote control receiver on Fire TV.
@@ -117,10 +112,8 @@ public class VLCApplication extends Application {
             }
         });
 
-        if (sActivityCbListener != null)
-            registerActivityLifecycleCallbacks(sActivityCbListener);
-        else
-            ExternalMonitor.register(instance);
+        if (sActivityCbListener != null) registerActivityLifecycleCallbacks(sActivityCbListener);
+        else ExternalMonitor.register(instance);
     }
 
     @Override



More information about the Android mailing list