mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-25 22:29:45 +03:00
fix subs staying loaded
This commit is contained in:
parent
009e2962e0
commit
885be41819
1 changed files with 22 additions and 9 deletions
|
@ -458,15 +458,9 @@ class PlayerActivity :
|
|||
player.timePos?.let {
|
||||
MPVLib.command(arrayOf("set", "start", "${player.timePos}"))
|
||||
}
|
||||
subTracks = arrayOf(Track("nothing", "Off")) + it.subtitleTracks.toTypedArray()
|
||||
audioTracks = arrayOf(Track("nothing", "Off")) + it.audioTracks.toTypedArray()
|
||||
MPVLib.command(arrayOf("loadfile", it.videoUrl))
|
||||
subTracks = arrayOf(Track("nothing", "Off")) + it.subtitleTracks.toTypedArray() +
|
||||
player.tracks.getValue("sub").map { track ->
|
||||
Track("mpv", track.name)
|
||||
}.toTypedArray()
|
||||
subTracks = arrayOf(Track("nothing", "Off")) + it.subtitleTracks.toTypedArray() +
|
||||
player.tracks.getValue("audio").map { track ->
|
||||
Track("mpv", track.name)
|
||||
}.toTypedArray()
|
||||
}
|
||||
launchUI { refreshUi() }
|
||||
}
|
||||
|
@ -572,9 +566,9 @@ class PlayerActivity :
|
|||
MPVLib.command(arrayOf("set", "start", "$intPos"))
|
||||
}
|
||||
setViewMode()
|
||||
MPVLib.command(arrayOf("loadfile", it.videoUrl))
|
||||
subTracks = arrayOf(Track("nothing", "Off")) + it.subtitleTracks.toTypedArray()
|
||||
audioTracks = arrayOf(Track("nothing", "Off")) + it.audioTracks.toTypedArray()
|
||||
MPVLib.command(arrayOf("loadfile", it.videoUrl))
|
||||
}
|
||||
launchUI { refreshUi() }
|
||||
}
|
||||
|
@ -603,7 +597,26 @@ class PlayerActivity :
|
|||
// MPVLib.setOptionString("cache-dir", cacheDir)
|
||||
}
|
||||
|
||||
private fun clearTracks() {
|
||||
val count = MPVLib.getPropertyInt("track-list/count")!!
|
||||
// Note that because events are async, properties might disappear at any moment
|
||||
// so use ?: continue instead of !!
|
||||
for (i in 0 until count) {
|
||||
val type = MPVLib.getPropertyString("track-list/$i/type") ?: continue
|
||||
if (!player.tracks.containsKey(type)) {
|
||||
continue
|
||||
}
|
||||
val mpvId = MPVLib.getPropertyInt("track-list/$i/id") ?: continue
|
||||
when (type) {
|
||||
"video" -> MPVLib.command(arrayOf("video-remove", "$mpvId"))
|
||||
"audio" -> MPVLib.command(arrayOf("audio-remove", "$mpvId"))
|
||||
"sub" -> MPVLib.command(arrayOf("sub-remove", "$mpvId"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun fileLoaded() {
|
||||
clearTracks()
|
||||
player.loadTracks()
|
||||
subTracks += player.tracks.getValue("sub")
|
||||
.drop(1).map { track ->
|
||||
|
|
Loading…
Reference in a new issue