androidMain.tech.skot.libraries.video.SKVideoView.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of viewlegacy Show documentation
Show all versions of viewlegacy Show documentation
viewlegacy module for SK-Video skot library
package tech.skot.libraries.video
import androidx.fragment.app.Fragment
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.ui.StyledPlayerView
import tech.skot.core.components.SKActivity
import tech.skot.core.components.SKComponentView
class SKVideoView(
override val proxy: SKVideoViewProxy,
activity: SKActivity,
fragment: Fragment?,
binding: StyledPlayerView,
player: ExoPlayer,
) : SKComponentView(proxy, activity, fragment, binding) {
init {
binding.player = player
lifecycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver {
override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
proxy.player?.release()
proxy.player = null
binding.player = null
}
})
}
fun setCurrentPosition(position: Long) {
binding.player?.apply {
seekTo(position)
prepare()
}
}
fun setOnFullScreen(onFullScreen: ((fullScreen: Boolean) -> Unit)?) {
binding.setFullscreenButtonClickListener(onFullScreen)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy