When using Coil to load videos from URIs generated...
# compose
f
When using Coil to load videos from URIs generated with
ContentResolver
, I need to explicitly pass the fetcher to the request builder, otherwise Coil cannot process the video (since the URI does not contain the file type). E.g.:
Copy code
Image(
    painter = rememberImagePainter(
        data = contentUri,
        builder = {
            fetcher(VideoFrameUriFetcher(LocalContext.current))
        },
    ),
    contentDescription = null,
)
Creating the
VideoFrameUriFetcher
instance for every video seems kind of inefficient. Is there a better Compose way?
a
Why not hoist the video frame fetcher?
1
f
Yeah, probably makes sense. Thanks.
a
The frame fetcher could live inside your viewmodel too so it won't be recreated on every recomposition, although I am not sure if
builder
already does some caching for you
224 Views