PlayerGestureHelper

Handles all gesture, volume, brightness, speed-up, zoom, and hardware-key-event input for a PlayerView. Keeps these separate from the player-view setup and lifecycle code in PlayerView itself.

Instantiated and owned by PlayerView; accessed from host fragments via the delegate properties PlayerView exposes.

Constructors

Link copied to clipboard
constructor(playerView: PlayerView)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Properties

Link copied to clipboard

White overlay inflated into exo_content_frame; alpha encodes extra brightness (0–1).

Link copied to clipboard
Link copied to clipboard

Action from the previous touch sequence; guards against mis-detected double-taps after swipes.

Link copied to clipboard

Brightness state

Link copied to clipboard

Volume state

Link copied to clipboard

Current in-progress swipe action, null when no swipe is active.

Link copied to clipboard
var desiredMatrix: Matrix?

The matrix the zoom will animate to after the user lifts fingers.

Link copied to clipboard

Whether double-tapping left/right seeks backward/forward.

Link copied to clipboard

Whether double-tapping the center of the screen pauses (left/right still seeks if doubleTapEnabled).

Link copied to clipboard
Link copied to clipboard

Seek distance (ms) for each double-tap seek. Read from prefs in initialize.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val holdHandler: Handler

Hold / speed-up

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Touch tracking

Link copied to clipboard

Set true by the host when the player occupies the full screen. Controls whether hardware volume-key overrides are active (phones/emulators only).

Link copied to clipboard

Mirrors the host's lock state; suppresses gesture interactions when true.

Link copied to clipboard
Link copied to clipboard

Midpoint of the two-finger pan, null when no pan is active.

Link copied to clipboard

System time of the most-recent touch end. Updated by callers at the end of every ACTION_UP.

Link copied to clipboard
var matrixAnimation: ValueAnimator?

Running snap-back animation, or null.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Gesture settings (read from prefs in initialize)

Link copied to clipboard

Whether the player UI was visible when the current swipe gesture began.

Link copied to clipboard

When true, read/write system brightness via Settings.System.SCREEN_BRIGHTNESS. Automatically falls back to window-attribute brightness if the permission is missing.

Link copied to clipboard
var videoOutline: View?

Optional view for showing the snap-hint outline during zoom (set by FullScreenPlayer).

Link copied to clipboard
var zoomMatrix: Matrix?

Current zoom+pan matrix, or null when no zoom is active.

Functions

Link copied to clipboard

Fades playerRewHolder, playerFfwdHolder, and playerPausePlay to fadeTo (0f or 1f). Always resets the holder alphas to 1f first so any stale fillAfter state is cleared. Called from host fragments' show/hide control animations so both GeneratorPlayer and trailer share the same fade logic.

Link copied to clipboard
fun applyZoomMatrix(newMatrix: Matrix, animation: Boolean)

Applies newMatrix (scale + translation only) to the video surface view.

Link copied to clipboard

Clears all zoom state and resets the video surface view to 1:1 scale. Does NOT change the ExoPlayer resize mode - call PlayerView.resize separately.

Link copied to clipboard
fun currentZoomMatrix(): Matrix

Returns the current zoom matrix, accounting for RESIZE_MODE_ZOOM which already has an implicit zoom applied.

Link copied to clipboard

Plays the fast-forward animation and seeks forward by fastForwardTime.

Link copied to clipboard

Reads from Settings.System.SCREEN_BRIGHTNESS, falling back to the window attribute if the permission is absent.

Link copied to clipboard
fun handleBrightnessAdjustment(verticalAddition: Float)
Link copied to clipboard
fun handleVolumeAdjustment(delta: Float, fromButton: Boolean)
Link copied to clipboard
fun handleVolumeKey(keyCode: Int): Boolean

Handles a hardware volume key press. Only active on phones/emulators when isFullScreen is true.

Link copied to clipboard
fun handleZoomPanGesture(event: MotionEvent, ctx: Context, onFirstPointerDown: () -> Unit, onGestureEnd: () -> Unit): Boolean

Processes a two-finger zoom/pan gesture event. Handles scale detection, panning, and the snap-back animation after finger lift.

Link copied to clipboard

Called from PlayerView.initialize after views are bound.

Link copied to clipboard
fun onTapDetected(x: Float, viewWidth: Int, isLocked: Boolean, onSingleTap: () -> Unit): Boolean

Call when a valid tap is detected (short hold, minimal movement, valid touch area). Routes to double-tap seeking/pausing or schedules a delayed single-tap callback.

Link copied to clipboard
fun release()

Called from PlayerView.release.

Link copied to clipboard

Nulls keyEventListener. Called from the host fragment's onPause.

Link copied to clipboard

Removes the overlay layout listener registered by requestUpdateBrightnessOverlayOnNextLayout.

Attaches a persistent layout-change listener to the ExoPlayer view so updateBrightnessOverlayBounds is called on every layout pass (orientation change, aspect-ratio change, zoom, PiP transition, etc.).

Link copied to clipboard

Resets the fast-forward button label to the standard "+Xs" format.

Link copied to clipboard

Resets the rewind button label to the standard "–Xs" format.

Link copied to clipboard

Resets zoom to fit mode if any zoom is currently active. Calls PlayerView.resize to update the ExoPlayer resize mode.

Link copied to clipboard
fun rewind()

Plays the rewind animation and seeks back by fastForwardTime.

Link copied to clipboard
fun setBrightness(brightness: Float)

Sets Settings.System.SCREEN_BRIGHTNESS, falling back to the window attribute if the permission is absent.

Link copied to clipboard

Registers the basic volume-key listener on keyEventListener. Called from PlayerView.initialize and from the host fragment's onResume.

Link copied to clipboard

Touch gestures

Link copied to clipboard

Speed-up

Link copied to clipboard

Resizes and repositions brightnessOverlay to exactly match the visible video surface, accounting for zoom scale and translation.

Link copied to clipboard

Syncs currentRequestedVolume with the current system stream volume.