【发布时间】:2021-06-28 07:17:18
【问题描述】:
我无法在视频未显示时暂停视频。切换到不同的滑块时,我已成功暂停它。 我还需要卸载或者如何防止它在不播放时在后台运行,所以它可能不会加载浏览器。
请在此处检查我的代码框 CLICK HERE
useEffect(() => {
const options = {
root: document.querySelector("#video"),
threshold: 0.1
};
observerRef.current = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.intersectionRatio !== 1) {
setPlayed(false);
}
});
}, options);
}, []);
【问题讨论】:
标签: javascript html reactjs react-hooks html5-video