File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
package/expo-package/src/optionalDependencies Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -267,9 +267,19 @@ const flattenExpoAudioRecordingOptions = (
267267 ...options . ios ,
268268 } ;
269269 } else if ( Platform . OS === 'android' ) {
270+ const audioEncoder = options . android . audioEncoder ;
271+ const audioEncoderConfig = audioEncoder
272+ ? { audioEncoder : expoAvToExpoAudioAndroidEncoderAdapter ( audioEncoder ) }
273+ : { } ;
274+ const outputFormat = options . android . outputFormat ;
275+ const outputFormatConfig = outputFormat
276+ ? { outputFormat : expoAvToExpoAudioAndroidOutputAdapter ( outputFormat ) }
277+ : { } ;
270278 commonOptions = {
271279 ...commonOptions ,
272280 ...options . android ,
281+ ...audioEncoderConfig ,
282+ ...outputFormatConfig ,
273283 } ;
274284 }
275285 return commonOptions ;
@@ -295,6 +305,44 @@ const expoAvToExpoAudioModeAdapter = (mode: AudioRecordingConfiguration['mode'])
295305 } ;
296306} ;
297307
308+ const expoAvToExpoAudioAndroidEncoderAdapter = (
309+ audioEncoder : AudioRecordingConfiguration [ 'options' ] [ 'android' ] [ 'audioEncoder' ] ,
310+ ) => {
311+ const encoderMap = {
312+ 0 : 'default' ,
313+ 1 : 'amr_nb' ,
314+ 2 : 'amr_wb' ,
315+ 3 : 'aac' ,
316+ 4 : 'he_aac' ,
317+ 5 : 'aac_eld' ,
318+ } ;
319+
320+ return Object . keys ( encoderMap ) . includes ( audioEncoder . toString ( ) )
321+ ? encoderMap [ audioEncoder ]
322+ : 'default' ;
323+ } ;
324+
325+ const expoAvToExpoAudioAndroidOutputAdapter = (
326+ outputFormat : AudioRecordingConfiguration [ 'options' ] [ 'android' ] [ 'outputFormat' ] ,
327+ ) => {
328+ const outputFormatMap = {
329+ 0 : 'default' ,
330+ 1 : '3gp' ,
331+ 2 : 'mpeg4' ,
332+ 3 : 'amrnb' ,
333+ 4 : 'amrwb' ,
334+ 5 : 'default' ,
335+ 6 : 'aac_adts' ,
336+ 7 : 'default' ,
337+ 8 : 'mpeg2ts' ,
338+ 9 : 'webm' ,
339+ } ;
340+
341+ return Object . keys ( outputFormatMap ) . includes ( outputFormat . toString ( ) )
342+ ? outputFormatMap [ outputFormat ]
343+ : 'default' ;
344+ } ;
345+
298346// Always try to prioritize expo-audio if it's there.
299347export const Audio = ExpoRecordingComponent
300348 ? new _AudioExpoAudio ( )
You can’t perform that action at this time.
0 commit comments