1
0
Fork 0
mirror of https://gitlab.com/futo-org/fcast.git synced 2025-06-24 21:25:23 +00:00

Fixed controls not being accessible due to DPAD handling.

This commit is contained in:
Koen 2023-08-18 10:59:16 +02:00
parent 72bc635dfd
commit 631f2e3e27
3 changed files with 23 additions and 15 deletions

View file

@ -0,0 +1,8 @@
package com.futo.fcast.receiver
import android.content.Context
import android.util.AttributeSet
import android.view.KeyEvent
import com.google.android.exoplayer2.ui.StyledPlayerView
class CustomStyledPlayerView(context: Context, attrs: AttributeSet? = null) : StyledPlayerView(context, attrs) { }

View file

@ -245,26 +245,26 @@ class PlayerActivity : AppCompatActivity() {
TcpListenerService.activityCount--
}
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_DPAD_LEFT -> {
val newPosition = _exoPlayer.currentPosition - 10000
_exoPlayer.seekTo(max(0, newPosition))
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
if (_playerControlView.isControllerFullyVisible) {
if (event.keyCode == KeyEvent.KEYCODE_BACK) {
_playerControlView.hideController()
return true
}
KeyEvent.KEYCODE_DPAD_RIGHT -> {
val newPosition = _exoPlayer.currentPosition + 10000
_exoPlayer.seekTo(newPosition)
return true
}
KeyEvent.KEYCODE_BACK -> {
if (_playerControlView.isControllerFullyVisible) {
_playerControlView.hideController()
} else {
when (event.keyCode) {
KeyEvent.KEYCODE_DPAD_LEFT -> {
_exoPlayer.seekTo(max(0, _exoPlayer.currentPosition - SEEK_BACKWARD_MILLIS))
return true
}
KeyEvent.KEYCODE_DPAD_RIGHT -> {
_exoPlayer.seekTo(_exoPlayer.currentPosition + SEEK_FORWARD_MILLIS)
return true
}
}
}
return super.onKeyDown(keyCode, event)
return super.dispatchKeyEvent(event)
}
fun play(playMessage: PlayMessage) {

View file

@ -6,7 +6,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/black">
<com.google.android.exoplayer2.ui.StyledPlayerView
<com.futo.fcast.receiver.CustomStyledPlayerView
android:id="@+id/player_control_view"
android:layout_width="match_parent"
android:layout_height="match_parent"