Skip to content

Commit

Permalink
simplified code
Browse files Browse the repository at this point in the history
  • Loading branch information
manish99verma authored and Bnyro committed Apr 17, 2024
1 parent c041d94 commit 7c893cd
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
}
}

private fun setPlayerResolution(resolution: Int, isSelectedByUser: Boolean) {
private fun setPlayerResolution(resolution: Int, isSelectedByUser: Boolean = false) {
val transformedResolution = if (!isSelectedByUser && isShort) {
ceil(resolution * 16.0 / 9.0).toInt()
} else {
Expand All @@ -1319,9 +1319,9 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
if (!this::trackSelector.isInitialized) return

if (!isFullscreen && noFullscreenResolution != null) {
setPlayerResolution(noFullscreenResolution!!, false)
setPlayerResolution(noFullscreenResolution!!)
} else if (fullscreenResolution != null) {
setPlayerResolution(fullscreenResolution ?: Int.MAX_VALUE, false)
setPlayerResolution(fullscreenResolution ?: Int.MAX_VALUE)
}
}

Expand Down Expand Up @@ -1495,13 +1495,10 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
if (currentQuality == it.resolution) "${it.name}" else it.name
}
) { which ->
var newResolution = resolutions[which].resolution
val newResolution = resolutions[which].resolution
setPlayerResolution(newResolution, true)

// save the selected resolution to update on fullscreen change
if (isShort) {
newResolution = ceil(newResolution * 9.0 / 16.0).toInt()
}
if (noFullscreenResolution != null && viewModel.isFullscreen.value != true) {
noFullscreenResolution = newResolution
} else {
Expand Down

0 comments on commit 7c893cd

Please sign in to comment.