2018-04-13 21:54:53 +00:00
|
|
|
import * as MIME from '../types/MIME';
|
2018-04-09 23:27:40 +00:00
|
|
|
|
|
|
|
interface MIMETypeSupportMap {
|
|
|
|
[key: string]: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
// See: https://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support
|
|
|
|
const SUPPORTED_IMAGE_MIME_TYPES: MIMETypeSupportMap = {
|
|
|
|
'image/bmp': true,
|
|
|
|
'image/gif': true,
|
|
|
|
'image/jpeg': true,
|
2018-06-16 00:49:35 +00:00
|
|
|
// No need to support SVG
|
|
|
|
'image/svg+xml': false,
|
2018-04-09 23:27:40 +00:00
|
|
|
'image/webp': true,
|
|
|
|
'image/x-xbitmap': true,
|
|
|
|
// ICO
|
|
|
|
'image/vnd.microsoft.icon': true,
|
|
|
|
'image/ico': true,
|
|
|
|
'image/icon': true,
|
|
|
|
'image/x-icon': true,
|
|
|
|
// PNG
|
|
|
|
'image/apng': true,
|
|
|
|
'image/png': true,
|
|
|
|
};
|
|
|
|
|
|
|
|
export const isImageTypeSupported = (mimeType: MIME.MIMEType): boolean =>
|
2018-04-13 20:25:52 +00:00
|
|
|
SUPPORTED_IMAGE_MIME_TYPES[mimeType] === true;
|
2018-04-09 23:27:40 +00:00
|
|
|
|
|
|
|
const SUPPORTED_VIDEO_MIME_TYPES: MIMETypeSupportMap = {
|
|
|
|
'video/mp4': true,
|
|
|
|
'video/ogg': true,
|
|
|
|
'video/webm': true,
|
|
|
|
};
|
|
|
|
|
|
|
|
// See: https://www.chromium.org/audio-video
|
|
|
|
export const isVideoTypeSupported = (mimeType: MIME.MIMEType): boolean =>
|
2018-04-13 20:25:52 +00:00
|
|
|
SUPPORTED_VIDEO_MIME_TYPES[mimeType] === true;
|