Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions android/src/main/java/com/tpstreams/TPStreamsRNPlayerView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.media3.common.Player
import androidx.media3.common.PlaybackParameters
import androidx.media3.common.PlaybackException
import android.media.MediaCodec
import android.view.View.MeasureSpec

class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context) {
private val playerView: TPStreamsPlayerView = TPStreamsPlayerView(context)
Expand All @@ -35,11 +36,27 @@ class TPStreamsRNPlayerView(context: ThemedReactContext) : FrameLayout(context)
private var downloadMetadata: Map<String, Any>? = null
private var offlineLicenseExpireTime: Long = DEFAULT_OFFLINE_LICENSE_EXPIRE_TIME
private var accessTokenCallback: ((String) -> Unit)? = null
private var isLayoutUpdatePosted = false

init {
addView(playerView, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
}

override fun requestLayout() {
Comment thread
syed-tp marked this conversation as resolved.
super.requestLayout()
if (!isLayoutUpdatePosted) {
isLayoutUpdatePosted = true
post {
isLayoutUpdatePosted = false
measure(
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
)
layout(left, top, right, bottom)
}
}
}

// Emit React Native events
private fun emitEvent(eventName: String, data: Map<String, Any>) {
val event = Arguments.createMap()
Expand Down
Loading