mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-16 23:12:12 +00:00
feat: auto fetchfetch addon subtitles
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
8134194461
commit
40588e0ed6
1 changed files with 14 additions and 5 deletions
|
|
@ -1036,6 +1036,12 @@ fun PlayerScreen(
|
|||
controlsVisible = false
|
||||
}
|
||||
|
||||
fun fetchAddonSubtitlesForActiveItem() {
|
||||
val type = contentType ?: return
|
||||
val videoId = activeVideoId ?: return
|
||||
SubtitleRepository.fetchAddonSubtitles(type, videoId)
|
||||
}
|
||||
|
||||
LaunchedEffect(activeSourceUrl, activeSourceAudioUrl, activeSourceHeaders, activeSourceResponseHeaders) {
|
||||
errorMessage = null
|
||||
playerController = null
|
||||
|
|
@ -1066,6 +1072,13 @@ fun PlayerScreen(
|
|||
playerController?.applySubtitleStyle(subtitleStyle)
|
||||
}
|
||||
|
||||
LaunchedEffect(showSubtitleModal, activeSubtitleTab, contentType, activeVideoId) {
|
||||
if (!showSubtitleModal || activeSubtitleTab != SubtitleTab.Addons) return@LaunchedEffect
|
||||
if (!isLoadingAddonSubtitles && addonSubtitles.isEmpty()) {
|
||||
fetchAddonSubtitlesForActiveItem()
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(playbackSnapshot.isLoading, playerController) {
|
||||
if (!playbackSnapshot.isLoading && playerController != null) {
|
||||
refreshTracks()
|
||||
|
|
@ -1709,11 +1722,7 @@ fun PlayerScreen(
|
|||
useCustomSubtitles = true
|
||||
playerController?.setSubtitleUri(addon.url)
|
||||
},
|
||||
onFetchAddonSubtitles = {
|
||||
if (contentType != null && activeVideoId != null) {
|
||||
SubtitleRepository.fetchAddonSubtitles(contentType, activeVideoId!!)
|
||||
}
|
||||
},
|
||||
onFetchAddonSubtitles = ::fetchAddonSubtitlesForActiveItem,
|
||||
onStyleChanged = PlayerSettingsRepository::setSubtitleStyle,
|
||||
onDismiss = { showSubtitleModal = false },
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue