mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +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}")
|
).setId("e:${it.index}")
|
||||||
.setMimeType(subtitleMimeTypes[it.codec])
|
.setMimeType(subtitleMimeTypes[it.codec])
|
||||||
.setLanguage(it.language)
|
.setLanguage(it.language)
|
||||||
|
.setLabel(it.title)
|
||||||
.setSelectionFlags(flags)
|
.setSelectionFlags(flags)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -328,6 +328,7 @@ class MpvPlayer(
|
||||||
}
|
}
|
||||||
Timber.v("TrackSelection: Got ${parameters.overrides.size} overrides")
|
Timber.v("TrackSelection: Got ${parameters.overrides.size} overrides")
|
||||||
parameters.overrides.forEach { (trackGroup, trackSelectionOverride) ->
|
parameters.overrides.forEach { (trackGroup, trackSelectionOverride) ->
|
||||||
|
val result =
|
||||||
tracks.groups.firstOrNull { it.mediaTrackGroup == trackGroup }?.let {
|
tracks.groups.firstOrNull { it.mediaTrackGroup == trackGroup }?.let {
|
||||||
val id = it.mediaTrackGroup.getFormat(0).id
|
val id = it.mediaTrackGroup.getFormat(0).id
|
||||||
val splits = id?.split(":")
|
val splits = id?.split(":")
|
||||||
|
|
@ -342,8 +343,18 @@ class MpvPlayer(
|
||||||
Timber.v("TrackSelection: activating %s %s '%s'", propertyName, trackId, id)
|
Timber.v("TrackSelection: activating %s %s '%s'", propertyName, trackId, id)
|
||||||
if (trackId != null && propertyName != null) {
|
if (trackId != null && propertyName != null) {
|
||||||
MPVLib.setPropertyString(propertyName, trackId)
|
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")
|
Timber.d("event: MPV_EVENT_FILE_LOADED")
|
||||||
mediaItem!!.localConfiguration?.subtitleConfigurations?.forEach {
|
mediaItem!!.localConfiguration?.subtitleConfigurations?.forEach {
|
||||||
val url = it.uri.toString()
|
val url = it.uri.toString()
|
||||||
Timber.v("Adding external subtitle track $url")
|
val title = it.label ?: "External Subtitles"
|
||||||
MPVLib.command(arrayOf("sub-add", url, "auto"))
|
Timber.v("Adding external subtitle track '$title'")
|
||||||
|
MPVLib.command(arrayOf("sub-add", url, "auto", title))
|
||||||
}
|
}
|
||||||
getTracks().let {
|
getTracks().let {
|
||||||
notifyListeners(EVENT_TRACKS_CHANGED) { onTracksChanged(it) }
|
notifyListeners(EVENT_TRACKS_CHANGED) { onTracksChanged(it) }
|
||||||
|
|
@ -685,8 +697,7 @@ class MpvPlayer(
|
||||||
val isExternal = MPVLib.getPropertyBoolean("track-list/$idx/external") ?: false
|
val isExternal = MPVLib.getPropertyBoolean("track-list/$idx/external") ?: false
|
||||||
val isSelected = MPVLib.getPropertyBoolean("track-list/$idx/selected") ?: false
|
val isSelected = MPVLib.getPropertyBoolean("track-list/$idx/selected") ?: false
|
||||||
val channelCount = MPVLib.getPropertyInt("track-list/$idx/demux-channel-count")
|
val channelCount = MPVLib.getPropertyInt("track-list/$idx/demux-channel-count")
|
||||||
val title =
|
val title = MPVLib.getPropertyString("track-list/$idx/title")
|
||||||
if (type != "sub" || !isExternal) MPVLib.getPropertyString("track-list/$idx/title") else null
|
|
||||||
|
|
||||||
if (type != null && id != null) {
|
if (type != null && id != null) {
|
||||||
// TODO do we need the real mimetypes?
|
// TODO do we need the real mimetypes?
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue