[Android] RendererDelegate: Use NetworkMonitor

Geoffrey Métais git at videolan.org
Tue Jan 28 15:49:18 CET 2020


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan 28 15:48:25 2020 +0100| [33cb8ff7b302eb81612920de8e3d9411c7d9a757] | committer: Geoffrey Métais

RendererDelegate: Use NetworkMonitor

Instead of ExternalMonitor; which will be reduced to storage monitoring

> https://code.videolan.org/videolan/vlc-android/commit/33cb8ff7b302eb81612920de8e3d9411c7d9a757
---

 application/vlc-android/src/org/videolan/vlc/RendererDelegate.kt | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/RendererDelegate.kt b/application/vlc-android/src/org/videolan/vlc/RendererDelegate.kt
index 2ecfcb44a..3f4d6512d 100644
--- a/application/vlc-android/src/org/videolan/vlc/RendererDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/RendererDelegate.kt
@@ -24,6 +24,7 @@ import org.videolan.libvlc.RendererDiscoverer
 import org.videolan.libvlc.RendererItem
 import org.videolan.resources.AppContextProvider
 import org.videolan.tools.AppScope
+import org.videolan.tools.NetworkMonitor
 import org.videolan.tools.retry
 import org.videolan.tools.livedata.LiveDataset
 import org.videolan.vlc.util.VLCInstance
@@ -41,14 +42,12 @@ object RendererDelegate : RendererDiscoverer.EventListener {
     @Volatile private var started = false
 
     init {
-        ExternalMonitor.connected.observeForever { AppScope.launch { if (it == true) start() else stop() } }
+        NetworkMonitor.getInstance(AppContextProvider.appContext).connected.observeForever { AppScope.launch { if (it == true) start() else stop() } }
     }
 
     suspend fun start() {
         if (started) return
-        val libVlc = AppContextProvider.appContext.let {
-            withContext(Dispatchers.IO) { VLCInstance.get(it) }
-        }
+        val libVlc = withContext(Dispatchers.IO) { VLCInstance.get(AppContextProvider.appContext) }
         started = true
         for (discoverer in RendererDiscoverer.list(libVlc)) {
             val rd = RendererDiscoverer(libVlc, discoverer.name)



More information about the Android mailing list