mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Fixed online subs resetting progress (for real this time)
This commit is contained in:
parent
b619ee9bf8
commit
cc7d7ec478
3 changed files with 16 additions and 12 deletions
|
@ -187,6 +187,9 @@ class CS3IPlayer : IPlayer {
|
|||
}
|
||||
|
||||
var currentSubtitles: SubtitleData? = null
|
||||
/**
|
||||
* @return True if the player should be reloaded
|
||||
* */
|
||||
override fun setPreferredSubtitles(subtitle: SubtitleData?): Boolean {
|
||||
Log.i(TAG, "setPreferredSubtitles init $subtitle")
|
||||
currentSubtitles = subtitle
|
||||
|
@ -199,15 +202,11 @@ class CS3IPlayer : IPlayer {
|
|||
)
|
||||
} else {
|
||||
when (subtitleHelper.subtitleStatus(subtitle)) {
|
||||
|
||||
// Uncommenting this will lead to online subtitles resetting player to 00:00 on reload
|
||||
|
||||
// SubtitleStatus.REQUIRES_RELOAD -> {
|
||||
// Log.i(TAG, "setPreferredSubtitles REQUIRES_RELOAD")
|
||||
// return@let true
|
||||
// // reloadPlayer(context)
|
||||
// }
|
||||
SubtitleStatus.IS_ACTIVE, SubtitleStatus.REQUIRES_RELOAD -> {
|
||||
SubtitleStatus.REQUIRES_RELOAD -> {
|
||||
Log.i(TAG, "setPreferredSubtitles REQUIRES_RELOAD")
|
||||
return@let true
|
||||
}
|
||||
SubtitleStatus.IS_ACTIVE -> {
|
||||
Log.i(TAG, "setPreferredSubtitles IS_ACTIVE")
|
||||
|
||||
trackSelector.setParameters(
|
||||
|
@ -230,7 +229,6 @@ class CS3IPlayer : IPlayer {
|
|||
//}
|
||||
}
|
||||
SubtitleStatus.NOT_FOUND -> {
|
||||
// not found
|
||||
Log.i(TAG, "setPreferredSubtitles NOT_FOUND")
|
||||
return@let true
|
||||
}
|
||||
|
@ -272,7 +270,7 @@ class CS3IPlayer : IPlayer {
|
|||
subtitleHelper.setSubStyle(style)
|
||||
}
|
||||
|
||||
private fun saveData() {
|
||||
override fun saveData() {
|
||||
Log.i(TAG, "saveData")
|
||||
updatedTime()
|
||||
|
||||
|
|
|
@ -376,6 +376,9 @@ class GeneratorPlayer : FullScreenPlayer() {
|
|||
|
||||
// this is used instead of observe, because observe is too slow
|
||||
val subs = currentSubs + subtitleData
|
||||
|
||||
// Save current time as to not reset player to 00:00
|
||||
player.saveData()
|
||||
player.setActiveSubtitles(subs)
|
||||
player.reloadPlayer(ctx)
|
||||
|
||||
|
@ -773,11 +776,11 @@ class GeneratorPlayer : FullScreenPlayer() {
|
|||
private fun autoSelectFromSettings(): Boolean {
|
||||
// auto select subtitle based of settings
|
||||
val langCode = preferredAutoSelectSubtitles
|
||||
|
||||
if (!langCode.isNullOrEmpty() && player.getCurrentPreferredSubtitle() == null) {
|
||||
getAutoSelectSubtitle(currentSubs, settings = true, downloads = false)?.let { sub ->
|
||||
context?.let { ctx ->
|
||||
if (setSubtitles(sub)) {
|
||||
player.saveData()
|
||||
player.reloadPlayer(ctx)
|
||||
player.handleEvent(CSPlayerEvent.Play)
|
||||
return true
|
||||
|
@ -793,6 +796,7 @@ class GeneratorPlayer : FullScreenPlayer() {
|
|||
getAutoSelectSubtitle(currentSubs, settings = false, downloads = true)?.let { sub ->
|
||||
context?.let { ctx ->
|
||||
if (setSubtitles(sub)) {
|
||||
player.saveData()
|
||||
player.reloadPlayer(ctx)
|
||||
player.handleEvent(CSPlayerEvent.Play)
|
||||
return true
|
||||
|
|
|
@ -90,6 +90,8 @@ interface IPlayer {
|
|||
)
|
||||
|
||||
fun updateSubtitleStyle(style: SaveCaptionStyle)
|
||||
fun saveData()
|
||||
|
||||
fun loadPlayer(
|
||||
context: Context,
|
||||
sameEpisode: Boolean,
|
||||
|
|
Loading…
Reference in a new issue