mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fixed #958
This commit is contained in:
parent
e3cc7ca489
commit
7adc6f6cb1
2 changed files with 16 additions and 6 deletions
|
@ -21,6 +21,7 @@ import com.google.android.gms.cast.framework.media.uicontroller.UIController
|
|||
import com.google.android.gms.cast.framework.media.widget.ExpandedControllerActivity
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.mvvm.Resource
|
||||
import com.lagradost.cloudstream3.mvvm.logError
|
||||
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
||||
import com.lagradost.cloudstream3.sortSubs
|
||||
import com.lagradost.cloudstream3.sortUrls
|
||||
|
@ -33,6 +34,7 @@ import com.lagradost.cloudstream3.utils.CastHelper.awaitLinks
|
|||
import com.lagradost.cloudstream3.utils.CastHelper.getMediaInfo
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||
import com.lagradost.cloudstream3.utils.DataStore.toKotlinObject
|
||||
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
import org.json.JSONObject
|
||||
|
@ -268,24 +270,33 @@ class SelectSourceController(val view: ImageView, val activity: ControllerActivi
|
|||
if (meta != null && meta.episodes.size > meta.currentEpisodeIndex + 1) {
|
||||
val currentIdIndex = remoteMediaClient?.getItemIndex() ?: return
|
||||
val itemCount = remoteMediaClient?.mediaQueue?.itemCount
|
||||
val index = meta.currentEpisodeIndex + 1
|
||||
val epData = meta.episodes[index]
|
||||
|
||||
try {
|
||||
val currentDuration = remoteMediaClient?.streamDuration
|
||||
val currentPosition = remoteMediaClient?.approximateStreamPosition
|
||||
if (currentDuration != null && currentPosition != null)
|
||||
DataStoreHelper.setViewPos(epData.id, currentPosition, currentDuration)
|
||||
} catch (e : Exception) {
|
||||
logError(e)
|
||||
}
|
||||
|
||||
if (itemCount != null && itemCount - currentIdIndex == 1 && !isLoadingMore) {
|
||||
isLoadingMore = true
|
||||
ioSafe {
|
||||
val index = meta.currentEpisodeIndex + 1
|
||||
val epData = meta.episodes[index]
|
||||
val currentLinks = mutableSetOf<ExtractorLink>()
|
||||
val currentSubs = mutableSetOf<SubtitleData>()
|
||||
|
||||
val generator = RepoLinkGenerator(listOf(epData))
|
||||
|
||||
val isSuccessful = safeApiCall {
|
||||
generator.generateLinks(false, true,
|
||||
{
|
||||
generator.generateLinks(clearCache = false, isCasting = true,
|
||||
callback = {
|
||||
it.first?.let { link ->
|
||||
currentLinks.add(link)
|
||||
}
|
||||
}, {
|
||||
}, subtitleCallback = {
|
||||
currentSubs.add(it)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -393,7 +393,6 @@ class GeneratorPlayer : FullScreenPlayer() {
|
|||
override fun playerPositionChanged(posDur: Pair<Long, Long>) {
|
||||
val (position, duration) = posDur
|
||||
viewModel.getId()?.let {
|
||||
println("SET VIEW ID: $it ($position/$duration)")
|
||||
DataStoreHelper.setViewPos(it, position, duration)
|
||||
}
|
||||
val percentage = position * 100L / duration
|
||||
|
|
Loading…
Reference in a new issue