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(
|
BottomSheetItem(
|
||||||
context.getString(R.string.quality),
|
context.getString(R.string.quality),
|
||||||
R.drawable.ic_hd,
|
R.drawable.ic_hd,
|
||||||
{ "${player?.videoSize?.height}p" }
|
this::getCurrentResolutionSummary
|
||||||
) {
|
) {
|
||||||
playerOptions?.onQualityClicked()
|
playerOptions?.onQualityClicked()
|
||||||
},
|
},
|
||||||
BottomSheetItem(
|
BottomSheetItem(
|
||||||
context.getString(R.string.audio_track),
|
context.getString(R.string.audio_track),
|
||||||
R.drawable.ic_audio,
|
R.drawable.ic_audio,
|
||||||
{ getCurrentAudioTrackTitle() }
|
this::getCurrentAudioTrackTitle
|
||||||
) {
|
) {
|
||||||
playerOptions?.onAudioStreamClicked()
|
playerOptions?.onAudioStreamClicked()
|
||||||
},
|
},
|
||||||
BottomSheetItem(
|
BottomSheetItem(
|
||||||
context.getString(R.string.captions),
|
context.getString(R.string.captions),
|
||||||
R.drawable.ic_caption,
|
R.drawable.ic_caption,
|
||||||
{
|
this::getCurrentCaptionLanguage
|
||||||
if (trackSelector != null && trackSelector!!.parameters.preferredTextLanguages.isNotEmpty()) {
|
|
||||||
trackSelector!!.parameters.preferredTextLanguages[0]
|
|
||||||
} else {
|
|
||||||
context.getString(R.string.none)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
playerOptions?.onCaptionsClicked()
|
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 {
|
private fun getCurrentAudioTrackTitle(): String {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return context.getString(R.string.unknown_or_no_audio)
|
return context.getString(R.string.unknown_or_no_audio)
|
||||||
|
@ -462,6 +462,7 @@
|
|||||||
<string name="no_chapter">No chapter</string>
|
<string name="no_chapter">No chapter</string>
|
||||||
<string name="screen_orientation">Screen orientation</string>
|
<string name="screen_orientation">Screen orientation</string>
|
||||||
<string name="auto_generated">auto-generated</string>
|
<string name="auto_generated">auto-generated</string>
|
||||||
|
<string name="resolution_limited">limited</string>
|
||||||
|
|
||||||
<!-- Notification channel strings -->
|
<!-- Notification channel strings -->
|
||||||
<string name="download_channel_name">Download Service</string>
|
<string name="download_channel_name">Download Service</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user