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

23 lines
899 B
Kotlin
Raw Normal View History

2021-07-04 17:00:04 +00:00
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
}
2021-07-05 20:28:50 +00:00
VideoDownloadManager.downloadEvent.invoke(Pair(id, state))
2021-07-04 17:00:04 +00:00
}
}
}
}