From c423cf3b79b088e542709267002b7db27b1a83ff Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 13 Oct 2026 05:29:09 +0000 Subject: Feed video: fewer "To exit full screen" notices, and a YouTube clip takes one tap. Adam: Chrome's "v3.coinos.io – To exit full screen, drag from the top and touch the back button" shows every time, and a YouTube clip needs its own small full-screen icon. The notice is Chrome's, put up whenever a page goes full screen; a page can't turn it off, so the app goes full screen less. In the installed app (display-mode standalone, or opened from an android-app:// referrer) there is no address bar and the pager already fills the window, so it no longer goes full screen: a wide clip asks the screen to turn without it, and only if that's refused (the browser may allow turning only in full screen) goes full screen — the notice then, but the clip on its side; the screen is let go past that clip, or on closing. A browser tab goes full screen as before. A feed clip's own control bar loses its full-screen button (controlslist=nofullscreen): a tap on the clip is the way, into the pager. YouTube: the player's taps never reach the page, so a layer over a playing clip's picture takes them, leaving YouTube's control bar along the bottom to YouTube; one tap on it — or on the still — plays with sound and takes the clip's box full screen, turned on its side (unMute + playVideo through the iframe API for a player autoplaying muted); full screen the layer steps aside, so all of YouTube's controls are there. YouTube can only fill the screen through Chrome's full screen, so its notice still shows there. tools/fullscreen-notice-test.js (installed app: no full screen, the screen turned and let go, the fallback when turning is refused; no full-screen button on feed clips); tools/youtube-tap-test.js (YouTube stood in for: autoplaying muted, a tap on the control bar stays YouTube's, one tap full screen with unMute and playVideo, the layer aside full screen and back after; with Data Saver, the still to full screen with sound); video-unmute-test stubs ui for its slice of videoNode. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KPw21NEpWeTGu6swVASmBt --- src/features/messages.js | 61 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 10 deletions(-) (limited to 'src/features') diff --git a/src/features/messages.js b/src/features/messages.js index 6e977af..b09aa17 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -7615,7 +7615,10 @@ export function messagesFeature(ctx) { // play button: no seek bar, no sound button. Without autoplay the // player's own controls are the way in, so they stay. const idle = autoplayOk() && !wokeClips.has(url); - const v = h('video', { src: playSrc(url), class: 'note-video', controls: idle ? undefined : true, poster: videoThumbs.get(url) || (videoInfo.get(url) || {}).image || serverThumb(url), + // In the feed a tap on the clip opens the pager, so the player's own + // full-screen button (Chrome's full screen: no next clip, and its notice) + // is left off its bar there. + const v = h('video', { src: playSrc(url), class: 'note-video', controls: idle ? undefined : true, controlslist: ui.chatOpen && ui.msgView === 'feed' && !ui.noteThread && !ui.profilePk ? 'nofullscreen' : undefined, poster: videoThumbs.get(url) || (videoInfo.get(url) || {}).image || serverThumb(url), preload: 'none', playsinline: true, muted: loud ? undefined : true, style: stable ? videoBoxStyle(feedMedia(url)) : undefined, // learned now, used by the next paint of any row with this clip @@ -7741,27 +7744,44 @@ export function messagesFeature(ctx) { f.allowFullscreen = true; f.onload = () => { try { f.contentWindow.postMessage(JSON.stringify({ event: 'listening', id: vid }), '*'); } catch {} }; box.append(f); + // a tap on the picture is ours, not the player's (whose taps the page + // never sees): it takes the clip full screen — YouTube's own control + // bar along the bottom stays YouTube's. Full screen, this steps aside. + box.append(h('div', { class: 'yt-shield', 'aria-hidden': 'true' })); if (muted) { let on = false; const btn = soundBtn(() => { on = !on; btn.setSound(on); post(box, on ? 'unMute' : 'mute'); if (on) post(box, 'playVideo'); }); + box._soundOn = () => { on = true; btn.setSound(true); }; box.append(btn); } }; - const frame = h('div', { class: 'yt-embed' }, + // One tap, as with any clip in a post: it plays, with sound, full screen + // (turned on its side). The still loads the player first; a player + // already going (autoplayed, muted) is unmuted and carried on. + const full = (box) => { + const go = box.requestFullscreen || box.webkitRequestFullscreen; + if (!go) return; + Promise.resolve(go.call(box, { navigationUI: 'hide' })) + .then(() => screen.orientation?.lock?.('landscape').catch(() => {})).catch(() => {}); + }; + const tapped = (e) => { + if (e.target.closest('.yt-open, .vid-sound, iframe')) return; + e.stopPropagation(); e.preventDefault(); + const box = e.currentTarget; + if (!box.dataset.playing) load(box, false); // a tap means sound + else { post(box, 'unMute'); post(box, 'playVideo'); if (box._soundOn) box._soundOn(); } + full(box); + }; + const frame = h('div', { class: 'yt-embed', onClick: tapped }, h('img', { class: 'yt-poster', loading: 'lazy', alt: '', src: !feedPaint || feedMedia('https://i.ytimg.com/vi/' + vid + '/hqdefault.jpg') ? 'https://i.ytimg.com/vi/' + vid + '/hqdefault.jpg' : undefined, onError: (e) => { e.target.style.display = 'none'; }, }), + // (its tap is the box's: play, full screen) h('button', { - class: 'yt-play', 'aria-label': t('playVideo'), title: t('playVideo'), - onClick: (e) => { - e.stopPropagation(); - const box = e.currentTarget.parentElement; - if (!box || box.dataset.playing) return; - load(box, false); // a tap means sound - }, + class: 'yt-play', type: 'button', 'aria-label': t('playVideo'), title: t('playVideo'), }, h('span', { style: 'display:flex', html: '' })), h('a', { class: 'yt-open', href: url, target: '_blank', rel: 'noopener noreferrer', @@ -11770,7 +11790,27 @@ export function messagesFeature(ctx) { } catch { return false; } } let pagerFs = false; // the pager put the page full screen (and so takes it back out) + let pagerLock = false; // the pager turned the screen (and so lets it go) + // The installed app (the Play/Zapstore build, or a home-screen install) + // has no address bar: the pager already fills its window. Going full + // screen there only hid the system bars, and every time it did Chrome put + // up its "To exit full screen, drag from the top…" notice, which a page + // can't turn off. So there it doesn't: a wide clip asks the screen to turn + // without it, and goes full screen only if that's refused (the browser + // allows turning only in full screen) — the notice then, but the clip on + // its side. + const installedApp = () => { + try { return matchMedia('(display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui)').matches || document.referrer.startsWith('android-app://'); } catch { return false; } + }; function pagerFullscreen(wide) { + if (installedApp()) { + if (!wide || !screen.orientation?.lock) return; + screen.orientation.lock('landscape').then(() => { if (ui.mediaPager) pagerLock = true; else screen.orientation.unlock?.(); }, () => pagerGoFullscreen(true)); + return; + } + pagerGoFullscreen(wide); + } + function pagerGoFullscreen(wide) { const d = document.documentElement; const go = d.requestFullscreen || d.webkitRequestFullscreen; if (!go || fsElement()) return; @@ -11782,6 +11822,7 @@ export function messagesFeature(ctx) { } const exitFs = () => { try { (document.exitFullscreen || document.webkitExitFullscreen || (() => {})).call(document)?.catch?.(() => {}); } catch {} }; function pagerUnFullscreen() { + if (pagerLock) { pagerLock = false; try { screen.orientation?.unlock?.(); } catch {} } if (!pagerFs) return; pagerFs = false; try { screen.orientation?.unlock?.(); } catch {} @@ -12332,7 +12373,7 @@ export function messagesFeature(ctx) { if (pager.cur && pager.cur !== e.target) { const v = pager.cur.querySelector('video.mp-media'); if (v) v.pause(); // past the clip it opened on, the screen follows the phone again - if (pagerFs) { try { screen.orientation?.unlock?.(); } catch {} } + if (pagerFs || pagerLock) { pagerLock = false; try { screen.orientation?.unlock?.(); } catch {} } if (pager.fromFeed && video) el.classList.remove('show'); } pager.cur = e.target; -- cgit v1.2.3