diff --git a/livestream/src/main/java/video/api/livestream/ApiVideoLiveStream.kt b/livestream/src/main/java/video/api/livestream/ApiVideoLiveStream.kt index 289ed4e..6771cf7 100644 --- a/livestream/src/main/java/video/api/livestream/ApiVideoLiveStream.kt +++ b/livestream/src/main/java/video/api/livestream/ApiVideoLiveStream.kt @@ -238,7 +238,11 @@ constructor( } init { - apiVideoView.streamer = streamer + try { + apiVideoView.streamer = streamer + } catch (e: Exception) { + Log.w(TAG, "Can't set streamer to ApiVideoView", e) + } } /** @@ -370,7 +374,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 fc08a0d..8647d54 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.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