Merge remote-tracking branch 'origin/master'

This commit is contained in:
LagradOst 2022-06-19 01:03:33 +02:00
commit 95767fb523
3 changed files with 13 additions and 6 deletions

View file

@ -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
@ -202,7 +205,6 @@ class CS3IPlayer : IPlayer {
SubtitleStatus.REQUIRES_RELOAD -> {
Log.i(TAG, "setPreferredSubtitles REQUIRES_RELOAD")
return@let true
// reloadPlayer(context)
}
SubtitleStatus.IS_ACTIVE -> {
Log.i(TAG, "setPreferredSubtitles IS_ACTIVE")
@ -227,7 +229,6 @@ class CS3IPlayer : IPlayer {
//}
}
SubtitleStatus.NOT_FOUND -> {
// not found
Log.i(TAG, "setPreferredSubtitles NOT_FOUND")
return@let true
}
@ -269,7 +270,7 @@ class CS3IPlayer : IPlayer {
subtitleHelper.setSubStyle(style)
}
private fun saveData() {
override fun saveData() {
Log.i(TAG, "saveData")
updatedTime()
@ -511,6 +512,7 @@ class CS3IPlayer : IPlayer {
mediaItem
)
println("PLAYBACK POS $playbackPosition")
return exoPlayerBuilder.build().apply {
setPlayWhenReady(playWhenReady)
seekTo(currentWindow, playbackPosition)

View file

@ -375,8 +375,10 @@ class GeneratorPlayer : FullScreenPlayer() {
setSubtitles(subtitleData)
// this is used instead of observe, because observe is too slow
val subs = currentSubs.toMutableSet()
subs.add(subtitleData)
val subs = currentSubs + subtitleData
// Save current time as to not reset player to 00:00
player.saveData()
player.setActiveSubtitles(subs)
player.reloadPlayer(ctx)
@ -774,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
@ -794,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

View file

@ -90,6 +90,8 @@ interface IPlayer {
)
fun updateSubtitleStyle(style: SaveCaptionStyle)
fun saveData()
fun loadPlayer(
context: Context,
sameEpisode: Boolean,