fix: 暂停时显示ExoPlayer进度条,触摸事件不冲突
This commit is contained in:
@@ -76,6 +76,7 @@ class PlayerActivity : AppCompatActivity() {
|
||||
private var touchStartX = 0f
|
||||
private var isAdjusting = false
|
||||
private var isBrightnessMode = false
|
||||
private var isControllerTouch = false
|
||||
private var startBrightness = 0f
|
||||
private var startVolume = 0
|
||||
private var maxVolume = 0
|
||||
@@ -127,9 +128,11 @@ class PlayerActivity : AppCompatActivity() {
|
||||
override fun onPlayWhenReadyChanged(playWhenReady: Boolean, reason: Int) {
|
||||
if (playWhenReady) {
|
||||
hideHandler.postDelayed(hideRunnable, 4000)
|
||||
playerView.hideController()
|
||||
} else {
|
||||
hideHandler.removeCallbacks(hideRunnable)
|
||||
showControls()
|
||||
playerView.showController()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -387,6 +390,8 @@ class PlayerActivity : AppCompatActivity() {
|
||||
touchStartX = event.x
|
||||
touchStartY = event.y
|
||||
isAdjusting = false
|
||||
isControllerTouch = event.y > view.height * 0.8f
|
||||
if (isControllerTouch) return@OnTouchListener false
|
||||
val halfWidth = view.width / 2
|
||||
isBrightnessMode = touchStartX < halfWidth
|
||||
startBrightness = window.attributes.screenBrightness
|
||||
@@ -418,8 +423,10 @@ class PlayerActivity : AppCompatActivity() {
|
||||
val movedFar = kotlin.math.abs(event.x - touchStartX) > 20f || kotlin.math.abs(event.y - touchStartY) > 20f
|
||||
if (!isAdjusting && !movedFar) {
|
||||
toggleControls()
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user