You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add mediaCapabilities hook
* update README.md with useMediaCapabilities hook
* cleanup mediaCapabilities test
* remove usage of useState and useEffect in media-capabilities
* simplify things
* add initialMediaCapabilities
* add a better example in readme for useMediaCapabilities
* better copy to align style of writing with writings from @mlampedx
Co-authored-by: Addy Osmani <addyosmani@gmail.com>
`useMediaCapabilities` utility for adapting based on the user's device media capabilities.
164
+
165
+
**Use case:** this hook can be used to check if we can play a certain content type. For example, Safari does not support WebM so we want to fallback to MP4 but if Safari at some point does support WebM it will automatically load WebM videos.
Couldn't test webm support, either the media capabilities api is unavailable or no media configuration was given.
200
+
</div>
201
+
}
202
+
</div>
203
+
);
204
+
};
205
+
```
206
+
207
+
This hook accepts a [media configuration](https://developer.mozilla.org/en-US/docs/Web/API/MediaConfiguration) object argument and an optional `initialMediaCapabilities` object argument, which can be used to provide a `mediaCapabilities` state value when the user's browser does not support the relevant [Media Capabilities API](https://developer.mozilla.org/en-US/docs/Web/API/Media_Capabilities_API) or no media configuration was given.
208
+
159
209
### Adaptive Code-loading & Code-splitting
160
210
161
211
#### Code-loading
@@ -258,6 +308,8 @@ export default App;
258
308
259
309
* [Device Memory API](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/deviceMemory) is available in [Chrome 63+, Opera 50+, Chrome for Android 76+, Opera for Android 46+](https://caniuse.com/#search=deviceMemory)
260
310
311
+
* [Media Capabilities API](https://developer.mozilla.org/en-US/docs/Web/API/Media_Capabilities_API) is available in [Chrome 63+, Firefox 63+, Opera 55+, Chrome for Android 78+, Firefox for Android 68+](https://caniuse.com/#search=media%20capabilities)
0 commit comments