Repository navigation
Prompt for a tap when a phone refuses the live view's first play - #521
masnwilliams wants to merge 1 commit into
Conversation
robertjamesprior
left a comment
There was a problem hiding this comment.
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.
|
Closing in favor of #524, which includes this change and limits the prompt to a connected session, alongside automatic reconnect after a dropped connection. |
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 unmutedplay(), then a muted one. When both are refused,onPlayingChangedmarks the video paused and does nothing else. The neko play overlay is commented out, and the "Tap to resume video" button only appears whenVideoResumesetsvideoBlocked. 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
play()is refused even muted,onPlayingChangednow setsvideoBlocked. This shows the same "Tap to resume video" button thatVideoResumealready shows for the same refusal later on. The flag is only set when:resumeVideo, only runs on touch devices, so on desktop the button would do nothing, and desktop behavior stays as it is today.NotAllowedError, which is the autoplay-policy refusal. Other rejections, such as anAbortErrorfrom a new stream replacing a pendingplay(), 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:The button already clears itself on the video's
playingevent, 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 newtests/video-autoplay.test.ts, which loads the real component methods, the two refused-play cases fail against the previousvideo.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 buildsucceeds.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 aNotAllowedError.onPlayingChangednow calls a newaskForTapIfRefusedhelper after failed autoplay attempts. On touch devices only, that setsvideoBlocked, which surfaces the existing “Tap to resume video” control instead of leaving the stream paused with no prompt.AbortErrorand other non-autoplay rejections do not trigger the prompt; desktop behavior is unchanged.Adds
video-autoplay.test.ts, which loads the realvideo.vuescript 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.