aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/features/messages.js61
-rw-r--r--src/style.css6
2 files changed, 57 insertions, 10 deletions
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: '<svg width="30" height="30" viewBox="0 0 24 24" fill="currentColor" style="display:block"><path d="M8 5v14l11-7z"/></svg>' })),
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;
diff --git a/src/style.css b/src/style.css
index e66d756..e03ff14 100644
--- a/src/style.css
+++ b/src/style.css
@@ -1010,6 +1010,12 @@ html.no-scroll { overflow: hidden; scrollbar-gutter: auto; }
padding: 4px 7px; border-radius: 8px; background: rgba(18, 18, 18, .6); text-decoration: none;
}
.yt-open:hover { background: rgba(18, 18, 18, .85); text-decoration: none; }
+/* over a playing clip: a tap takes it full screen; YouTube's control bar
+ along the bottom is left uncovered, and full screen it all is */
+.yt-shield { position: absolute; left: 0; right: 0; top: 0; bottom: 52px; z-index: 1; cursor: pointer; }
+.yt-embed:fullscreen { border-radius: 0; aspect-ratio: auto; width: 100%; height: 100%; }
+.yt-embed:fullscreen .yt-shield { display: none; }
+.yt-embed:fullscreen iframe { object-fit: contain; }
/* A link, as the card its page describes: picture on top, title, a line,
the site. The whole card is the link. */
.link-card {