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