diff --git a/app/containers/MessageBox/RecordAudio.tsx b/app/containers/MessageBox/RecordAudio.tsx index ca71cd7bd..dc8bd2909 100644 --- a/app/containers/MessageBox/RecordAudio.tsx +++ b/app/containers/MessageBox/RecordAudio.tsx @@ -20,26 +20,31 @@ interface IMessageBoxRecordAudioProps { onStart: Function; } -const RECORDING_EXTENSION = '.m4a'; +const RECORDING_EXTENSION = '.aac'; const RECORDING_SETTINGS = { android: { + // Settings related to audio encoding. extension: RECORDING_EXTENSION, - outputFormat: Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG_4, + outputFormat: Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AAC_ADTS, audioEncoder: Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC, + // Settings related to audio quality. sampleRate: Audio.RECORDING_OPTIONS_PRESET_LOW_QUALITY.android.sampleRate, numberOfChannels: Audio.RECORDING_OPTIONS_PRESET_LOW_QUALITY.android.numberOfChannels, bitRate: Audio.RECORDING_OPTIONS_PRESET_LOW_QUALITY.android.bitRate }, ios: { + // Settings related to audio encoding. extension: RECORDING_EXTENSION, - audioQuality: Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_MIN, + audioQuality: Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_MEDIUM, + outputFormat: Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC, + // Settings related to audio quality. sampleRate: Audio.RECORDING_OPTIONS_PRESET_LOW_QUALITY.ios.sampleRate, numberOfChannels: Audio.RECORDING_OPTIONS_PRESET_LOW_QUALITY.ios.numberOfChannels, - bitRate: Audio.RECORDING_OPTIONS_PRESET_LOW_QUALITY.ios.bitRate, - outputFormat: Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC + bitRate: Audio.RECORDING_OPTIONS_PRESET_LOW_QUALITY.ios.bitRate }, web: {} }; + const RECORDING_MODE = { allowsRecordingIOS: true, playsInSilentModeIOS: true, @@ -159,7 +164,7 @@ export default class RecordAudio extends React.PureComponent { try { - this.setState({ currentTime: value }); await this.sound.setPositionAsync(value * 1000); } catch { // Do nothing diff --git a/app/lib/methods/handleMediaDownload.ts b/app/lib/methods/handleMediaDownload.ts index 9fe7aa7c5..9fb3c5c9b 100644 --- a/app/lib/methods/handleMediaDownload.ts +++ b/app/lib/methods/handleMediaDownload.ts @@ -41,7 +41,7 @@ export const getFilename = ({ mimeType?: string; }) => { const isTitleTyped = mime.lookup(title); - const extension = getExtension(type, mimeType); + const extension = getExtension(type, mimeType, url); if (isTitleTyped && title) { if (isTitleTyped === mimeType) { return title; @@ -65,18 +65,20 @@ export const getFilename = ({ return `${filenameFromUrl}.${extension}`; }; -const getExtension = (type: MediaTypes, mimeType?: string) => { +const getExtension = (type: MediaTypes, mimeType?: string, url?: string) => { if (!mimeType) { return defaultType[type]; } + // support audio from older versions + if (url?.split('.').pop() === 'm4a') { + return 'm4a'; + } // The library is returning mpag instead of mp3 for audio/mpeg if (mimeType === 'audio/mpeg') { return 'mp3'; } - // Audios sent by Android devices are in the audio/aac format, which cannot be converted to mp3 by iOS. - // However, both platforms support the m4a format, so they can maintain the same behavior. if (mimeType === 'audio/aac') { - return 'm4a'; + return 'aac'; } // The return of mime.extension('video/quicktime') is .qt, // this format the iOS isn't recognize and can't save on gallery