diff options
Diffstat (limited to 'src/features')
| -rw-r--r-- | src/features/messages.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/features/messages.js b/src/features/messages.js index 6548e99..1c74526 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -7466,6 +7466,10 @@ export function messagesFeature(ctx) { for (const en of entries) { const el2 = en.target; if (!el2.isConnected) { playerWatch.unobserve(el2); continue; } + // under the media pager nothing starts: the page laid out again + // beneath it (a turn of the phone) "showed" a clip — the pager's own, + // as often as not — and a second copy played behind it + if (ui.mediaPager && en.isIntersecting) continue; if (en.isIntersecting && en.intersectionRatio >= 0.5) { if (el2._onIn) el2._onIn(); } else if (el2._onOut) el2._onOut(); } }, { threshold: [0, 0.5] }); @@ -12027,6 +12031,11 @@ export function messagesFeature(ctx) { // clips, in the feed's order), rather than from the media grid; `at`: where // the clip it opened on was, so it carries on from there function openMediaPager(kind, start, { fromFeed = false, at = 0 } = {}) { + // the page's own players stop: the pager's is the one to hear + for (const v of document.querySelectorAll('video')) { try { v.pause(); } catch {} } + for (const f of document.querySelectorAll('.yt-embed[data-playing] iframe')) { + try { f.contentWindow.postMessage(JSON.stringify({ event: 'command', func: 'pauseVideo', args: [] }), '*'); f.closest('.yt-embed')._pausedByUs = true; } catch {} + } ui.mediaPager = { kind, start, feed: curFeedId, fromFeed, at }; render(); } @@ -12398,7 +12407,11 @@ export function messagesFeature(ctx) { if (thumb && v.getAttribute('poster') !== thumb) v.setAttribute('poster', thumb); } function startSlide(slide) { + // only the slide on screen plays (not one a half-way layout — a turn of + // the phone — passed over), and it alone + if (!pager || pager.cur !== slide) return; const v = slide.querySelector('video.mp-media'); + for (const o of pager.el.querySelectorAll('video.mp-media')) if (o !== v && !o.paused) { try { o.pause(); } catch {} } if (/#t=[\d.]+$/.test(v.getAttribute('src') || '')) v.setAttribute('src', playSrc(v.getAttribute('data-src'))); // the still's src: from the start now v.preload = 'auto'; pagerAttach(slide); |
