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:
LagradOst 2023-06-14 22:42:42 +00:00 committed by GitHub
parent b5566af401
commit 906f1fdc9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View file

@ -238,6 +238,7 @@ class GeneratorPlayer : FullScreenPlayer() {
}
meta.name = newMeta.headerName
}
is ExtractorUri -> {
if (newMeta.tvType?.isMovieType() == false) {
meta.episode = newMeta.episode
@ -980,6 +981,7 @@ class GeneratorPlayer : FullScreenPlayer() {
is ResultEpisode -> {
DataStoreHelper.removeLastWatched(newMeta.parentId)
}
is ExtractorUri -> {
DataStoreHelper.removeLastWatched(newMeta.parentId)
}
@ -996,6 +998,7 @@ class GeneratorPlayer : FullScreenPlayer() {
isFromDownload = false
)
}
is ExtractorUri -> {
DataStoreHelper.setLastWatched(
resumeMeta.parentId,
@ -1127,6 +1130,7 @@ class GeneratorPlayer : FullScreenPlayer() {
season = meta.season
tvType = meta.tvType
}
is ExtractorUri -> {
headerName = meta.headerName
subName = meta.name
@ -1343,6 +1347,7 @@ class GeneratorPlayer : FullScreenPlayer() {
is Resource.Loading -> {
startLoading()
}
is Resource.Success -> {
// provider returned false
//if (it.value != true) {
@ -1350,6 +1355,7 @@ class GeneratorPlayer : FullScreenPlayer() {
//}
startPlayer()
}
is Resource.Failure -> {
showToast(activity, it.errorString, Toast.LENGTH_LONG)
startPlayer()
@ -1364,10 +1370,12 @@ class GeneratorPlayer : FullScreenPlayer() {
overlay_loading_skip_button?.isVisible = turnVisible
normalSafeApiCall {
currentLinks.lastOrNull()?.let { last ->
if (getLinkPriority(currentQualityProfile, last) >= QualityDataHelper.AUTO_SKIP_PRIORITY) {
startPlayer()
if (currentLinks.any { link ->
getLinkPriority(currentQualityProfile, link) >=
QualityDataHelper.AUTO_SKIP_PRIORITY
}
) {
startPlayer()
}
}

View file

@ -156,18 +156,24 @@ class PlayerGeneratorViewModel : ViewModel() {
val currentSubs = mutableSetOf<SubtitleData>()
// clear old data
_currentSubs.postValue(currentSubs)
_currentLinks.postValue(currentLinks)
_currentSubs.postValue(emptySet())
_currentLinks.postValue(emptySet())
// load more data
_loadingLinks.postValue(Resource.Loading())
val loadingState = safeApiCall {
generator?.generateLinks(clearCache = clearCache, isCasting = isCasting, {
currentLinks.add(it)
_currentLinks.postValue(currentLinks)
// Clone to prevent ConcurrentModificationException
normalSafeApiCall {
// Extra normalSafeApiCall since .toSet() iterates.
_currentLinks.postValue(currentLinks.toSet())
}
}, {
currentSubs.add(it)
// _currentSubs.postValue(currentSubs) // this causes ConcurrentModificationException, so fuck it
normalSafeApiCall {
_currentSubs.postValue(currentSubs.toSet())
}
})
}