check if subtitles are added before removing them

Signed-off-by: Toni Förster <toni.foerster@gmail.com>
This commit is contained in:
Toni Förster
2024-09-09 14:18:49 +02:00
parent 5e85fd294c
commit 0de0445805
2 changed files with 32 additions and 8 deletions

View File

@@ -25,7 +25,9 @@ final class MPVBackend: PlayerBackend {
var video: Video?
var captions: Captions? { didSet {
guard let captions else {
client?.removeSubs()
if client?.areSubtitlesAdded == true {
client?.removeSubs()
}
return
}
addSubTrack(captions.url)
@@ -615,7 +617,9 @@ final class MPVBackend: PlayerBackend {
}
func addSubTrack(_ url: URL) {
client?.removeSubs()
if client?.areSubtitlesAdded == true {
client?.removeSubs()
}
client?.addSubTrack(url)
}