mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Set title for external subtitles
This commit is contained in:
parent
5b07512d75
commit
135bf90b3b
2 changed files with 29 additions and 17 deletions
|
|
@ -568,6 +568,7 @@ class PlaybackViewModel
|
|||
).setId("e:${it.index}")
|
||||
.setMimeType(subtitleMimeTypes[it.codec])
|
||||
.setLanguage(it.language)
|
||||
.setLabel(it.title)
|
||||
.setSelectionFlags(flags)
|
||||
.build()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -328,6 +328,7 @@ class MpvPlayer(
|
|||
}
|
||||
Timber.v("TrackSelection: Got ${parameters.overrides.size} overrides")
|
||||
parameters.overrides.forEach { (trackGroup, trackSelectionOverride) ->
|
||||
val result =
|
||||
tracks.groups.firstOrNull { it.mediaTrackGroup == trackGroup }?.let {
|
||||
val id = it.mediaTrackGroup.getFormat(0).id
|
||||
val splits = id?.split(":")
|
||||
|
|
@ -342,8 +343,18 @@ class MpvPlayer(
|
|||
Timber.v("TrackSelection: activating %s %s '%s'", propertyName, trackId, id)
|
||||
if (trackId != null && propertyName != null) {
|
||||
MPVLib.setPropertyString(propertyName, trackId)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
if (result != true) {
|
||||
Timber.w(
|
||||
"Did not find track to select for type=%s, id=%s",
|
||||
trackGroup.type,
|
||||
trackGroup.getFormat(0).id,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -586,8 +597,9 @@ class MpvPlayer(
|
|||
Timber.d("event: MPV_EVENT_FILE_LOADED")
|
||||
mediaItem!!.localConfiguration?.subtitleConfigurations?.forEach {
|
||||
val url = it.uri.toString()
|
||||
Timber.v("Adding external subtitle track $url")
|
||||
MPVLib.command(arrayOf("sub-add", url, "auto"))
|
||||
val title = it.label ?: "External Subtitles"
|
||||
Timber.v("Adding external subtitle track '$title'")
|
||||
MPVLib.command(arrayOf("sub-add", url, "auto", title))
|
||||
}
|
||||
getTracks().let {
|
||||
notifyListeners(EVENT_TRACKS_CHANGED) { onTracksChanged(it) }
|
||||
|
|
@ -685,8 +697,7 @@ class MpvPlayer(
|
|||
val isExternal = MPVLib.getPropertyBoolean("track-list/$idx/external") ?: false
|
||||
val isSelected = MPVLib.getPropertyBoolean("track-list/$idx/selected") ?: false
|
||||
val channelCount = MPVLib.getPropertyInt("track-list/$idx/demux-channel-count")
|
||||
val title =
|
||||
if (type != "sub" || !isExternal) MPVLib.getPropertyString("track-list/$idx/title") else null
|
||||
val title = MPVLib.getPropertyString("track-list/$idx/title")
|
||||
|
||||
if (type != null && id != null) {
|
||||
// TODO do we need the real mimetypes?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue