Extracted the video logic from D7902 as this will also be needed for modals.
This component is intended to display thumbnail while video is loading. And while thumbnail is decrypted/loaded, the thumbhash is displayed. The component also supports encrypted thumbnails.
Details
Details
- Reviewers
ashoat atul ginsu inka - Commits
- rCOMM983f258fb7d9: [web] Add loadable video component
Tested together with D7902
Diff Detail
Diff Detail
- Repository
- rCOMM Comm
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
web/media/loadable-video.react.js | ||
---|---|---|
19–29 ↗ | (On Diff #26901) | Explanation in https://phab.comm.dev/D7902?id=26730#inline-51871 |
web/media/loadable-video.react.js | ||
---|---|---|
29 ↗ | (On Diff #26901) | I'd like to show the thumbnailURI as soon as it's loaded, rather than waiting for the whole video to be loaded. More context in my comment on D7902, but it should be a simple change here I think... React.useEffect(() => { (async () => { // video thumbnail is used as a poster image when the video is loaded // preload it so the browser can immediately load it from cache if (!thumbnailURI) { return; } await preloadImage(thumbnailURI); setThumbnailLoaded(true); })(); }, [thumbnailURI]); const poster = isThumbnailLoaded ? thumbnailURI : thumbHashDataURL; Do you think that would work? |
Comment Actions
- Changed logic to display actual video thumbnail as soon as possible
- Added support for encrypted video thumbnails
- Added a forwardRef to the video element which will be needed for encrypted media
The whole approach and diff tree changes discussed in D7902
web/media/loadable-video.react.js | ||
---|---|---|
20–22 ↗ | (On Diff #26920) | Found myself wondering in what scenarios uri and thumbHashDataURL will not be set. Answered them by reading later parts of the stack: |