import { SUPPORT_AUDIO_EXT } from '@/modules/uploaderNew/constants';

import DEFAULT_THUMBNAIL_PATH_FOR_AUDIO_FORMAT from '@/assets/img/upload/default-img-audio-thumbnail.jpg';

export const checkFileIsAudio = (filePath) => {
  const ext = filePath.split('.').pop();

  return SUPPORT_AUDIO_EXT.includes(`.${ext}`);
};

export const getDefaultAudioThumbnailAsFile = async () => {
  const response = await fetch(DEFAULT_THUMBNAIL_PATH_FOR_AUDIO_FORMAT.src);
  const blob = await response.blob();

  return new File([blob], DEFAULT_THUMBNAIL_PATH_FOR_AUDIO_FORMAT.src, {
    type: blob.type,
  });
};
