diff --git a/android/build.gradle b/android/build.gradle index 8680080c2..e7c60f1de 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -11,7 +11,7 @@ buildscript { ext { buildToolsVersion = "31.0.0" - minSdkVersion = 23 + minSdkVersion = 24 compileSdkVersion = 31 targetSdkVersion = 31 if (System.properties['os.arch'] == "aarch64") { @@ -28,6 +28,7 @@ buildscript { libre_build = !(isPlay.toBoolean()) jitsi_url = "https://github.com/RocketChat/jitsi-maven-repository/raw/master/releases" jitsi_version = "3.7.0" + ffmpegKitPackage = "audio" } repositories { diff --git a/app/containers/MessageBox/RecordAudio.tsx b/app/containers/MessageBox/RecordAudio.tsx index 2f2152721..7a749f58f 100644 --- a/app/containers/MessageBox/RecordAudio.tsx +++ b/app/containers/MessageBox/RecordAudio.tsx @@ -4,13 +4,16 @@ import { Audio, InterruptionModeAndroid, InterruptionModeIOS } from 'expo-av'; import { BorderlessButton } from 'react-native-gesture-handler'; import { getInfoAsync } from 'expo-file-system'; import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake'; +import * as FileSystem from 'expo-file-system'; +import { FFmpegKit, ReturnCode } from 'ffmpeg-kit-react-native'; import styles from './styles'; import I18n from '../../i18n'; import { themes } from '../../lib/constants'; -import { CustomIcon } from '../CustomIcon'; +import { parseFilename, sanitizeString } from '../../lib/methods/audioFile'; import { events, logEvent } from '../../lib/methods/helpers/log'; import { TSupportedThemes } from '../../theme'; +import { CustomIcon } from '../CustomIcon'; interface IMessageBoxRecordAudioProps { theme: TSupportedThemes; @@ -157,17 +160,28 @@ export default class RecordAudio extends React.PureComponent { + const returnCode = await session.getReturnCode(); + if (ReturnCode.isSuccess(returnCode)) { + const fileData = await getInfoAsync(newFilePath); + console.log(fileData) + const fileInfo = { + name: parseFilename(fileData.uri), + mime: 'audio/mpeg', + type: 'audio/mpeg', + store: 'Uploads', + path: newFilePath, + size: fileData.size + }; + onFinish(fileInfo); + } else { + console.log('error'); + } + }); } catch (error) { logEvent(events.ROOM_AUDIO_FINISH_F); } diff --git a/app/lib/methods/audioFile.ts b/app/lib/methods/audioFile.ts index 31cd09f9e..65e627457 100644 --- a/app/lib/methods/audioFile.ts +++ b/app/lib/methods/audioFile.ts @@ -4,9 +4,9 @@ import { sanitizeLikeString } from '../database/utils'; import { store } from '../store/auxStore'; import log from './helpers/log'; -const sanitizeString = (value: string) => sanitizeLikeString(value.substring(value.lastIndexOf('/') + 1)); +export const sanitizeString = (value: string) => sanitizeLikeString(value.substring(value.lastIndexOf('/') + 1)); -const parseFilename = (value: string) => { +export const parseFilename = (value: string) => { const extension = value.substring(value.lastIndexOf('.') + 1); const filename = sanitizeString(value.substring(value.lastIndexOf('/') + 1).split('.')[0]); return `${filename}.${extension}`; diff --git a/ios/Podfile b/ios/Podfile index 306f8ced6..27616cc33 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -9,6 +9,7 @@ def all_pods pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi', :modular_headers => true pod 'simdjson', path: '../node_modules/@nozbe/simdjson' pod 'ReactNativeUiLib', :path => '../node_modules/react-native-ui-lib/lib' + pod 'ffmpeg-kit-react-native', :subspecs => ['audio'], :podspec => '../node_modules/ffmpeg-kit-react-native/ffmpeg-kit-react-native.podspec' $RNFirebaseAnalyticsWithoutAdIdSupport = true config = use_native_modules! diff --git a/ios/Podfile.lock b/ios/Podfile.lock index c7fa41434..f0e6ba884 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -34,6 +34,10 @@ PODS: - React-Core (= 0.68.2) - React-jsi (= 0.68.2) - ReactCommon/turbomodule/core (= 0.68.2) + - ffmpeg-kit-ios-audio (5.1) + - ffmpeg-kit-react-native/audio (5.1.0): + - ffmpeg-kit-ios-audio (= 5.1) + - React-Core - Firebase/AnalyticsWithoutAdIdSupport (8.15.0): - Firebase/CoreOnly - FirebaseAnalytics/WithoutAdIdSupport (~> 8.15.0) @@ -600,6 +604,7 @@ DEPENDENCIES: - EXVideoThumbnails (from `../node_modules/expo-video-thumbnails/ios`) - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) + - ffmpeg-kit-react-native/audio (from `../node_modules/ffmpeg-kit-react-native/ffmpeg-kit-react-native.podspec`) - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) - hermes-engine (~> 0.11.0) - JitsiMeetSDK (from `https://github.com/RocketChat/jitsi-meet-ios-sdk-releases.git`) @@ -680,6 +685,7 @@ DEPENDENCIES: SPEC REPOS: trunk: + - ffmpeg-kit-ios-audio - Firebase - FirebaseAnalytics - FirebaseCore @@ -734,6 +740,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/Libraries/FBLazyVector" FBReactNativeSpec: :path: "../node_modules/react-native/React/FBReactNativeSpec" + ffmpeg-kit-react-native: + :podspec: "../node_modules/ffmpeg-kit-react-native/ffmpeg-kit-react-native.podspec" glog: :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" JitsiMeetSDK: @@ -902,6 +910,8 @@ SPEC CHECKSUMS: EXVideoThumbnails: 19e055dc3245b53c536da9e0ef9c618fd2118297 FBLazyVector: a7a655862f6b09625d11c772296b01cd5164b648 FBReactNativeSpec: 66b5770d86bfee27d67b850416dbc7123c4f6311 + ffmpeg-kit-ios-audio: 6eaf5a3c4249b767328502747a08bfd901a86d3d + ffmpeg-kit-react-native: 5950b8015ff2c4fa7c00372d5ce598123902d23d Firebase: 5f8193dff4b5b7c5d5ef72ae54bb76c08e2b841d FirebaseAnalytics: 7761cbadb00a717d8d0939363eb46041526474fa FirebaseCore: 5743c5785c074a794d35f2fff7ecc254a91e08b1 @@ -998,6 +1008,6 @@ SPEC CHECKSUMS: WatermelonDB: 577c61fceff16e9f9103b59d14aee4850c0307b6 Yoga: 99652481fcd320aefa4a7ef90095b95acd181952 -PODFILE CHECKSUM: 052cbf741847405abc3b902c9e107c1ebb48b252 +PODFILE CHECKSUM: fa943eef52304cbca92070cf5ab4be1008650d23 COCOAPODS: 1.11.3 diff --git a/package.json b/package.json index 8c1a7ed62..473a561aa 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "expo-local-authentication": "12.2.0", "expo-video-thumbnails": "6.3.0", "expo-web-browser": "10.2.1", + "ffmpeg-kit-react-native": "^5.1.0", "hoist-non-react-statics": "3.3.2", "i18n-js": "3.9.2", "js-base64": "3.6.1", diff --git a/react-native.config.js b/react-native.config.js index 9e78b41ad..c91c3e742 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -14,6 +14,11 @@ module.exports = { platforms: { android: null } + }, + 'ffmpeg-kit-react-native': { + platforms: { + ios: null + } } } }; diff --git a/yarn.lock b/yarn.lock index 8c1b12e98..ac189a463 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10969,6 +10969,11 @@ fetch-retry@^4.1.1: resolved "https://registry.yarnpkg.com/fetch-retry/-/fetch-retry-4.1.1.tgz#fafe0bb22b54f4d0a9c788dff6dd7f8673ca63f3" integrity sha512-e6eB7zN6UBSwGVwrbWVH+gdLnkW9WwHhmq2YDK1Sh30pzx1onRVGBvogTlUeWxwTa+L86NYdo4hFkh7O8ZjSnA== +ffmpeg-kit-react-native@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/ffmpeg-kit-react-native/-/ffmpeg-kit-react-native-5.1.0.tgz#7aea05ee642b0b204777ba36994f41ed192ec4ca" + integrity sha512-WGuF7wm18vvhr1oCMLRfHIDCwKrmBezWgVtzim6Z3cbDiHeYvDjpm7KJwrvBMwOgekQtP4R4zI9W0ZByoXjMnQ== + figgy-pudding@^3.5.1: version "3.5.2" resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e"