Skip to content

Commit

Permalink
simplified code
Browse files Browse the repository at this point in the history
  • Loading branch information
manish99verma committed Apr 2, 2024
1 parent c041d94 commit 6f8c9f2
Showing 1 changed file with 5 additions and 4 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 @@ -1498,10 +1498,11 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
var 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()
}

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

0 comments on commit 6f8c9f2

Please sign in to comment.