mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Fixed skip loading (#484)
* Added quality profiles * Better quality selection * Added profile bg and fixed some sources * Properly fixed skip loading * Extra safety --------- Co-authored-by: Lag <>
This commit is contained in:
parent
b5566af401
commit
906f1fdc9a
2 changed files with 21 additions and 7 deletions
|
@ -238,6 +238,7 @@ class GeneratorPlayer : FullScreenPlayer() {
|
||||||
}
|
}
|
||||||
meta.name = newMeta.headerName
|
meta.name = newMeta.headerName
|
||||||
}
|
}
|
||||||
|
|
||||||
is ExtractorUri -> {
|
is ExtractorUri -> {
|
||||||
if (newMeta.tvType?.isMovieType() == false) {
|
if (newMeta.tvType?.isMovieType() == false) {
|
||||||
meta.episode = newMeta.episode
|
meta.episode = newMeta.episode
|
||||||
|
@ -980,6 +981,7 @@ class GeneratorPlayer : FullScreenPlayer() {
|
||||||
is ResultEpisode -> {
|
is ResultEpisode -> {
|
||||||
DataStoreHelper.removeLastWatched(newMeta.parentId)
|
DataStoreHelper.removeLastWatched(newMeta.parentId)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ExtractorUri -> {
|
is ExtractorUri -> {
|
||||||
DataStoreHelper.removeLastWatched(newMeta.parentId)
|
DataStoreHelper.removeLastWatched(newMeta.parentId)
|
||||||
}
|
}
|
||||||
|
@ -996,6 +998,7 @@ class GeneratorPlayer : FullScreenPlayer() {
|
||||||
isFromDownload = false
|
isFromDownload = false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ExtractorUri -> {
|
is ExtractorUri -> {
|
||||||
DataStoreHelper.setLastWatched(
|
DataStoreHelper.setLastWatched(
|
||||||
resumeMeta.parentId,
|
resumeMeta.parentId,
|
||||||
|
@ -1127,6 +1130,7 @@ class GeneratorPlayer : FullScreenPlayer() {
|
||||||
season = meta.season
|
season = meta.season
|
||||||
tvType = meta.tvType
|
tvType = meta.tvType
|
||||||
}
|
}
|
||||||
|
|
||||||
is ExtractorUri -> {
|
is ExtractorUri -> {
|
||||||
headerName = meta.headerName
|
headerName = meta.headerName
|
||||||
subName = meta.name
|
subName = meta.name
|
||||||
|
@ -1343,6 +1347,7 @@ class GeneratorPlayer : FullScreenPlayer() {
|
||||||
is Resource.Loading -> {
|
is Resource.Loading -> {
|
||||||
startLoading()
|
startLoading()
|
||||||
}
|
}
|
||||||
|
|
||||||
is Resource.Success -> {
|
is Resource.Success -> {
|
||||||
// provider returned false
|
// provider returned false
|
||||||
//if (it.value != true) {
|
//if (it.value != true) {
|
||||||
|
@ -1350,6 +1355,7 @@ class GeneratorPlayer : FullScreenPlayer() {
|
||||||
//}
|
//}
|
||||||
startPlayer()
|
startPlayer()
|
||||||
}
|
}
|
||||||
|
|
||||||
is Resource.Failure -> {
|
is Resource.Failure -> {
|
||||||
showToast(activity, it.errorString, Toast.LENGTH_LONG)
|
showToast(activity, it.errorString, Toast.LENGTH_LONG)
|
||||||
startPlayer()
|
startPlayer()
|
||||||
|
@ -1364,10 +1370,12 @@ class GeneratorPlayer : FullScreenPlayer() {
|
||||||
overlay_loading_skip_button?.isVisible = turnVisible
|
overlay_loading_skip_button?.isVisible = turnVisible
|
||||||
|
|
||||||
normalSafeApiCall {
|
normalSafeApiCall {
|
||||||
currentLinks.lastOrNull()?.let { last ->
|
if (currentLinks.any { link ->
|
||||||
if (getLinkPriority(currentQualityProfile, last) >= QualityDataHelper.AUTO_SKIP_PRIORITY) {
|
getLinkPriority(currentQualityProfile, link) >=
|
||||||
startPlayer()
|
QualityDataHelper.AUTO_SKIP_PRIORITY
|
||||||
}
|
}
|
||||||
|
) {
|
||||||
|
startPlayer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,18 +156,24 @@ class PlayerGeneratorViewModel : ViewModel() {
|
||||||
val currentSubs = mutableSetOf<SubtitleData>()
|
val currentSubs = mutableSetOf<SubtitleData>()
|
||||||
|
|
||||||
// clear old data
|
// clear old data
|
||||||
_currentSubs.postValue(currentSubs)
|
_currentSubs.postValue(emptySet())
|
||||||
_currentLinks.postValue(currentLinks)
|
_currentLinks.postValue(emptySet())
|
||||||
|
|
||||||
// load more data
|
// load more data
|
||||||
_loadingLinks.postValue(Resource.Loading())
|
_loadingLinks.postValue(Resource.Loading())
|
||||||
val loadingState = safeApiCall {
|
val loadingState = safeApiCall {
|
||||||
generator?.generateLinks(clearCache = clearCache, isCasting = isCasting, {
|
generator?.generateLinks(clearCache = clearCache, isCasting = isCasting, {
|
||||||
currentLinks.add(it)
|
currentLinks.add(it)
|
||||||
_currentLinks.postValue(currentLinks)
|
// Clone to prevent ConcurrentModificationException
|
||||||
|
normalSafeApiCall {
|
||||||
|
// Extra normalSafeApiCall since .toSet() iterates.
|
||||||
|
_currentLinks.postValue(currentLinks.toSet())
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
currentSubs.add(it)
|
currentSubs.add(it)
|
||||||
// _currentSubs.postValue(currentSubs) // this causes ConcurrentModificationException, so fuck it
|
normalSafeApiCall {
|
||||||
|
_currentSubs.postValue(currentSubs.toSet())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue