AquaStream/app/src/main/java/com/lagradost/cloudstream3/services/VideoDownloadService.kt

23 lines
892 B
Kotlin

package com.lagradost.cloudstream3.services
import android.app.IntentService
import android.content.Intent
import com.lagradost.cloudstream3.utils.VideoDownloadManager
class VideoDownloadService : IntentService("VideoDownloadService") {
override fun onHandleIntent(intent: Intent?) {
if (intent != null) {
val id = intent.getIntExtra("id", -1)
val type = intent.getStringExtra("type")
if (id != -1 && type != null) {
val state = when (type) {
"resume" -> VideoDownloadManager.DownloadActionType.Resume
"pause" -> VideoDownloadManager.DownloadActionType.Pause
"stop" -> VideoDownloadManager.DownloadActionType.Stop
else -> return
}
VideoDownloadManager.events.invoke(Pair(id, state))
}
}
}
}