How YouTube website can use autoplay feature function without DOMException

45 Views Asked by At

I wonder why YouTube can use autoplay feature without DOMException because when I tried to use <audio/> and <video/> tags with autoplay when loaded, It's show an DOMException error. I tried another way by set an attribute playInLines={true} and muted={true} it first, then called ref.current.play() and finally unmute it. Unfortunately, the browser isn't allow to play without user interact first by showing DOMException error.

When I using YouTube website, I noticed that YouTube won't autoplay until I switched back to YouTube tab, the video is autoplayed.

I searched from internet that YouTube website is built from the framework that load only the element that it needed, the other element won't refreshed.

Is YouTube a Single Page Application. If it isn't, when the user interacted first time on loaded, can the website play the videos forever? (not counted the AFK interruption (YouTube Premium user won't encountner this))

I don't have any knowledge but I guess that YouTube is using the both of <audio/> and <video/> tags.

0

There are 0 best solutions below