Skip to content

Commit a47c11d

Browse files
committed
feat(player): Optimize the subtitle switching logic
1 parent 545914f commit a47c11d

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

composeApp/src/commonMain/kotlin/com/jankinwu/fntv/client/data/model/PlayingInfoCache.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ data class PlayingInfoCache(
2828
var currentSubtitleStreamList: List<SubtitleStream>? = null,
2929
var isUseDirectLink: Boolean = false,
3030
var isEpisode: Boolean = false,
31+
var previousSubtitle: SubtitleStream? = null,
3132
)

composeApp/src/commonMain/kotlin/com/jankinwu/fntv/client/ui/screen/PlayerScreen.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,9 @@ fun PlayerOverlay(
496496
// Reload HLS subtitle repository to fetch new segments
497497
hlsSubtitleUtil?.reload()
498498
// Don't restart playback for internal subtitles
499-
shouldStartPlayback = false
499+
if (cache.previousSubtitle?.isExternal == 0) {
500+
shouldStartPlayback = false
501+
}
500502
}
501503
} catch (e: Exception) {
502504
logger.w("ResetSubtitle: Failed to parse m3u8: ${e.message}")
@@ -1050,6 +1052,7 @@ fun PlayerOverlay(
10501052
if (cache != null) {
10511053
playerViewModel.updatePlayingInfo(
10521054
cache.copy(
1055+
previousSubtitle = cache.currentSubtitleStream,
10531056
currentSubtitleStream = subtitle
10541057
)
10551058
)

composeApp/src/commonMain/kotlin/com/jankinwu/fntv/client/utils/HlsSubtitleUtil.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ class HlsSubtitleUtil(
6060
}
6161

6262
return client.get(fullUrl) {
63-
if (AccountDataCache.cookieState.isNotBlank()) {
64-
header("cookie", AccountDataCache.cookieState)
65-
header("Authorization", AccountDataCache.authorization)
66-
}
63+
// if (AccountDataCache.cookieState.isNotBlank()) {
64+
// header("cookie", AccountDataCache.cookieState)
65+
// header("Authorization", AccountDataCache.authorization)
66+
// }
6767
}.bodyAsText()
6868
}
6969

0 commit comments

Comments
 (0)