Skip to content

Commit

Permalink
fix(lib): fix exception on startPreview
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Oct 1, 2024
1 parent 59e840f commit a8a99d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.message}")
}
}

/**
Expand Down Expand Up @@ -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}")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -61,4 +66,8 @@ class ApiVideoView @JvmOverloads constructor(
internal fun startPreview() {
previewView.startPreview()
}

companion object {
private const val TAG = "ApiVideoView"
}
}

0 comments on commit a8a99d0

Please sign in to comment.