mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
Merge pull request #2361 from Bnyro/master
Hightlight the current resolution in the quality selection
This commit is contained in:
commit
90f3a716a6
@ -106,8 +106,9 @@ class DownloadService : Service() {
|
|||||||
DownloadManager.EXTRA_DOWNLOAD_ID,
|
DownloadManager.EXTRA_DOWNLOAD_ID,
|
||||||
-1
|
-1
|
||||||
)
|
)
|
||||||
if (downloadId == audioDownloadId) audioDownloadId = null
|
if (downloadId == audioDownloadId) {
|
||||||
else if (downloadId == videoDownloadId) videoDownloadId = null
|
audioDownloadId = null
|
||||||
|
} else if (downloadId == videoDownloadId) videoDownloadId = null
|
||||||
|
|
||||||
if (audioDownloadId != null || videoDownloadId != null) return
|
if (audioDownloadId != null || videoDownloadId != null) return
|
||||||
|
|
||||||
|
@ -1133,12 +1133,12 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
if (resolutions.isEmpty()) {
|
if (resolutions.isEmpty()) {
|
||||||
return listOf(
|
return listOf(
|
||||||
VideoResolution(getString(R.string.hls), adaptiveSourceUrl = streams.hls)
|
VideoResolution(getString(R.string.hls), resolution = Int.MAX_VALUE, adaptiveSourceUrl = streams.hls)
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
resolutions.add(0, VideoResolution(getString(R.string.auto_quality), Int.MAX_VALUE))
|
||||||
}
|
}
|
||||||
|
|
||||||
resolutions.add(0, VideoResolution(getString(R.string.auto_quality), null))
|
|
||||||
|
|
||||||
return resolutions
|
return resolutions
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1176,12 +1176,9 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setPlayerResolution(resolution: Int?) {
|
private fun setPlayerResolution(resolution: Int) {
|
||||||
val params = trackSelector.buildUponParameters()
|
val params = trackSelector.buildUponParameters()
|
||||||
when (resolution) {
|
params.setMaxVideoSize(Int.MAX_VALUE, resolution).setMinVideoSize(Int.MIN_VALUE, resolution)
|
||||||
null -> params.setMaxVideoSize(Int.MAX_VALUE, Int.MAX_VALUE).setMinVideoSize(0, 0)
|
|
||||||
else -> params.setMaxVideoSize(Int.MAX_VALUE, resolution).setMinVideoSize(Int.MIN_VALUE, resolution)
|
|
||||||
}
|
|
||||||
trackSelector.setParameters(params)
|
trackSelector.setParameters(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1327,13 +1324,18 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
override fun onQualityClicked() {
|
override fun onQualityClicked() {
|
||||||
// get the available resolutions
|
// get the available resolutions
|
||||||
val resolutions = getAvailableResolutions()
|
val resolutions = getAvailableResolutions()
|
||||||
|
val currentQuality = trackSelector.parameters.maxVideoHeight
|
||||||
|
|
||||||
// Dialog for quality selection
|
// Dialog for quality selection
|
||||||
BaseBottomSheet()
|
BaseBottomSheet()
|
||||||
.setSimpleItems(
|
.setSimpleItems(
|
||||||
resolutions.map { it.name }
|
resolutions.map {
|
||||||
|
if (currentQuality == it.resolution) "${it.name} ✓" else it.name
|
||||||
|
}
|
||||||
) { which ->
|
) { which ->
|
||||||
setPlayerResolution(resolutions[which].resolution)
|
resolutions[which].resolution?.let {
|
||||||
|
setPlayerResolution(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.show(childFragmentManager)
|
.show(childFragmentManager)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user