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

commonMain.tech.skot.libraries.video.SKAudio.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.model.SKData
import tech.skot.model.SKManualData

class SKAudio(private val proxy: SKAudioVC) {

    fun setPlayList(tracks: List) {
        proxy.trackList = tracks
    }

    fun addTrackIfNotIn(track: SKAudioVC.Track) {
        if (!proxy.trackList.contains(track)) {
            proxy.addTrack(track)
        }
    }

    fun play() {
        proxy.playing = true
    }

    var playing:Boolean
        get() = proxy.playing
    set(value) {
        proxy.playing = value
    }

    fun pause() {
        proxy.playing = false
    }

    fun setCurrentTrack(track: SKAudioVC.Track) {
        proxy.setCurrentTrack(track)
    }

    fun hasNext(): Boolean {
        return proxy.hasNext()
    }

    fun seekToLastTrack() {
        proxy.seekToLastTrack()
    }

    fun setProgressRefreshInterval(ms: Long) {
        proxy.progressRefreshInterval = ms
    }

    var keepActiveInBackGroundWithMessageIfNothingPlayed: String?
        get() = proxy.keepActiveInBackGroundWithMessageIfNothingPlayed
        set(value) {
            proxy.keepActiveInBackGroundWithMessageIfNothingPlayed = value
        }

    init {
        setProgressRefreshInterval(1000L)
    }

    private val _state = SKManualData(null)
    val state: SKData = _state

    val currentState:SKAudioVC.State?
        get() = _state.value

    private val _durations = SKManualData?>(null)
    val durations: SKData?> = _durations


    init {
        proxy.onState = {
            _state.value = it
        }
        proxy.onDurations = {
            _durations.value = it
        }
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy