getFormat static method
Implementation
static Future<MediaFormat> getFormat(File file,
{bool trustExtension = false}) async {
MediaFormat? format = kAllFormats
.select((i) => i.extensions.any((x) => file.path.endsWith(x)));
int length = await file.length();
if (format == null || !trustExtension) {
RandomAccessFile raf = await file.open();
List<int> headerBytes =
await raf.read(min(defaultMagicNumbersMaxLength, length));
raf.close();
String? mimeType = lookupMimeType(file.path, headerBytes: headerBytes);
if (mimeType != null) {
format = kAllFormats.select((i) => i.mimeType == mimeType);
}
}
return format ?? MediaFormat.unknown();
}