Is there any recommended API other than modernizr to detect if browser supports AutoPlay of video or not?
I am trying to make a way that if AutoPlay feature is allowed Wistia player code with autoplay will be loaded. In case AutoPlay is not allowed I am trying to fire Wistia player code with video autoplay with silent feature, this way on all browsers it work well.
I used modernizr its working fine, but its taking a bit more time to show the video.
Other way that I am trying to use is Javascript Promise, but haven't got success yet with Wistia code. Any advise other than these two ways?
答案 0 :(得分:0)
More than likely: no. If you look at the actual source relating to how Modernizr detects autoplay, you'll see that it creates a video element, tries to autoplay it, and if it can't, it returns false
for the autoplay feature.
This is the same pattern that most feature detection implementations (such as has.js and Modernizr) follow for any feature.
The slowness that you are seeing is probably due to the way the detection is written such that it has to wait 200ms for the result and then retries up to 5 times just in case the browser was being flaky meaning up to a full second before you know whether autoplay is supported.