[Android] TV: Catch exception when surface is not valid
Geoffrey Métais
git at videolan.org
Tue Mar 19 15:35:13 CET 2019
vlc-android | branch: 3.1.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Mar 18 10:11:47 2019 +0100| [19cb5c2761423fc4f6077adc4c62a5525702135a] | committer: Geoffrey Métais
TV: Catch exception when surface is not valid
> https://code.videolan.org/videolan/vlc-android/commit/19cb5c2761423fc4f6077adc4c62a5525702135a
---
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