[Android] Fix IllegalStateException when the current video track is not available anymore

Nicolas Pomepuy git at videolan.org
Thu Sep 1 11:36:09 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Aug 10 08:01:32 2022 +0200| [a917d8d42e96a168abf0b9103e64d2b3921021db] | committer: Nicolas Pomepuy

Fix IllegalStateException when the current video track is not available anymore

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

 .../src/org/videolan/vlc/util/FrameRateManager.kt         | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/util/FrameRateManager.kt b/application/vlc-android/src/org/videolan/vlc/util/FrameRateManager.kt
index b543f7e35..1a974f2c6 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/FrameRateManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/FrameRateManager.kt
@@ -6,12 +6,15 @@ import android.os.Build
 import android.os.Handler
 import android.os.Looper
 import android.util.Log
+import android.view.Surface
+import android.view.SurfaceView
+import android.view.Window
+import android.view.WindowManager
+import androidx.annotation.RequiresApi
 import androidx.appcompat.app.AppCompatActivity
 import androidx.core.content.getSystemService
-import org.videolan.vlc.PlaybackService
-import android.view.*
-import androidx.annotation.RequiresApi
 import org.videolan.vlc.BuildConfig
+import org.videolan.vlc.PlaybackService
 import java.math.BigDecimal
 import java.math.RoundingMode
 
@@ -31,7 +34,11 @@ class FrameRateManager(var context: Context, var service: PlaybackService) {
                 //switching mode may cause playback to pause i.e HDMI
                 //wait 2 seconds and resume play, mode switch will have happened by then
                 Handler(Looper.getMainLooper()).postDelayed({
-                    val videoTrack = this at FrameRateManager.service.mediaplayer.currentVideoTrack
+                    val videoTrack = try {
+                        this at FrameRateManager.service.mediaplayer.currentVideoTrack
+                    } catch (e: IllegalStateException) {
+                        null
+                    }
                     if (videoTrack != null) {
                         service.play()
                     }



More information about the Android mailing list