Skip to content

Player: touch gestures (tap, double-tap seek, hold for 2×, pinch zoom) and casting - #37

Merged
raccommode merged 2 commits into
raccommode:mainfrom
MajorLOL:main
Oct 27, 2026
Merged

raccommode merged 2 commits into
raccommode:mainfrom
MajorLOL:main

Conversation

@MajorLOL

Copy link
Copy Markdown
Contributor

Summary

Adds mobile-style gestures to the video player and a cast button.

Gestures

Gesture Action
Tap show / hide the controls
Double tap right / left seek +10 s / −10 s (each further quick tap adds 10 s)
Press and hold on the right play at 2× while held (badge shown), back to normal on release
Two-finger pinch zoom up to 4×; one-finger drag pans while zoomed; tap the zoom badge to reset
  • Mouse behaviour is unchanged: click = play/pause, double click = fullscreen; holding on the right also plays at 2×. Keyboard shortcuts are unchanged.
  • On small screens the control bar's gradient covered the lower half of the video and swallowed taps. The bar itself now ignores touches; only its buttons and sliders take them.
  • The gesture recognizer (src/player-gestures.ts) has no React/DOM dependency and is unit-tested (tap vs double tap, streaks, hold, pinch, pan, cancel, zoom maths).

Casting

  • Chromecast / Google TV via the Google Cast Web Sender SDK, loaded on demand. Chrome only exposes it on secure pages, so this needs HTTPS (e.g. behind a reverse proxy). Over plain HTTP, the browser's own "Cast…" menu remains the fallback.
  • AirPlay in Safari (webkitShowPlaybackTargetPicker), also over HTTP.
  • Remote Playback API where the browser supports it (e.g. Chrome on Android).
  • While a Chromecast session is active, local playback pauses and the player's play/pause, seek and double-tap controls drive the TV. "Stop casting" resumes locally at the TV's position.
  • The receiver loads the absolute stream URL itself; a localhost address is detected and explained. Unsupported formats show a hint about the re-encoding presets.
  • When no cast route is available, the button explains what is needed instead of failing silently.

Testing

  • npm run check: 551 tests pass, TypeScript and build OK.
  • New: src/player-gestures.test.ts, src/player-cast.test.ts, and a render check in src/Player.test.tsx.
  • Verified in Chromium with touch emulation (390×844, real touch events via CDP) on a running instance:
    • tap toggles controls
    • double tap right +10 s, triple tap left −20 s
    • hold → playbackRate 2, release → 1
    • pinch → 4× zoom, reset badge works
    • desktop click still pauses
  • Casting to a real Chromecast/AirPlay device was not tested; only the "no device" path was exercised.

…) and casting

- Touch: tap toggles the controls, double tap right/left seeks +/-10 s (further
  quick taps add 10 s), press and hold on the right plays at 2x, two-finger
  pinch zooms up to 4x with one-finger panning and a reset badge.
- Mouse keeps click = play/pause and double click = fullscreen; holding on the
  right also plays at 2x.
- The control bar's gradient no longer swallows taps on small screens; only
  its buttons and sliders take touches.
- Cast button: Chromecast via the Google Cast sender SDK (Chrome/Edge on HTTPS),
  AirPlay in Safari, or the Remote Playback API. While casting, the player's
  controls drive the TV; stopping resumes locally at the same position.
- Gesture recognizer and zoom maths in src/player-gestures.ts with unit tests;
  verified in Chromium with touch emulation. README documents gestures and
  casting requirements.
…) and casting

- Touch: tap toggles the controls, double tap right/left seeks +/-10 s (further
  quick taps add 10 s), press and hold on the right plays at 2x, two-finger
  pinch zooms up to 4x with one-finger panning and a reset badge.
- Mouse keeps click = play/pause and double click = fullscreen; holding on the
  right also plays at 2x.
- The control bar's gradient no longer swallows taps on small screens; only
  its buttons and sliders take touches.
- Cast button: Chromecast via the Google Cast sender SDK (Chrome/Edge on HTTPS),
  AirPlay in Safari, or the Remote Playback API. While casting, the player's
  controls drive the TV; stopping resumes locally at the same position.
- Gesture recognizer and zoom maths in src/player-gestures.ts with unit tests;
  verified in Chromium with touch emulation. README documents gestures and
  casting requirements.

Copy link
Copy Markdown
Owner

Reviewed the changes at 0b213ba and completed integration checks.

The gesture recognizer is well separated from the UI. I found and fixed several integration regressions before merging:

  • Restored the existing persistent audio boost (up to 300%) and its regression test, plus the mute and volume accessibility labels removed by this PR.
  • Added Cast SDK listener cleanup, synchronized rejoined sessions, and restricted remote state to the selected video's URL so a stale session cannot restart or control another video.
  • Kept local playback running when loading media on the receiver fails, and guarded asynchronous casting against leaving the viewer.
  • Reset active speed holds and pending tap streaks when switching media.

The fixes are in b6f9151 and are included with this PR in the merge commit.

Validation: NODE_OPTIONS=--no-experimental-webstorage npm run check under Node 24 passed all 568 tests, TypeScript, and the production build. Python subtitle compilation passed. Browser checks on a 390px viewport covered playback, double-tap seeking, hold/release speed, pinch/reset zoom, the 300% boost control, and the no-device casting message. Real Chromecast/AirPlay hardware playback has not been tested.

Merging with these fixes included. Thank you for the contribution!

raccommode added a commit that referenced this pull request Oct 27, 2026
Add player gestures and casting, preserving audio boost and fixing session and gesture cleanup.
@raccommode
raccommode merged commit 0b213ba into raccommode:main Oct 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants