Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复字幕轨道自动切换 #1143

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class VlcjVideoPlayerState(parentCoroutineContext: CoroutineContext) : PlayerSta
}

private fun reloadSubtitleTracks() {
subtitleTracks.candidates.value = player.subpictures().trackDescriptions()
val newSubtitleTracks = player.subpictures().trackDescriptions()
.filterNot { it.id() == -1 } // "Disable"
.map {
SubtitleTrack(
Expand All @@ -451,7 +451,11 @@ class VlcjVideoPlayerState(parentCoroutineContext: CoroutineContext) : PlayerSta
listOf(Label(null, it.description())),
)
}
subtitleTracks.current.value = subtitleTracks.candidates.value.firstOrNull()
// 新的字幕轨道和原来不同时才会更改,同时将 current 设置为新字幕轨道列表的第一个
if (subtitleTracks.candidates.value != newSubtitleTracks) {
subtitleTracks.candidates.value = newSubtitleTracks
subtitleTracks.current.value = newSubtitleTracks.firstOrNull()
}
}

private fun reloadAudioTracks() {
Expand Down
Loading