Reputation: 181
I want the video to autoplay on the website only if the user is connected to the wifi. I know about the navigator.connection api - but it's not available on safari, and besides it only tells you about the speed of the connection not the type.
Upvotes: 8
Views: 3840
Reputation: 3025
As of December 2020, Safari has made no moves to implement the Network Information API, which as you've noted, provides the navigator.connection
NetworkInformation
object. That's a shame, because other browsers have supplied this for years.
This means there is no equivalent of the iOS-native Reachability APIs on mobile Safari (or desktop Safari, for that matter), so the best you can do is to use a very rough hack like:
For the sake of completeness, according to the MDN, the browsers that do provide navigator.connection
as of December 2020, are:
dom.netinfo.enabled
preference(Safari and Internet Explorer are the only major browsers conspicuously missing support.)
Upvotes: 5