diff --git a/livestream/src/main/java/video/api/livestream/ApiVideoLiveStream.kt b/livestream/src/main/java/video/api/livestream/ApiVideoLiveStream.kt index dac4b06..93e73e6 100644 --- a/livestream/src/main/java/video/api/livestream/ApiVideoLiveStream.kt +++ b/livestream/src/main/java/video/api/livestream/ApiVideoLiveStream.kt @@ -417,7 +417,11 @@ constructor( Log.w(TAG, "Video config is not set") return@permissionRequester } - apiVideoView.startPreview() + try { + apiVideoView.startPreview() + } catch (t: Throwable) { + Log.e(TAG, "Can't start preview: ${t.message}") + } } } diff --git a/livestream/src/main/java/video/api/livestream/views/ApiVideoView.kt b/livestream/src/main/java/video/api/livestream/views/ApiVideoView.kt index fa8cb73..3cba0a7 100644 --- a/livestream/src/main/java/video/api/livestream/views/ApiVideoView.kt +++ b/livestream/src/main/java/video/api/livestream/views/ApiVideoView.kt @@ -2,6 +2,7 @@ package video.api.livestream.views import android.content.Context import android.util.AttributeSet +import android.util.Log import android.view.ViewGroup import android.widget.FrameLayout import io.github.thibaultbee.streampack.core.streamers.interfaces.ICameraStreamer @@ -25,7 +26,11 @@ class ApiVideoView @JvmOverloads constructor( * @param value the [ICameraStreamer] to use */ set(value) { - previewView.streamer = value + try { + previewView.streamer = value + } catch (t: Throwable) { + Log.w(TAG, "Failed to set streamer: $t") + } } init { @@ -61,4 +66,8 @@ class ApiVideoView @JvmOverloads constructor( internal fun startPreview() { previewView.startPreview() } + + companion object { + private const val TAG = "ApiVideoView" + } } \ No newline at end of file