nc-photos/lib/entity/file_util.dart

21 lines
624 B
Dart
Raw Normal View History

2021-04-10 06:28:12 +02:00
import 'package:nc_photos/entity/file.dart';
2021-05-06 13:36:20 +02:00
import 'package:nc_photos/platform/k.dart' as platform_k;
2021-04-10 06:28:12 +02:00
bool isSupportedFormat(File file) =>
_supportedFormatMimes.contains(file.contentType);
2021-05-06 08:29:46 +02:00
bool isSupportedImageFormat(File file) =>
isSupportedFormat(file) && file.contentType?.startsWith("image/") == true;
2021-05-06 13:36:20 +02:00
bool isSupportedVideoFormat(File file) =>
isSupportedFormat(file) && file.contentType?.startsWith("video/") == true;
2021-04-10 06:28:12 +02:00
const _supportedFormatMimes = [
"image/jpeg",
"image/png",
"image/webp",
2021-04-14 23:09:31 +02:00
"image/heic",
2021-05-06 13:36:20 +02:00
// video player currently doesn't work on web
if (!platform_k.isWeb) "video/mp4",
2021-04-10 06:28:12 +02:00
];