All Downloads are FREE. Search and download functionalities are using the official Maven repository.

androidMain.tech.skot.libraries.video.SKVideoView.kt Maven / Gradle / Ivy

There is a newer version: 0.2.4_1.2.7
Show newest version
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