mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Implemented center double tap to play/pause.
This commit is contained in:
@@ -42,6 +42,7 @@ import kotlinx.coroutines.launch
|
||||
import java.text.DecimalFormat
|
||||
import java.text.DecimalFormatSymbols
|
||||
import java.util.Locale
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
class GestureControlView : LinearLayout {
|
||||
@@ -114,6 +115,7 @@ class GestureControlView : LinearLayout {
|
||||
val onZoom = Event1<Float>();
|
||||
val onSoundAdjusted = Event1<Float>();
|
||||
val onToggleFullscreen = Event0();
|
||||
val onTogglePlayPause = Event0();
|
||||
val onSpeedHoldStart = Event0()
|
||||
val onSpeedHoldEnd = Event0()
|
||||
|
||||
@@ -269,8 +271,19 @@ class GestureControlView : LinearLayout {
|
||||
return false;
|
||||
}
|
||||
|
||||
val rewinding = (ev.x / width) < 0.5;
|
||||
startFastForward(rewinding);
|
||||
val centerArea = 0.2
|
||||
val rewindArea = (1 - centerArea) / 2
|
||||
val forwardArea = rewindArea
|
||||
assert(abs(centerArea + rewindArea + forwardArea - 1) < 0.01)
|
||||
|
||||
val xfrac = ev.x / width
|
||||
if (xfrac <= rewindArea) {
|
||||
startFastForward(true)
|
||||
} else if (xfrac >= 1 - forwardArea) {
|
||||
startFastForward(false)
|
||||
} else {
|
||||
onTogglePlayPause.emit()
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,15 @@ class CastView : ConstraintLayout {
|
||||
Logger.e(TAG, "Failed to change playback speed to previous hold playback speed: $e")
|
||||
}
|
||||
}
|
||||
_gestureControlView.onTogglePlayPause.subscribe {
|
||||
StateCasting.instance.activeDevice?.let { d ->
|
||||
if (d.isPlaying) {
|
||||
d.pausePlayback()
|
||||
} else {
|
||||
d.resumePlayback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_gestureControlView.onSeek.subscribe {
|
||||
val d = StateCasting.instance.activeDevice ?: return@subscribe;
|
||||
|
||||
@@ -285,6 +285,15 @@ class FutoVideoPlayer : FutoVideoPlayerBase {
|
||||
player.play()
|
||||
}
|
||||
}
|
||||
gestureControl.onTogglePlayPause.subscribe {
|
||||
exoPlayer?.player?.let { player ->
|
||||
if (player.playWhenReady) {
|
||||
player.pause()
|
||||
} else {
|
||||
player.play()
|
||||
}
|
||||
}
|
||||
}
|
||||
gestureControl.onSpeedHoldEnd.subscribe {
|
||||
exoPlayer?.player?.let { player ->
|
||||
if (!_speedHoldWasPlaying) player.pause()
|
||||
|
||||
Reference in New Issue
Block a user