Skip to content

Prompt for a tap when a phone refuses the live view's first play - #521

Closed
masnwilliams wants to merge 1 commit into
mainfrom
hypeship/live-view-low-power-tap-prompt
Closed

masnwilliams wants to merge 1 commit into
mainfrom
hypeship/live-view-low-power-tap-prompt

Conversation

@masnwilliams

@masnwilliams masnwilliams commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

With Low Power Mode on, iOS Safari refuses every play() that doesn't come from a tap, muted ones included. On first load the live view tries an unmuted play(), then a muted one. When both are refused, onPlayingChanged marks the video paused and does nothing else. The neko play overlay is commented out, and the "Tap to resume video" button only appears when VideoResume sets videoBlocked. That happens on a touch, a key press, or the tab becoming visible again, never on first load. So the user sees a black box with no prompt. A tap starts the video, and switching tabs and back shows the button. That's why the prompt seems to appear only some of the time.

Changes

  • When the first-load play() is refused even muted, onPlayingChanged now sets videoBlocked. This shows the same "Tap to resume video" button that VideoResume already shows for the same refusal later on. The flag is only set when:
    • the device is a touch device. The button's handler, resumeVideo, only runs on touch devices, so on desktop the button would do nothing, and desktop behavior stays as it is today.
    • the error is a NotAllowedError, which is the autoplay-policy refusal. Other rejections, such as an AbortError from a new stream replacing a pending play(), don't show the prompt.

Effect on other mobile browsers

The prompt only appears when the video would otherwise stay black until a tap. If a muted play() is allowed, nothing changes:

  • iOS Safari and other iOS browsers (all WebKit) outside Low Power Mode: muted autoplay is allowed, so there's no prompt.
  • Android Chrome, Samsung Internet, and Firefox with default settings: muted autoplay is allowed, so there's no prompt.
  • A browser set to block all autoplay (Firefox "Block audio and video", site settings): the user now sees the prompt instead of a black box.

The button already clears itself on the video's playing event, so it goes away however the video starts (the button, a tap anywhere, or a later visibility resume).

Testing

  • bun test tests: 268 pass. In the new tests/video-autoplay.test.ts, which loads the real component methods, the two refused-play cases fail against the previous video.vue. The tests cover: refused even muted on touch (prompt), already muted and refused (prompt), only sound refused (plays muted, no prompt), allowed (no prompt), AbortError (no prompt), refused on desktop (no prompt).
  • vue-cli-service build succeeds.
  • Not tested on a physical iPhone in Low Power Mode.

Note

Low Risk
Small, guarded UI state change in mobile video autoplay error handling with dedicated unit tests; no auth or server impact.

Overview
Fixes a black screen on first load when mobile browsers (especially iOS Safari in Low Power Mode) reject both unmuted and muted play() with a NotAllowedError.

onPlayingChanged now calls a new askForTapIfRefused helper after failed autoplay attempts. On touch devices only, that sets videoBlocked, which surfaces the existing “Tap to resume video” control instead of leaving the stream paused with no prompt. AbortError and other non-autoplay rejections do not trigger the prompt; desktop behavior is unchanged.

Adds video-autoplay.test.ts, which loads the real video.vue script and exercises first-load paths: full refusal (prompt), muted-only success (no prompt), allowed play, AbortError, and desktop refusal.

Reviewed by Cursor Bugbot for commit 8794e97. Bugbot is set up for automated code reviews on this repo. Configure here.

@masnwilliams
masnwilliams requested review from robertjamesprior and removed request for robertjamesprior November 17, 2026 17:46

@robertjamesprior robertjamesprior left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit -- images/chromium-headful/client/src/components/video.vue:1213: the button's handler is resumeVideo alone, so the first tap on it plays muted. Tapping anywhere else on the player goes through onTouchEnd, which calls unmuteOnInteraction() first and gets you audio. The fork has no on-screen unmute control (the volume control and mutedOverlay are both commented out), so in the low-power-mode case this button is the only affordance and the stream stays silent until a second tap. unmuteOnInteraction(); resumeVideo() on the button would match the tap-anywhere path. Nit rather than a blocker since live-view audio is rare.

On the NotAllowedError guard: WebKit reports that name for low power mode (https://bugs.webkit.org/show_bug.cgi?id=216887), so the assumption holds without a device test. Worth a real phone before merge anyway, since the rest is synthetic. The AbortError exclusion is right -- a replaced stream re-triggers canplaythrough, which retries.

Verified locally: 268 pass, vue-cli-service build succeeds, and the two refusal cases do fail against main's video.vue.

Approving -- no blockers.

@masnwilliams

Copy link
Copy Markdown
Contributor Author

Picked tnsardesai to review: reviewed the recent mobile live view changes (#487, #489, #464); 2 pending

@masnwilliams

Copy link
Copy Markdown
Contributor Author

Closing in favor of #524, which includes this change and limits the prompt to a connected session, alongside automatic reconnect after a dropped connection.

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.

3 participants