[Android] TV: Catch exception when surface is not valid

Geoffrey Métais git at videolan.org
Mon Mar 18 15:45:20 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Mar 18 10:11:47 2019 +0100| [fc4df919416f71580e8f6402db5903db21cb3a46] | committer: Geoffrey Métais

TV: Catch exception when surface is not valid

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

 vlc-android/src/org/videolan/vlc/PreviewVideoInputService.kt | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PreviewVideoInputService.kt b/vlc-android/src/org/videolan/vlc/PreviewVideoInputService.kt
index 0faea50f6..840755492 100644
--- a/vlc-android/src/org/videolan/vlc/PreviewVideoInputService.kt
+++ b/vlc-android/src/org/videolan/vlc/PreviewVideoInputService.kt
@@ -10,10 +10,7 @@ import android.net.Uri
 import android.os.Build
 import android.util.Log
 import android.view.Surface
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.launch
+import kotlinx.coroutines.*
 import org.videolan.libvlc.Media
 import org.videolan.libvlc.MediaPlayer
 import org.videolan.vlc.media.MediaPlayerEventListener
@@ -25,9 +22,10 @@ import java.io.IOException
 
 private const val TAG = "PreviewInputService"
 
+ at ObsoleteCoroutinesApi
+ at ExperimentalCoroutinesApi
 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
 class PreviewVideoInputService : TvInputService(), CoroutineScope {
-    @ExperimentalCoroutinesApi
     override val coroutineContext = Dispatchers.Main.immediate
 
     override fun onCreateSession(inputId: String): TvInputService.Session? {
@@ -69,6 +67,9 @@ class PreviewVideoInputService : TvInputService(), CoroutineScope {
                 } catch (e: IOException) {
                     Log.e(TAG, "Could not prepare media player", e)
                     notifyVideoUnavailable(TvInputManager.VIDEO_UNAVAILABLE_REASON_UNKNOWN)
+                } catch (e: IllegalStateException) {
+                    Log.e(TAG, "Could not prepare media player", e)
+                    notifyVideoUnavailable(TvInputManager.VIDEO_UNAVAILABLE_REASON_UNKNOWN)
                 }
             }
             return true



More information about the Android mailing list