Skip to content

Commit

Permalink
Fixed skip loading (#484)
Browse files Browse the repository at this point in the history
* Added quality profiles

* Better quality selection

* Added profile bg and fixed some sources

* Properly fixed skip loading

* Extra safety

---------

Co-authored-by: Lag <>
  • Loading branch information
Blatzar committed Jun 14, 2023
1 parent b5566af commit 906f1fd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ class GeneratorPlayer : FullScreenPlayer() {
}
meta.name = newMeta.headerName
}

is ExtractorUri -> {
if (newMeta.tvType?.isMovieType() == false) {
meta.episode = newMeta.episode
Expand Down Expand Up @@ -980,6 +981,7 @@ class GeneratorPlayer : FullScreenPlayer() {
is ResultEpisode -> {
DataStoreHelper.removeLastWatched(newMeta.parentId)
}

is ExtractorUri -> {
DataStoreHelper.removeLastWatched(newMeta.parentId)
}
Expand All @@ -996,6 +998,7 @@ class GeneratorPlayer : FullScreenPlayer() {
isFromDownload = false
)
}

is ExtractorUri -> {
DataStoreHelper.setLastWatched(
resumeMeta.parentId,
Expand Down Expand Up @@ -1127,6 +1130,7 @@ class GeneratorPlayer : FullScreenPlayer() {
season = meta.season
tvType = meta.tvType
}

is ExtractorUri -> {
headerName = meta.headerName
subName = meta.name
Expand Down Expand Up @@ -1343,13 +1347,15 @@ class GeneratorPlayer : FullScreenPlayer() {
is Resource.Loading -> {
startLoading()
}

is Resource.Success -> {
// provider returned false
//if (it.value != true) {
// showToast(activity, R.string.unexpected_error, Toast.LENGTH_SHORT)
//}
startPlayer()
}

is Resource.Failure -> {
showToast(activity, it.errorString, Toast.LENGTH_LONG)
startPlayer()
Expand All @@ -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()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
})
}

Expand Down

0 comments on commit 906f1fd

Please sign in to comment.