Ignore unknown audio track types

Co-authored-by: AudricV <74829229+AudricV@users.noreply.github.com>
This commit is contained in:
Bnyro 2023-07-16 17:33:37 +02:00
parent 9d25d32bff
commit df4df4fccc
2 changed files with 14 additions and 14 deletions

View File

@ -115,14 +115,18 @@ object DashHelper {
adapSetElement.setAttribute("lang", adapSet.audioLocale) adapSetElement.setAttribute("lang", adapSet.audioLocale)
} }
val roleElement = doc.createElement("Role") // Only add the Role element if there is a track type set
roleElement.setAttribute("schemeIdUri", "urn:mpeg:dash:role:2011") // This allows distinction between formats marked as original on YouTube and
roleElement.setAttribute( // formats without track type info set
"value", if (adapSet.audioTrackType != null) {
getRoleValueFromAudioTrackType(adapSet.audioTrackType) val roleElement = doc.createElement("Role")
) roleElement.setAttribute("schemeIdUri", "urn:mpeg:dash:role:2011")
roleElement.setAttribute(
adapSetElement.appendChild(roleElement) "value",
getRoleValueFromAudioTrackType(adapSet.audioTrackType)
)
adapSetElement.appendChild(roleElement)
}
val isVideo = adapSet.mimeType.contains("video") val isVideo = adapSet.mimeType.contains("video")
@ -198,11 +202,7 @@ object DashHelper {
return segmentBase return segmentBase
} }
private fun getRoleValueFromAudioTrackType(audioTrackType: String?): String { private fun getRoleValueFromAudioTrackType(audioTrackType: String): String {
if (audioTrackType == null) {
return "main"
}
return when (audioTrackType.lowercase()) { return when (audioTrackType.lowercase()) {
"descriptive" -> "description" "descriptive" -> "description"
"dubbed" -> "dub" "dubbed" -> "dub"

View File

@ -1429,7 +1429,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
} }
.show(childFragmentManager) .show(childFragmentManager)
} }
override fun onAudioStreamClicked() { override fun onAudioStreamClicked() {
val context = requireContext() val context = requireContext()
val audioLanguagesAndRoleFlags = PlayerHelper.getAudioLanguagesAndRoleFlagsFromTrackGroups( val audioLanguagesAndRoleFlags = PlayerHelper.getAudioLanguagesAndRoleFlagsFromTrackGroups(