isVideoDecoderSupported static method
Returns true if a VideoDecoder can actually be configured for
codecString.
hasVideoDecoder only proves the CONSTRUCTOR exists. HEVC and AV1 in particular depend on the browser AND the hardware, so a decoder that exists can still refuse the codec — without this the backend would configure and throw instead of declining. (Video ENCODE has always been gated this way; decode was not, which was simply an oversight.)
Returns false if hasVideoDecoder is false; true when the probe
itself is unavailable, leaving configure() as the judge.
Implementation
static Future<bool> isVideoDecoderSupported(
String codecString, {
int width = 1280,
int height = 720,
}) async {
if (!hasVideoDecoder) return false;
try {
final support = await web.VideoDecoder.isConfigSupported(
web.VideoDecoderConfig(
codec: codecString,
codedWidth: width,
codedHeight: height,
),
).toDart;
return support.supported;
} catch (_) {
return true;
}
}