[Android] Prevent video tracks being redrawn too frequently

Nicolas Pomepuy git at videolan.org
Tue Jun 2 13:57:43 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu May 28 07:04:09 2020 +0200| [e31382cee1c14b0bc928dc408fc60b2e7771722e] | committer: Nicolas Pomepuy

Prevent video tracks being redrawn too frequently

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

 .../src/org/videolan/vlc/gui/video/VideoStatsDelegate.kt       | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoStatsDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoStatsDelegate.kt
index 6fb21ecbf..f7fd7a392 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoStatsDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoStatsDelegate.kt
@@ -25,6 +25,7 @@
 package org.videolan.vlc.gui.video
 
 import android.annotation.SuppressLint
+import android.net.Uri
 import android.os.Handler
 import android.util.Log
 import android.view.MotionEvent
@@ -92,6 +93,8 @@ class VideoStatsDelegate(private val player: VideoPlayerActivity, val scrolling:
         setupLayout()
     }
 
+    var lastMediaUri:Uri?= null
+
     @SuppressLint("SetTextI18n")
     private val runnable = Runnable {
         val media = player.service?.mediaplayer?.media as? Media ?: return at Runnable
@@ -105,13 +108,14 @@ class VideoStatsDelegate(private val player: VideoPlayerActivity, val scrolling:
             binding.plotView.addData(StatIndex.INPUT_BITRATE.ordinal, Pair(now, it * 8 * 1024))
         }
 
-        media.let {
+        if (lastMediaUri != media.uri) {
+            lastMediaUri = media.uri
             binding.infoGrids.removeAllViews()
-            for (i in 0 until it.trackCount) {
+            for (i in 0 until media.trackCount) {
                 val grid = GridLayout(player)
                 grid.columnCount = 2
 
-                val track = it.getTrack(i)
+                val track = media.getTrack(i)
                 if (track.bitrate > 0) addStreamGridView(grid, player.getString(R.string.bitrate), player.getString(R.string.bitrate_value, track.bitrate.toLong().readableSize()))
                 addStreamGridView(grid, player.getString(R.string.codec), track.codec)
                 if (track.language != null && !track.language.equals("und", ignoreCase = true))



More information about the Android mailing list