There's a new experimental Chrome Extension called FacePause, created by developer Mattias Hemmingsson, which shows how Google’s face detection API can be used to pause YouTube videos if a user looks away from their screen. In the shortest possible terms, the API has been around since Chrome 56 and utilizes a user's web camera to determine whether they are facing the screen or not. The experimental feature hasn't seen a lot of use by developers despite that, as of this writing, that was ten stable versions ago. Rather than seeing his creation as useful, however, Hemmingsson said he wanted to show one possible use for the API by way of experimentation. So it goes without saying that this won't necessarily work perfectly for everybody. Moreover, whether it works well is going to be partially dependent on the quality of lighting and, by proxy, whether or not the software can use the camera to detect the user's face.
Aside from not working well in less well-lit circumstances, users will also need to enable one of Chrome's many experimental "flag" settings to get started. That can be done by navigating to the hidden settings menu at "chrome://flags" and then performing a search for "Experimental Web Platform features." That should move the user down the list of available experimental settings and highlight the appropriate feature that needs to be enabled. Choosing the "enabled" option from the drop-down menu to the right and then restarting Chrome will turn it on. Then, after enabling the extension via the three-dot Chrome menu - found in the "More tools" option - the feature should be fully enabled. If the room a user is in happens to be bright enough, the browser should be able to detect their face and pause a YouTube video when they aren't looking. The automation is, it bears repeating, a novel feature though. So users shouldn't expect perfection here.
As always, one must maintain vigilance when installing Chrome Extensions. It isn't unusual for those to contain spyware or malware in some cases. In fact, it's been a growing problem that has gone largely unaddressed over the past few years, although there don't appear to be any issues with FacePause. That extension can be found via the banner below.