mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
Merge pull request #4517 from Bnyro/master
feat(player): show if quality is auto or limited
This commit is contained in:
commit
8653143d10
@ -32,27 +32,21 @@ class OnlinePlayerView(
|
||||
BottomSheetItem(
|
||||
context.getString(R.string.quality),
|
||||
R.drawable.ic_hd,
|
||||
{ "${player?.videoSize?.height}p" }
|
||||
this::getCurrentResolutionSummary
|
||||
) {
|
||||
playerOptions?.onQualityClicked()
|
||||
},
|
||||
BottomSheetItem(
|
||||
context.getString(R.string.audio_track),
|
||||
R.drawable.ic_audio,
|
||||
{ getCurrentAudioTrackTitle() }
|
||||
this::getCurrentAudioTrackTitle
|
||||
) {
|
||||
playerOptions?.onAudioStreamClicked()
|
||||
},
|
||||
BottomSheetItem(
|
||||
context.getString(R.string.captions),
|
||||
R.drawable.ic_caption,
|
||||
{
|
||||
if (trackSelector != null && trackSelector!!.parameters.preferredTextLanguages.isNotEmpty()) {
|
||||
trackSelector!!.parameters.preferredTextLanguages[0]
|
||||
} else {
|
||||
context.getString(R.string.none)
|
||||
}
|
||||
}
|
||||
this::getCurrentCaptionLanguage
|
||||
) {
|
||||
playerOptions?.onCaptionsClicked()
|
||||
},
|
||||
@ -65,6 +59,29 @@ class OnlinePlayerView(
|
||||
)
|
||||
}
|
||||
|
||||
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
|
||||
private fun getCurrentResolutionSummary(): String {
|
||||
val currentQuality = player?.videoSize?.height ?: 0
|
||||
var summary = "${currentQuality}p"
|
||||
val trackSelector = trackSelector ?: return summary
|
||||
val selectedQuality = trackSelector.parameters.maxVideoHeight
|
||||
if (selectedQuality == Int.MAX_VALUE) {
|
||||
summary += " - ${context.getString(R.string.auto)}"
|
||||
} else if (selectedQuality > currentQuality) {
|
||||
summary += " - ${context.getString(R.string.resolution_limited)}"
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
|
||||
private fun getCurrentCaptionLanguage(): String {
|
||||
return if (trackSelector != null && trackSelector!!.parameters.preferredTextLanguages.isNotEmpty()) {
|
||||
trackSelector!!.parameters.preferredTextLanguages[0]
|
||||
} else {
|
||||
context.getString(R.string.none)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCurrentAudioTrackTitle(): String {
|
||||
if (player == null) {
|
||||
return context.getString(R.string.unknown_or_no_audio)
|
||||
|
@ -462,6 +462,7 @@
|
||||
<string name="no_chapter">No chapter</string>
|
||||
<string name="screen_orientation">Screen orientation</string>
|
||||
<string name="auto_generated">auto-generated</string>
|
||||
<string name="resolution_limited">limited</string>
|
||||
|
||||
<!-- Notification channel strings -->
|
||||
<string name="download_channel_name">Download Service</string>
|
||||
|
Loading…
Reference in New Issue
Block a user