androidMain.tech.skot.libraries.video.SKAudioApplicationExtension.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 android.app.Application
import android.content.Intent
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ProcessLifecycleOwner
import tech.skot.core.SKLog
fun Application.bindAudioService(audioService: Class) {
ProcessLifecycleOwner.get().lifecycle.addObserver(
object : DefaultLifecycleObserver {
override fun onStart(owner: LifecycleOwner) {
super.onStart(owner)
startService(Intent(applicationContext, audioService).apply {
action = SKAudioService.ACTION_FOREGROUND
})
}
override fun onStop(owner: LifecycleOwner) {
super.onStop(owner)
startService(Intent(applicationContext, audioService).apply {
action = SKAudioService.ACTION_BACKGROUND
})
}
}
)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy