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

commonMain.tech.skot.libraries.video.SKVideo.kt Maven / Gradle / Ivy

There is a newer version: 0.2.4_1.2.7
Show newest version
package tech.skot.libraries.video

import tech.skot.core.components.SKComponent
import tech.skot.libraries.video.di.skvideoViewInjector

/**
 * A Video Component
 * Based on ExoPlayer for Android
 * no iOs Version at this time
 *
 * @param url url of video you want play
 * @param playingInitial indicate if the video should play automatically when ready
 * @param soundInitial indicate if the soud should be on or of
 *
 * @property playing indicate if the video should play, play if true, pause if false
 *
 */
class SKVideo(
    urlInitial: String?,
    useCache: Boolean = false,
    playingInitial: Boolean = true,
    soundInitial: Boolean = false,
    onFullScreen: ((fullScreen: Boolean) -> Unit)? = null,
) :
    SKComponent() {


    override val view: SKVideoVC = skvideoViewInjector.skVideo(
        url = urlInitial,
        useCache = useCache,
        onFullScreen = onFullScreen,
        playingInitial = playingInitial,
        soundInitial = soundInitial,
    )

    var url: String? = urlInitial
        set(value) {
            field = value
            view.url = value
        }

    var playing: Boolean = playingInitial
        set(value) {
            field = value
            view.playing = value
        }

    var sound: Boolean = soundInitial
        set(value) {
            field = value
            view.sound = value
        }

    fun onPause() {
        view.onPause()
    }

    fun onResume() {
        view.onResume()
    }

    fun setCurrentPosition(position: Long) {
        view.setCurrentPosition(position)
    }

    val currentPosition: Long?
        get() = view.currentPosition

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy