I noticed that YouTube will only start playing the video when the user switches to the current tab.
So when a user opens multiple tabs, how to determine whether the user has switched to the current tab?
高洛峰2017-07-05 10:40:13
There is a Page Visibility API, you can take a look
I have thought about this implementation before, but it actually has shortcomings. What if sometimes I just want to listen to the sound? (:evil
天蓬老师2017-07-05 10:40:13
document.addEventListener('visibilitychange', function() {
if (!document.hidden) {
// code
}
})