Commit 19cb5c27 authored by Geoffrey Métais's avatar Geoffrey Métais

TV: Catch exception when surface is not valid

parent 00a5c112
......@@ -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"
@ObsoleteCoroutinesApi
@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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment