diff --git a/build/Audio/Recording.d.ts b/build/Audio/Recording.d.ts index 83f7417649f30..f744b650d1b1e 100644 --- a/build/Audio/Recording.d.ts +++ b/build/Audio/Recording.d.ts @@ -120,6 +120,7 @@ export declare class Recording { pauseAsync(): Promise; stopAndUnloadAsync(): Promise; getURI(): string | null; + /** @deprecated Use `createNewLoadedSoundAsync()` instead */ createNewLoadedSound(initialStatus?: AVPlaybackStatusToSet, onPlaybackStatusUpdate?: ((status: AVPlaybackStatus) => void) | null): Promise<{ sound: Sound; status: AVPlaybackStatus; diff --git a/build/Audio/Recording.js b/build/Audio/Recording.js index 7eb292a93bbf1..1a36f9a20af3a 100644 --- a/build/Audio/Recording.js +++ b/build/Audio/Recording.js @@ -271,6 +271,7 @@ export class Recording { getURI() { return this._uri; } + /** @deprecated Use `createNewLoadedSoundAsync()` instead */ async createNewLoadedSound(initialStatus = {}, onPlaybackStatusUpdate = null) { console.warn(`createNewLoadedSound is deprecated in favor of createNewLoadedSoundAsync, which has the same API aside from the method name`); return this.createNewLoadedSoundAsync(initialStatus, onPlaybackStatusUpdate); diff --git a/build/Audio/Recording.js.map b/build/Audio/Recording.js.map index 6ce1b1dcd6343..a0ce9c696f814 100644 --- a/build/Audio/Recording.js.map +++ b/build/Audio/Recording.js.map @@ -1 +1 @@ -{"version":3,"file":"Recording.js","sourceRoot":"","sources":["../../src/Audio/Recording.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAsB,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAExF,OAAO,EACL,wCAAwC,GAGzC,MAAM,OAAO,CAAC;AACf,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AA2BhC,yCAAyC;AACzC,MAAM,CAAC,MAAM,8C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C,0DAA0D,CAAC,CAAC;SAC7E;QACD,OAAO,KAAK,CAAC,WAAW;QACtB,oEAAoE;QACpE,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,EAClB,aAAa,EACb,sBAAsB,EACtB,KAAK,CACN,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { EventEmitter, Subscription, Platform } from '@unimodules/core';\nimport { PermissionResponse, PermissionStatus } from 'unimodules-permissions-interface';\n\nimport {\n _DEFAULT_PROGRESS_UPDATE_INTERVAL_MILLIS,\n AVPlaybackStatus,\n AVPlaybackStatusToSet,\n} from '../AV';\nimport ExponentAV from '../ExponentAV';\nimport { isAudioEnabled, throwIfAudioIsDisabled } from './AudioAvailability';\nimport { Sound } from './Sound';\n\nexport type RecordingOptions = {\n android: {\n extension: string;\n outputFormat: number;\n audioEncoder: number;\n sampleRate?: number;\n numberOfChannels?: number;\n bitRate?: number;\n maxFileSize?: number;\n };\n ios: {\n extension: string;\n outputFormat?: string | number;\n audioQuality: number;\n sampleRate: number;\n numberOfChannels: number;\n bitRate: number;\n bitRateStrategy?: number;\n bitDepthHint?: number;\n linearPCMBitDepth?: number;\n linearPCMIsBigEndian?: boolean;\n linearPCMIsFloat?: boolean;\n };\n};\n\n// TODO: consider changing these to enums\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_DEFAULT = 0;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_THREE_GPP = 1;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG_4 = 2;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AMR_NB = 3;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AMR_WB = 4;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AAC_ADIF = 5;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AAC_ADTS = 6;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_RTP_AVP = 7;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG2TS = 8;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_WEBM = 9;\n\nexport const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_DEFAULT = 0;\nexport const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AMR_NB = 1;\nexport const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AMR_WB = 2;\nexport const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC = 3;\nexport const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_HE_AAC = 4;\nexport const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC_ELD = 5;\n\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_LINEARPCM = 'lpcm';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AC3 = 'ac-3';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_60958AC3 = 'cac3';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_APPLEIMA4 = 'ima4';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC = 'aac ';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4CELP = 'celp';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4HVXC = 'hvxc';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4TWINVQ = 'twvq';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MACE3 = 'MAC3';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MACE6 = 'MAC6';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_ULAW = 'ulaw';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_ALAW = 'alaw';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_QDESIGN = 'QDMC';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_QDESIGN2 = 'QDM2';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_QUALCOMM = 'Qclp';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER1 = '.mp1';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER2 = '.mp2';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER3 = '.mp3';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_APPLELOSSLESS = 'alac';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_HE = 'aach';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_LD = 'aacl';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD = 'aace';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD_SBR = 'aacf';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD_V2 = 'aacg';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_HE_V2 = 'aacp';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_SPATIAL = 'aacs';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AMR = 'samr';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AMR_WB = 'sawb';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AUDIBLE = 'AUDB';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_ILBC = 'ilbc';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_DVIINTELIMA = 0x6d730011;\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MICROSOFTGSM = 0x6d730031;\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AES3 = 'aes3';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_ENHANCEDAC3 = 'ec-3';\n\nexport const RECORDING_OPTION_IOS_AUDIO_QUALITY_MIN = 0;\nexport const RECORDING_OPTION_IOS_AUDIO_QUALITY_LOW = 0x20;\nexport const RECORDING_OPTION_IOS_AUDIO_QUALITY_MEDIUM = 0x40;\nexport const RECORDING_OPTION_IOS_AUDIO_QUALITY_HIGH = 0x60;\nexport const RECORDING_OPTION_IOS_AUDIO_QUALITY_MAX = 0x7f;\n\nexport const RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_CONSTANT = 0;\nexport const RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_LONG_TERM_AVERAGE = 1;\nexport const RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_VARIABLE_CONSTRAINED = 2;\nexport const RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_VARIABLE = 3;\n\n// TODO : maybe make presets for music and speech, or lossy / lossless.\n\nexport const RECORDING_OPTIONS_PRESET_HIGH_QUALITY: RecordingOptions = {\n android: {\n extension: '.m4a',\n outputFormat: RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG_4,\n audioEncoder: RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC,\n sampleRate: 44100,\n numberOfChannels: 2,\n bitRate: 128000,\n },\n ios: {\n extension: '.caf',\n audioQuality: RECORDING_OPTION_IOS_AUDIO_QUALITY_MAX,\n sampleRate: 44100,\n numberOfChannels: 2,\n bitRate: 128000,\n linearPCMBitDepth: 16,\n linearPCMIsBigEndian: false,\n linearPCMIsFloat: false,\n },\n};\n\nexport const RECORDING_OPTIONS_PRESET_LOW_QUALITY: RecordingOptions = {\n android: {\n extension: '.3gp',\n outputFormat: RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_THREE_GPP,\n audioEncoder: RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AMR_NB,\n sampleRate: 44100,\n numberOfChannels: 2,\n bitRate: 128000,\n },\n ios: {\n extension: '.caf',\n audioQuality: RECORDING_OPTION_IOS_AUDIO_QUALITY_MIN,\n sampleRate: 44100,\n numberOfChannels: 2,\n bitRate: 128000,\n linearPCMBitDepth: 16,\n linearPCMIsBigEndian: false,\n linearPCMIsFloat: false,\n },\n};\n\n// TODO: For consistency with PlaybackStatus, should we include progressUpdateIntervalMillis here as\n// well?\nexport type RecordingStatus = {\n canRecord: boolean;\n isRecording: boolean;\n isDoneRecording: boolean;\n durationMillis: number;\n};\n\nexport { PermissionResponse, PermissionStatus };\n\nlet _recorderExists: boolean = false;\nconst eventEmitter = Platform.OS === 'android' ? new EventEmitter(ExponentAV) : null;\n\nexport async function getPermissionsAsync(): Promise {\n return ExponentAV.getPermissionsAsync();\n}\n\nexport async function requestPermissionsAsync(): Promise {\n return ExponentAV.requestPermissionsAsync();\n}\n\nexport class Recording {\n _subscription: Subscription | null = null;\n _canRecord: boolean = false;\n _isDoneRecording: boolean = false;\n _finalDurationMillis: number = 0;\n _uri: string | null = null;\n _onRecordingStatusUpdate: ((status: RecordingStatus) => void) | null = null;\n _progressUpdateTimeoutVariable: number | null = null;\n _progressUpdateIntervalMillis: number = _DEFAULT_PROGRESS_UPDATE_INTERVAL_MILLIS;\n _options: RecordingOptions | null = null;\n\n // Internal methods\n\n _cleanupForUnloadedRecorder = async (finalStatus: RecordingStatus) => {\n this._canRecord = false;\n this._isDoneRecording = true;\n // $FlowFixMe(greg): durationMillis is not always defined\n this._finalDurationMillis = finalStatus.durationMillis;\n _recorderExists = false;\n if (this._subscription) {\n this._subscription.remove();\n this._subscription = null;\n }\n this._disablePolling();\n return await this.getStatusAsync(); // Automatically calls onRecordingStatusUpdate for the final state.\n };\n\n _pollingLoop = async () => {\n if (isAudioEnabled() && this._canRecord && this._onRecordingStatusUpdate != null) {\n this._progressUpdateTimeoutVariable = setTimeout(\n this._pollingLoop,\n this._progressUpdateIntervalMillis\n ) as any;\n try {\n await this.getStatusAsync();\n } catch (error) {\n this._disablePolling();\n }\n }\n };\n\n _disablePolling() {\n if (this._progressUpdateTimeoutVariable != null) {\n clearTimeout(this._progressUpdateTimeoutVariable);\n this._progressUpdateTimeoutVariable = null;\n }\n }\n\n _enablePollingIfNecessaryAndPossible() {\n if (isAudioEnabled() && this._canRecord && this._onRecordingStatusUpdate != null) {\n this._disablePolling();\n this._pollingLoop();\n }\n }\n\n _callOnRecordingStatusUpdateForNewStatus(status: RecordingStatus) {\n if (this._onRecordingStatusUpdate != null) {\n this._onRecordingStatusUpdate(status);\n }\n }\n\n async _performOperationAndHandleStatusAsync(\n operation: () => Promise\n ): Promise {\n throwIfAudioIsDisabled();\n if (this._canRecord) {\n const status = await operation();\n this._callOnRecordingStatusUpdateForNewStatus(status);\n return status;\n } else {\n throw new Error('Cannot complete operation because this recorder is not ready to record.');\n }\n }\n\n // Note that all calls automatically call onRecordingStatusUpdate as a side effect.\n\n // Get status API\n\n getStatusAsync = async (): Promise => {\n // Automatically calls onRecordingStatusUpdate.\n if (this._canRecord) {\n return this._performOperationAndHandleStatusAsync(() => ExponentAV.getAudioRecordingStatus());\n }\n const status = {\n canRecord: false,\n isRecording: false,\n isDoneRecording: this._isDoneRecording,\n durationMillis: this._finalDurationMillis,\n };\n this._callOnRecordingStatusUpdateForNewStatus(status);\n return status;\n };\n\n setOnRecordingStatusUpdate(onRecordingStatusUpdate: ((status: RecordingStatus) => void) | null) {\n this._onRecordingStatusUpdate = onRecordingStatusUpdate;\n if (onRecordingStatusUpdate == null) {\n this._disablePolling();\n } else {\n this._enablePollingIfNecessaryAndPossible();\n }\n this.getStatusAsync();\n }\n\n setProgressUpdateInterval(progressUpdateIntervalMillis: number) {\n this._progressUpdateIntervalMillis = progressUpdateIntervalMillis;\n this.getStatusAsync();\n }\n\n // Record API\n\n async prepareToRecordAsync(\n options: RecordingOptions = RECORDING_OPTIONS_PRESET_LOW_QUALITY\n ): Promise {\n throwIfAudioIsDisabled();\n\n if (_recorderExists) {\n throw new Error('Only one Recording object can be prepared at a given time.');\n }\n\n if (this._isDoneRecording) {\n throw new Error('This Recording object is done recording; you must make a new one.');\n }\n\n if (!options || !options.android || !options.ios) {\n throw new Error(\n 'You must provide recording options for android and ios in order to prepare to record.'\n );\n }\n\n const extensionRegex = /^\\.\\w+$/;\n if (\n !options.android.extension ||\n !options.ios.extension ||\n !extensionRegex.test(options.android.extension) ||\n !extensionRegex.test(options.ios.extension)\n ) {\n throw new Error(`Your file extensions must match ${extensionRegex.toString()}.`);\n }\n\n if (!this._canRecord) {\n if (eventEmitter) {\n this._subscription = eventEmitter.addListener(\n 'Expo.Recording.recorderUnloaded',\n this._cleanupForUnloadedRecorder\n );\n }\n\n const {\n uri,\n status,\n }: {\n uri: string;\n // status is of type RecordingStatus, but without the canRecord field populated\n status: Pick>;\n } = await ExponentAV.prepareAudioRecorder(options);\n\n _recorderExists = true;\n this._uri = uri;\n this._options = options;\n this._canRecord = true;\n\n const currentStatus = { ...status, canRecord: true };\n this._callOnRecordingStatusUpdateForNewStatus(currentStatus);\n this._enablePollingIfNecessaryAndPossible();\n return currentStatus;\n } else {\n throw new Error('This Recording object is already prepared to record.');\n }\n }\n\n async startAsync(): Promise {\n return this._performOperationAndHandleStatusAsync(() => ExponentAV.startAudioRecording());\n }\n\n async pauseAsync(): Promise {\n return this._performOperationAndHandleStatusAsync(() => ExponentAV.pauseAudioRecording());\n }\n\n async stopAndUnloadAsync(): Promise {\n if (!this._canRecord) {\n if (this._isDoneRecording) {\n throw new Error('Cannot unload a Recording that has already been unloaded.');\n } else {\n throw new Error('Cannot unload a Recording that has not been prepared.');\n }\n }\n // We perform a separate native API call so that the state of the Recording can be updated with\n // the final duration of the recording. (We cast stopStatus as Object to appease Flow)\n const finalStatus = await ExponentAV.stopAudioRecording();\n await ExponentAV.unloadAudioRecorder();\n return this._cleanupForUnloadedRecorder(finalStatus);\n }\n\n // Read API\n\n getURI(): string | null {\n return this._uri;\n }\n\n async createNewLoadedSound(\n initialStatus: AVPlaybackStatusToSet = {},\n onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null\n ): Promise<{ sound: Sound; status: AVPlaybackStatus }> {\n console.warn(\n `createNewLoadedSound is deprecated in favor of createNewLoadedSoundAsync, which has the same API aside from the method name`\n );\n return this.createNewLoadedSoundAsync(initialStatus, onPlaybackStatusUpdate);\n }\n\n async createNewLoadedSoundAsync(\n initialStatus: AVPlaybackStatusToSet = {},\n onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null\n ): Promise<{ sound: Sound; status: AVPlaybackStatus }> {\n if (this._uri == null || !this._isDoneRecording) {\n throw new Error('Cannot create sound when the Recording has not finished!');\n }\n return Sound.createAsync(\n // $FlowFixMe: Flow can't distinguish between this literal and Asset\n { uri: this._uri },\n initialStatus,\n onPlaybackStatusUpdate,\n false\n );\n }\n}\n"]} \ No newline at end of file +{"version":3,"file":"Recording.js","sourceRoot":"","sources":["../../src/Audio/Recording.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAsB,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAExF,OAAO,EACL,wCAAwC,GAGzC,MAAM,OAAO,CAAC;AACf,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AA2BhC,yCAAyC;AACzC,MAAM,CAAC,MAAM,8CAA8C,GAAG,CAAC,CAAC;AAChE,MAAM,CAAC,MAAM,gDAAgD,GAAG,CAAC,CAAC;AAClE,MAAM,CAAC,MAAM,6CAA6C,GAAG,CAAC,CAAC;AAC/D,MAAM,CAAC,MAAM,6CAA6C,GAAG,CAAC,CAAC;AAC/D,MAAM,CAAC,MAAM,6CAA6C,GAAG,CAAC,CAAC;AAC/D,MAAM,CAAC,MAAM,+CAA+C,GAAG,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,+CAA+C,GAAG,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,8CAA8C,GAAG,CAAC,CAAC;AAChE,MAAM,CAAC,MAAM,8CA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YACpB,IAAI,IAAI,CAAC,gBAAgB,EAAE;gBACzB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;aAC9E;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;aAC1E;SACF;QACD,+FAA+F;QAC/F,sFAAsF;QACtF,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,kBAAkB,EAAE,CAAC;QAC1D,MAAM,UAAU,CAAC,mBAAmB,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC,2BAA2B,CAAC,WAAW,CAAC,CAAC;IACvD,CAAC;IAED,WAAW;IAEX,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,oBAAoB,CACxB,gBAAuC,EAAE,EACzC,yBAAsE,IAAI;QAE1E,OAAO,CAAC,IAAI,CACV,6HAA6H,CAC9H,CAAC;QACF,OAAO,IAAI,CAAC,yBAAyB,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC;IAC/E,CAAC;IAED,KAAK,CAAC,yBAAyB,CAC7B,gBAAuC,EAAE,EACzC,yBAAsE,IAAI;QAE1E,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;YAC/C,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;SAC7E;QACD,OAAO,KAAK,CAAC,WAAW;QACtB,oEAAoE;QACpE,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,EAClB,aAAa,EACb,sBAAsB,EACtB,KAAK,CACN,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { EventEmitter, Subscription, Platform } from '@unimodules/core';\nimport { PermissionResponse, PermissionStatus } from 'unimodules-permissions-interface';\n\nimport {\n _DEFAULT_PROGRESS_UPDATE_INTERVAL_MILLIS,\n AVPlaybackStatus,\n AVPlaybackStatusToSet,\n} from '../AV';\nimport ExponentAV from '../ExponentAV';\nimport { isAudioEnabled, throwIfAudioIsDisabled } from './AudioAvailability';\nimport { Sound } from './Sound';\n\nexport type RecordingOptions = {\n android: {\n extension: string;\n outputFormat: number;\n audioEncoder: number;\n sampleRate?: number;\n numberOfChannels?: number;\n bitRate?: number;\n maxFileSize?: number;\n };\n ios: {\n extension: string;\n outputFormat?: string | number;\n audioQuality: number;\n sampleRate: number;\n numberOfChannels: number;\n bitRate: number;\n bitRateStrategy?: number;\n bitDepthHint?: number;\n linearPCMBitDepth?: number;\n linearPCMIsBigEndian?: boolean;\n linearPCMIsFloat?: boolean;\n };\n};\n\n// TODO: consider changing these to enums\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_DEFAULT = 0;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_THREE_GPP = 1;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG_4 = 2;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AMR_NB = 3;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AMR_WB = 4;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AAC_ADIF = 5;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AAC_ADTS = 6;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_RTP_AVP = 7;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG2TS = 8;\nexport const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_WEBM = 9;\n\nexport const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_DEFAULT = 0;\nexport const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AMR_NB = 1;\nexport const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AMR_WB = 2;\nexport const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC = 3;\nexport const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_HE_AAC = 4;\nexport const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC_ELD = 5;\n\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_LINEARPCM = 'lpcm';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AC3 = 'ac-3';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_60958AC3 = 'cac3';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_APPLEIMA4 = 'ima4';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC = 'aac ';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4CELP = 'celp';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4HVXC = 'hvxc';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4TWINVQ = 'twvq';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MACE3 = 'MAC3';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MACE6 = 'MAC6';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_ULAW = 'ulaw';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_ALAW = 'alaw';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_QDESIGN = 'QDMC';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_QDESIGN2 = 'QDM2';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_QUALCOMM = 'Qclp';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER1 = '.mp1';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER2 = '.mp2';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER3 = '.mp3';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_APPLELOSSLESS = 'alac';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_HE = 'aach';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_LD = 'aacl';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD = 'aace';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD_SBR = 'aacf';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD_V2 = 'aacg';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_HE_V2 = 'aacp';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_SPATIAL = 'aacs';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AMR = 'samr';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AMR_WB = 'sawb';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AUDIBLE = 'AUDB';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_ILBC = 'ilbc';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_DVIINTELIMA = 0x6d730011;\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MICROSOFTGSM = 0x6d730031;\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AES3 = 'aes3';\nexport const RECORDING_OPTION_IOS_OUTPUT_FORMAT_ENHANCEDAC3 = 'ec-3';\n\nexport const RECORDING_OPTION_IOS_AUDIO_QUALITY_MIN = 0;\nexport const RECORDING_OPTION_IOS_AUDIO_QUALITY_LOW = 0x20;\nexport const RECORDING_OPTION_IOS_AUDIO_QUALITY_MEDIUM = 0x40;\nexport const RECORDING_OPTION_IOS_AUDIO_QUALITY_HIGH = 0x60;\nexport const RECORDING_OPTION_IOS_AUDIO_QUALITY_MAX = 0x7f;\n\nexport const RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_CONSTANT = 0;\nexport const RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_LONG_TERM_AVERAGE = 1;\nexport const RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_VARIABLE_CONSTRAINED = 2;\nexport const RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_VARIABLE = 3;\n\n// TODO : maybe make presets for music and speech, or lossy / lossless.\n\nexport const RECORDING_OPTIONS_PRESET_HIGH_QUALITY: RecordingOptions = {\n android: {\n extension: '.m4a',\n outputFormat: RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG_4,\n audioEncoder: RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC,\n sampleRate: 44100,\n numberOfChannels: 2,\n bitRate: 128000,\n },\n ios: {\n extension: '.caf',\n audioQuality: RECORDING_OPTION_IOS_AUDIO_QUALITY_MAX,\n sampleRate: 44100,\n numberOfChannels: 2,\n bitRate: 128000,\n linearPCMBitDepth: 16,\n linearPCMIsBigEndian: false,\n linearPCMIsFloat: false,\n },\n};\n\nexport const RECORDING_OPTIONS_PRESET_LOW_QUALITY: RecordingOptions = {\n android: {\n extension: '.3gp',\n outputFormat: RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_THREE_GPP,\n audioEncoder: RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AMR_NB,\n sampleRate: 44100,\n numberOfChannels: 2,\n bitRate: 128000,\n },\n ios: {\n extension: '.caf',\n audioQuality: RECORDING_OPTION_IOS_AUDIO_QUALITY_MIN,\n sampleRate: 44100,\n numberOfChannels: 2,\n bitRate: 128000,\n linearPCMBitDepth: 16,\n linearPCMIsBigEndian: false,\n linearPCMIsFloat: false,\n },\n};\n\n// TODO: For consistency with PlaybackStatus, should we include progressUpdateIntervalMillis here as\n// well?\nexport type RecordingStatus = {\n canRecord: boolean;\n isRecording: boolean;\n isDoneRecording: boolean;\n durationMillis: number;\n};\n\nexport { PermissionResponse, PermissionStatus };\n\nlet _recorderExists: boolean = false;\nconst eventEmitter = Platform.OS === 'android' ? new EventEmitter(ExponentAV) : null;\n\nexport async function getPermissionsAsync(): Promise {\n return ExponentAV.getPermissionsAsync();\n}\n\nexport async function requestPermissionsAsync(): Promise {\n return ExponentAV.requestPermissionsAsync();\n}\n\nexport class Recording {\n _subscription: Subscription | null = null;\n _canRecord: boolean = false;\n _isDoneRecording: boolean = false;\n _finalDurationMillis: number = 0;\n _uri: string | null = null;\n _onRecordingStatusUpdate: ((status: RecordingStatus) => void) | null = null;\n _progressUpdateTimeoutVariable: number | null = null;\n _progressUpdateIntervalMillis: number = _DEFAULT_PROGRESS_UPDATE_INTERVAL_MILLIS;\n _options: RecordingOptions | null = null;\n\n // Internal methods\n\n _cleanupForUnloadedRecorder = async (finalStatus: RecordingStatus) => {\n this._canRecord = false;\n this._isDoneRecording = true;\n // $FlowFixMe(greg): durationMillis is not always defined\n this._finalDurationMillis = finalStatus.durationMillis;\n _recorderExists = false;\n if (this._subscription) {\n this._subscription.remove();\n this._subscription = null;\n }\n this._disablePolling();\n return await this.getStatusAsync(); // Automatically calls onRecordingStatusUpdate for the final state.\n };\n\n _pollingLoop = async () => {\n if (isAudioEnabled() && this._canRecord && this._onRecordingStatusUpdate != null) {\n this._progressUpdateTimeoutVariable = setTimeout(\n this._pollingLoop,\n this._progressUpdateIntervalMillis\n ) as any;\n try {\n await this.getStatusAsync();\n } catch (error) {\n this._disablePolling();\n }\n }\n };\n\n _disablePolling() {\n if (this._progressUpdateTimeoutVariable != null) {\n clearTimeout(this._progressUpdateTimeoutVariable);\n this._progressUpdateTimeoutVariable = null;\n }\n }\n\n _enablePollingIfNecessaryAndPossible() {\n if (isAudioEnabled() && this._canRecord && this._onRecordingStatusUpdate != null) {\n this._disablePolling();\n this._pollingLoop();\n }\n }\n\n _callOnRecordingStatusUpdateForNewStatus(status: RecordingStatus) {\n if (this._onRecordingStatusUpdate != null) {\n this._onRecordingStatusUpdate(status);\n }\n }\n\n async _performOperationAndHandleStatusAsync(\n operation: () => Promise\n ): Promise {\n throwIfAudioIsDisabled();\n if (this._canRecord) {\n const status = await operation();\n this._callOnRecordingStatusUpdateForNewStatus(status);\n return status;\n } else {\n throw new Error('Cannot complete operation because this recorder is not ready to record.');\n }\n }\n\n // Note that all calls automatically call onRecordingStatusUpdate as a side effect.\n\n // Get status API\n\n getStatusAsync = async (): Promise => {\n // Automatically calls onRecordingStatusUpdate.\n if (this._canRecord) {\n return this._performOperationAndHandleStatusAsync(() => ExponentAV.getAudioRecordingStatus());\n }\n const status = {\n canRecord: false,\n isRecording: false,\n isDoneRecording: this._isDoneRecording,\n durationMillis: this._finalDurationMillis,\n };\n this._callOnRecordingStatusUpdateForNewStatus(status);\n return status;\n };\n\n setOnRecordingStatusUpdate(onRecordingStatusUpdate: ((status: RecordingStatus) => void) | null) {\n this._onRecordingStatusUpdate = onRecordingStatusUpdate;\n if (onRecordingStatusUpdate == null) {\n this._disablePolling();\n } else {\n this._enablePollingIfNecessaryAndPossible();\n }\n this.getStatusAsync();\n }\n\n setProgressUpdateInterval(progressUpdateIntervalMillis: number) {\n this._progressUpdateIntervalMillis = progressUpdateIntervalMillis;\n this.getStatusAsync();\n }\n\n // Record API\n\n async prepareToRecordAsync(\n options: RecordingOptions = RECORDING_OPTIONS_PRESET_LOW_QUALITY\n ): Promise {\n throwIfAudioIsDisabled();\n\n if (_recorderExists) {\n throw new Error('Only one Recording object can be prepared at a given time.');\n }\n\n if (this._isDoneRecording) {\n throw new Error('This Recording object is done recording; you must make a new one.');\n }\n\n if (!options || !options.android || !options.ios) {\n throw new Error(\n 'You must provide recording options for android and ios in order to prepare to record.'\n );\n }\n\n const extensionRegex = /^\\.\\w+$/;\n if (\n !options.android.extension ||\n !options.ios.extension ||\n !extensionRegex.test(options.android.extension) ||\n !extensionRegex.test(options.ios.extension)\n ) {\n throw new Error(`Your file extensions must match ${extensionRegex.toString()}.`);\n }\n\n if (!this._canRecord) {\n if (eventEmitter) {\n this._subscription = eventEmitter.addListener(\n 'Expo.Recording.recorderUnloaded',\n this._cleanupForUnloadedRecorder\n );\n }\n\n const {\n uri,\n status,\n }: {\n uri: string;\n // status is of type RecordingStatus, but without the canRecord field populated\n status: Pick>;\n } = await ExponentAV.prepareAudioRecorder(options);\n\n _recorderExists = true;\n this._uri = uri;\n this._options = options;\n this._canRecord = true;\n\n const currentStatus = { ...status, canRecord: true };\n this._callOnRecordingStatusUpdateForNewStatus(currentStatus);\n this._enablePollingIfNecessaryAndPossible();\n return currentStatus;\n } else {\n throw new Error('This Recording object is already prepared to record.');\n }\n }\n\n async startAsync(): Promise {\n return this._performOperationAndHandleStatusAsync(() => ExponentAV.startAudioRecording());\n }\n\n async pauseAsync(): Promise {\n return this._performOperationAndHandleStatusAsync(() => ExponentAV.pauseAudioRecording());\n }\n\n async stopAndUnloadAsync(): Promise {\n if (!this._canRecord) {\n if (this._isDoneRecording) {\n throw new Error('Cannot unload a Recording that has already been unloaded.');\n } else {\n throw new Error('Cannot unload a Recording that has not been prepared.');\n }\n }\n // We perform a separate native API call so that the state of the Recording can be updated with\n // the final duration of the recording. (We cast stopStatus as Object to appease Flow)\n const finalStatus = await ExponentAV.stopAudioRecording();\n await ExponentAV.unloadAudioRecorder();\n return this._cleanupForUnloadedRecorder(finalStatus);\n }\n\n // Read API\n\n getURI(): string | null {\n return this._uri;\n }\n\n /** @deprecated Use `createNewLoadedSoundAsync()` instead */\n async createNewLoadedSound(\n initialStatus: AVPlaybackStatusToSet = {},\n onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null\n ): Promise<{ sound: Sound; status: AVPlaybackStatus }> {\n console.warn(\n `createNewLoadedSound is deprecated in favor of createNewLoadedSoundAsync, which has the same API aside from the method name`\n );\n return this.createNewLoadedSoundAsync(initialStatus, onPlaybackStatusUpdate);\n }\n\n async createNewLoadedSoundAsync(\n initialStatus: AVPlaybackStatusToSet = {},\n onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null\n ): Promise<{ sound: Sound; status: AVPlaybackStatus }> {\n if (this._uri == null || !this._isDoneRecording) {\n throw new Error('Cannot create sound when the Recording has not finished!');\n }\n return Sound.createAsync(\n // $FlowFixMe: Flow can't distinguish between this literal and Asset\n { uri: this._uri },\n initialStatus,\n onPlaybackStatusUpdate,\n false\n );\n }\n}\n"]} \ No newline at end of file diff --git a/build/Audio/Sound.d.ts b/build/Audio/Sound.d.ts index c27be785861f8..b534fd95f6f02 100644 --- a/build/Audio/Sound.d.ts +++ b/build/Audio/Sound.d.ts @@ -14,6 +14,7 @@ export declare class Sound implements Playback { _eventEmitter: EventEmitter; _coalesceStatusUpdatesInMillis: number; _onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null; + /** @deprecated Use `Sound.createAsync()` instead */ static create: (source: AVPlaybackSource, initialStatus?: AVPlaybackStatusToSet, onPlaybackStatusUpdate?: ((status: AVPlaybackStatus) => void) | null, downloadFirst?: boolean) => Promise<{ sound: Sound; status: AVPlaybackStatus; diff --git a/build/Audio/Sound.js b/build/Audio/Sound.js index 911410efe0f5e..f8cb198041d0b 100644 --- a/build/Audio/Sound.js +++ b/build/Audio/Sound.js @@ -141,6 +141,7 @@ export class Sound { })); } } +/** @deprecated Use `Sound.createAsync()` instead */ Sound.create = async (source, initialStatus = {}, onPlaybackStatusUpdate = null, downloadFirst = true) => { console.warn(`Sound.create is deprecated in favor of Sound.createAsync with the same API except for the new method name`); return Sound.createAsync(source, initialStatus, onPlaybackStatusUpdate, downloadFirst); diff --git a/build/Audio/Sound.js.map b/build/Audio/Sound.js.map index 2923966b0b3b0..baba2929bea8c 100644 --- a/build/Audio/Sound.js.map +++ b/build/Audio/Sound.js.map @@ -1 +1 @@ -{"version":3,"file":"Sound.js","sourceRoot":"","sources":["../../src/Audio/Sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAEL,aAAa,EAIb,0BAA0B,EAC1B,+CAA+C,EAC/C,iBAAiB,GAClB,MAAM,OAAO,CAAC;AAEf,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG7D,MAAM,OAAO,KAAK;IAAlB;QACE,YAAO,GAAY,KAAK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C,CAAC,CAAC;SACjE;QAED,OAAO,IAAI,CAAC,qCAAqC,CAAC,GAAG,EAAE,CACrD,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE;YAChC,GAAG,MAAM;YACT,cAAc,EAAE,CAAC;YACjB,UAAU,EAAE,IAAI;SACjB,CAAC,CACH,CAAC;IACJ,CAAC;;AA3MM,YAAM,GAAG,KAAK,EACnB,MAAwB,EACxB,gBAAuC,EAAE,EACzC,yBAAsE,IAAI,EAC1E,gBAAyB,IAAI,EACwB,EAAE;IACvD,OAAO,CAAC,IAAI,CACV,2GAA2G,CAC5G,CAAC;IACF,OAAO,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,sBAAsB,EAAE,aAAa,CAAC,CAAC;AACzF,CAAC,CAAC;AAEK,iBAAW,GAAG,KAAK,EACxB,MAAwB,EACxB,gBAAuC,EAAE,EACzC,yBAAsE,IAAI,EAC1E,gBAAyB,IAAI,EACwB,EAAE;IACvD,MAAM,KAAK,GAAU,IAAI,KAAK,EAAE,CAAC;IACjC,KAAK,CAAC,yBAAyB,CAAC,sBAAsB,CAAC,CAAC;IACxD,MAAM,MAAM,GAAqB,MAAM,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;IAC7F,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC,CAAC;AAgNJ,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { EventEmitter } from '@unimodules/core';\n\nimport {\n Playback,\n PlaybackMixin,\n AVPlaybackSource,\n AVPlaybackStatus,\n AVPlaybackStatusToSet,\n assertStatusValuesInBounds,\n getNativeSourceAndFullInitialStatusForLoadAsync,\n getUnloadedStatus,\n} from '../AV';\nimport { PitchCorrectionQuality } from '../Audio';\nimport ExponentAV from '../ExponentAV';\nimport { throwIfAudioIsDisabled } from './AudioAvailability';\n\ntype AudioInstance = number | HTMLMediaElement | null;\nexport class Sound implements Playback {\n _loaded: boolean = false;\n _loading: boolean = false;\n _key: AudioInstance = null;\n _lastStatusUpdate: string | null = null;\n _lastStatusUpdateTime: Date | null = null;\n _subscriptions: { remove: () => void }[] = [];\n _eventEmitter: EventEmitter = new EventEmitter(ExponentAV);\n _coalesceStatusUpdatesInMillis: number = 100;\n _onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null;\n\n static create = async (\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null,\n downloadFirst: boolean = true\n ): Promise<{ sound: Sound; status: AVPlaybackStatus }> => {\n console.warn(\n `Sound.create is deprecated in favor of Sound.createAsync with the same API except for the new method name`\n );\n return Sound.createAsync(source, initialStatus, onPlaybackStatusUpdate, downloadFirst);\n };\n\n static createAsync = async (\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null,\n downloadFirst: boolean = true\n ): Promise<{ sound: Sound; status: AVPlaybackStatus }> => {\n const sound: Sound = new Sound();\n sound.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);\n const status: AVPlaybackStatus = await sound.loadAsync(source, initialStatus, downloadFirst);\n return { sound, status };\n };\n\n // Internal methods\n\n _callOnPlaybackStatusUpdateForNewStatus(status: AVPlaybackStatus) {\n const shouldDismissBasedOnCoalescing =\n this._lastStatusUpdateTime &&\n JSON.stringify(status) === this._lastStatusUpdate &&\n Date.now() - this._lastStatusUpdateTime.getTime() < this._coalesceStatusUpdatesInMillis;\n\n if (this._onPlaybackStatusUpdate != null && !shouldDismissBasedOnCoalescing) {\n this._onPlaybackStatusUpdate(status);\n this._lastStatusUpdateTime = new Date();\n this._lastStatusUpdate = JSON.stringify(status);\n }\n }\n\n async _performOperationAndHandleStatusAsync(\n operation: () => Promise\n ): Promise {\n throwIfAudioIsDisabled();\n if (this._loaded) {\n const status = await operation();\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n return status;\n } else {\n throw new Error('Cannot complete operation because sound is not loaded.');\n }\n }\n\n _internalStatusUpdateCallback = ({\n key,\n status,\n }: {\n key: AudioInstance;\n status: AVPlaybackStatus;\n }) => {\n if (this._key === key) {\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n }\n };\n\n _internalErrorCallback = ({ key, error }: { key: AudioInstance; error: string }) => {\n if (this._key === key) {\n this._errorCallback(error);\n }\n };\n\n // TODO: We can optimize by only using time observer on native if (this._onPlaybackStatusUpdate).\n _subscribeToNativeEvents() {\n if (this._loaded) {\n this._subscriptions.push(\n this._eventEmitter.addListener(\n 'didUpdatePlaybackStatus',\n this._internalStatusUpdateCallback\n )\n );\n\n this._subscriptions.push(\n this._eventEmitter.addListener('ExponentAV.onError', this._internalErrorCallback)\n );\n }\n }\n\n _clearSubscriptions() {\n this._subscriptions.forEach(e => e.remove());\n this._subscriptions = [];\n }\n\n _errorCallback = (error: string) => {\n this._clearSubscriptions();\n this._loaded = false;\n this._key = null;\n this._callOnPlaybackStatusUpdateForNewStatus(getUnloadedStatus(error));\n };\n\n // ### Unified playback API ### (consistent with Video.js)\n // All calls automatically call onPlaybackStatusUpdate as a side effect.\n\n // Get status API\n\n getStatusAsync = async (): Promise => {\n if (this._loaded) {\n return this._performOperationAndHandleStatusAsync(() =>\n ExponentAV.getStatusForSound(this._key)\n );\n }\n const status: AVPlaybackStatus = getUnloadedStatus();\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n return status;\n };\n\n setOnPlaybackStatusUpdate(onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null) {\n this._onPlaybackStatusUpdate = onPlaybackStatusUpdate;\n this.getStatusAsync();\n }\n\n // Loading / unloading API\n\n async loadAsync(\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n downloadFirst: boolean = true\n ): Promise {\n throwIfAudioIsDisabled();\n if (this._loading) {\n throw new Error('The Sound is already loading.');\n }\n if (!this._loaded) {\n this._loading = true;\n\n const {\n nativeSource,\n fullInitialStatus,\n } = await getNativeSourceAndFullInitialStatusForLoadAsync(\n source,\n initialStatus,\n downloadFirst\n );\n\n // This is a workaround, since using load with resolve / reject seems to not work.\n return new Promise((resolve, reject) => {\n const loadSuccess = (result: [AudioInstance, AVPlaybackStatus]) => {\n const [key, status] = result;\n this._key = key;\n this._loaded = true;\n this._loading = false;\n this._subscribeToNativeEvents();\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n resolve(status);\n };\n\n const loadError = (error: Error) => {\n this._loading = false;\n reject(error);\n };\n\n ExponentAV.loadForSound(nativeSource, fullInitialStatus)\n .then(loadSuccess)\n .catch(loadError);\n });\n } else {\n throw new Error('The Sound is already loaded.');\n }\n }\n\n async unloadAsync(): Promise {\n if (this._loaded) {\n this._loaded = false;\n const key = this._key;\n this._key = null;\n const status = await ExponentAV.unloadForSound(key);\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n this._clearSubscriptions();\n return status;\n } else {\n return this.getStatusAsync(); // Automatically calls onPlaybackStatusUpdate.\n }\n }\n\n // Set status API (only available while isLoaded = true)\n\n async setStatusAsync(status: AVPlaybackStatusToSet): Promise {\n assertStatusValuesInBounds(status);\n return this._performOperationAndHandleStatusAsync(() =>\n ExponentAV.setStatusForSound(this._key, status)\n );\n }\n\n async replayAsync(status: AVPlaybackStatusToSet = {}): Promise {\n if (status.positionMillis && status.positionMillis !== 0) {\n throw new Error('Requested position after replay has to be 0.');\n }\n\n return this._performOperationAndHandleStatusAsync(() =>\n ExponentAV.replaySound(this._key, {\n ...status,\n positionMillis: 0,\n shouldPlay: true,\n })\n );\n }\n\n // Methods of the Playback interface that are set via PlaybackMixin\n playAsync!: () => Promise;\n playFromPositionAsync!: (\n positionMillis: number,\n tolerances?: { toleranceMillisBefore?: number; toleranceMillisAfter?: number }\n ) => Promise;\n pauseAsync!: () => Promise;\n stopAsync!: () => Promise;\n setPositionAsync!: (\n positionMillis: number,\n tolerances?: { toleranceMillisBefore?: number; toleranceMillisAfter?: number }\n ) => Promise;\n setRateAsync!: (\n rate: number,\n shouldCorrectPitch: boolean,\n pitchCorrectionQuality?: PitchCorrectionQuality\n ) => Promise;\n setVolumeAsync!: (volume: number) => Promise;\n setIsMutedAsync!: (isMuted: boolean) => Promise;\n setIsLoopingAsync!: (isLooping: boolean) => Promise;\n setProgressUpdateIntervalAsync!: (\n progressUpdateIntervalMillis: number\n ) => Promise;\n}\n\nObject.assign(Sound.prototype, PlaybackMixin);\n"]} \ No newline at end of file +{"version":3,"file":"Sound.js","sourceRoot":"","sources":["../../src/Audio/Sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAEL,aAAa,EAIb,0BAA0B,EAC1B,+CAA+C,EAC/C,iBAAiB,GAClB,MAAM,OAAO,CAAC;AAEf,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG7D,MAAM,OAAO,KAAK;IAAlB;QACE,YAAO,GAAY,KAAK,CAAC;QACzB,aAAQ,GAAY,KAAK,CAAC;QAC1B,SAAI,GAAkB,IAAI,CAAC;QAC3B,sBAAiB,GAAkB,IAAI,CAAC;QACxC,0BAAqB,GAAgB,IAAI,CAAC;QAC1C,mBAAc,GAA6B,EAAE,CAAC;QAC9C,kBAAa,GAAiB,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;QAC3D,mCAA8B,GAAW,GAAG,CAAC;QAC7C,4BAAuB,GAAgD,IAAI,CAAC;QAuD5E,kCAA6B,GAAG,CAAC,EAC/B,GAAG,EACH,MAAM,GAIP,EAAE,EAAE;YACH,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,EAAE;gBACrB,IAAI,CAAC,uCAAuC,CAAC,MAAM,CAAC,CAAC;aACtD;QACH,CAAC,CAAC;QAEF,2BAAsB,GAAG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C;AAEK,iBAAW,GAAG,KAAK,EACxB,MAAwB,EACxB,gBAAuC,EAAE,EACzC,yBAAsE,IAAI,EAC1E,gBAAyB,IAAI,EACwB,EAAE;IACvD,MAAM,KAAK,GAAU,IAAI,KAAK,EAAE,CAAC;IACjC,KAAK,CAAC,yBAAyB,CAAC,sBAAsB,CAAC,CAAC;IACxD,MAAM,MAAM,GAAqB,MAAM,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;IAC7F,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC,CAAC;AAgNJ,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { EventEmitter } from '@unimodules/core';\n\nimport {\n Playback,\n PlaybackMixin,\n AVPlaybackSource,\n AVPlaybackStatus,\n AVPlaybackStatusToSet,\n assertStatusValuesInBounds,\n getNativeSourceAndFullInitialStatusForLoadAsync,\n getUnloadedStatus,\n} from '../AV';\nimport { PitchCorrectionQuality } from '../Audio';\nimport ExponentAV from '../ExponentAV';\nimport { throwIfAudioIsDisabled } from './AudioAvailability';\n\ntype AudioInstance = number | HTMLMediaElement | null;\nexport class Sound implements Playback {\n _loaded: boolean = false;\n _loading: boolean = false;\n _key: AudioInstance = null;\n _lastStatusUpdate: string | null = null;\n _lastStatusUpdateTime: Date | null = null;\n _subscriptions: { remove: () => void }[] = [];\n _eventEmitter: EventEmitter = new EventEmitter(ExponentAV);\n _coalesceStatusUpdatesInMillis: number = 100;\n _onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null;\n\n /** @deprecated Use `Sound.createAsync()` instead */\n static create = async (\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null,\n downloadFirst: boolean = true\n ): Promise<{ sound: Sound; status: AVPlaybackStatus }> => {\n console.warn(\n `Sound.create is deprecated in favor of Sound.createAsync with the same API except for the new method name`\n );\n return Sound.createAsync(source, initialStatus, onPlaybackStatusUpdate, downloadFirst);\n };\n\n static createAsync = async (\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null,\n downloadFirst: boolean = true\n ): Promise<{ sound: Sound; status: AVPlaybackStatus }> => {\n const sound: Sound = new Sound();\n sound.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);\n const status: AVPlaybackStatus = await sound.loadAsync(source, initialStatus, downloadFirst);\n return { sound, status };\n };\n\n // Internal methods\n\n _callOnPlaybackStatusUpdateForNewStatus(status: AVPlaybackStatus) {\n const shouldDismissBasedOnCoalescing =\n this._lastStatusUpdateTime &&\n JSON.stringify(status) === this._lastStatusUpdate &&\n Date.now() - this._lastStatusUpdateTime.getTime() < this._coalesceStatusUpdatesInMillis;\n\n if (this._onPlaybackStatusUpdate != null && !shouldDismissBasedOnCoalescing) {\n this._onPlaybackStatusUpdate(status);\n this._lastStatusUpdateTime = new Date();\n this._lastStatusUpdate = JSON.stringify(status);\n }\n }\n\n async _performOperationAndHandleStatusAsync(\n operation: () => Promise\n ): Promise {\n throwIfAudioIsDisabled();\n if (this._loaded) {\n const status = await operation();\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n return status;\n } else {\n throw new Error('Cannot complete operation because sound is not loaded.');\n }\n }\n\n _internalStatusUpdateCallback = ({\n key,\n status,\n }: {\n key: AudioInstance;\n status: AVPlaybackStatus;\n }) => {\n if (this._key === key) {\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n }\n };\n\n _internalErrorCallback = ({ key, error }: { key: AudioInstance; error: string }) => {\n if (this._key === key) {\n this._errorCallback(error);\n }\n };\n\n // TODO: We can optimize by only using time observer on native if (this._onPlaybackStatusUpdate).\n _subscribeToNativeEvents() {\n if (this._loaded) {\n this._subscriptions.push(\n this._eventEmitter.addListener(\n 'didUpdatePlaybackStatus',\n this._internalStatusUpdateCallback\n )\n );\n\n this._subscriptions.push(\n this._eventEmitter.addListener('ExponentAV.onError', this._internalErrorCallback)\n );\n }\n }\n\n _clearSubscriptions() {\n this._subscriptions.forEach(e => e.remove());\n this._subscriptions = [];\n }\n\n _errorCallback = (error: string) => {\n this._clearSubscriptions();\n this._loaded = false;\n this._key = null;\n this._callOnPlaybackStatusUpdateForNewStatus(getUnloadedStatus(error));\n };\n\n // ### Unified playback API ### (consistent with Video.js)\n // All calls automatically call onPlaybackStatusUpdate as a side effect.\n\n // Get status API\n\n getStatusAsync = async (): Promise => {\n if (this._loaded) {\n return this._performOperationAndHandleStatusAsync(() =>\n ExponentAV.getStatusForSound(this._key)\n );\n }\n const status: AVPlaybackStatus = getUnloadedStatus();\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n return status;\n };\n\n setOnPlaybackStatusUpdate(onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null) {\n this._onPlaybackStatusUpdate = onPlaybackStatusUpdate;\n this.getStatusAsync();\n }\n\n // Loading / unloading API\n\n async loadAsync(\n source: AVPlaybackSource,\n initialStatus: AVPlaybackStatusToSet = {},\n downloadFirst: boolean = true\n ): Promise {\n throwIfAudioIsDisabled();\n if (this._loading) {\n throw new Error('The Sound is already loading.');\n }\n if (!this._loaded) {\n this._loading = true;\n\n const {\n nativeSource,\n fullInitialStatus,\n } = await getNativeSourceAndFullInitialStatusForLoadAsync(\n source,\n initialStatus,\n downloadFirst\n );\n\n // This is a workaround, since using load with resolve / reject seems to not work.\n return new Promise((resolve, reject) => {\n const loadSuccess = (result: [AudioInstance, AVPlaybackStatus]) => {\n const [key, status] = result;\n this._key = key;\n this._loaded = true;\n this._loading = false;\n this._subscribeToNativeEvents();\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n resolve(status);\n };\n\n const loadError = (error: Error) => {\n this._loading = false;\n reject(error);\n };\n\n ExponentAV.loadForSound(nativeSource, fullInitialStatus)\n .then(loadSuccess)\n .catch(loadError);\n });\n } else {\n throw new Error('The Sound is already loaded.');\n }\n }\n\n async unloadAsync(): Promise {\n if (this._loaded) {\n this._loaded = false;\n const key = this._key;\n this._key = null;\n const status = await ExponentAV.unloadForSound(key);\n this._callOnPlaybackStatusUpdateForNewStatus(status);\n this._clearSubscriptions();\n return status;\n } else {\n return this.getStatusAsync(); // Automatically calls onPlaybackStatusUpdate.\n }\n }\n\n // Set status API (only available while isLoaded = true)\n\n async setStatusAsync(status: AVPlaybackStatusToSet): Promise {\n assertStatusValuesInBounds(status);\n return this._performOperationAndHandleStatusAsync(() =>\n ExponentAV.setStatusForSound(this._key, status)\n );\n }\n\n async replayAsync(status: AVPlaybackStatusToSet = {}): Promise {\n if (status.positionMillis && status.positionMillis !== 0) {\n throw new Error('Requested position after replay has to be 0.');\n }\n\n return this._performOperationAndHandleStatusAsync(() =>\n ExponentAV.replaySound(this._key, {\n ...status,\n positionMillis: 0,\n shouldPlay: true,\n })\n );\n }\n\n // Methods of the Playback interface that are set via PlaybackMixin\n playAsync!: () => Promise;\n playFromPositionAsync!: (\n positionMillis: number,\n tolerances?: { toleranceMillisBefore?: number; toleranceMillisAfter?: number }\n ) => Promise;\n pauseAsync!: () => Promise;\n stopAsync!: () => Promise;\n setPositionAsync!: (\n positionMillis: number,\n tolerances?: { toleranceMillisBefore?: number; toleranceMillisAfter?: number }\n ) => Promise;\n setRateAsync!: (\n rate: number,\n shouldCorrectPitch: boolean,\n pitchCorrectionQuality?: PitchCorrectionQuality\n ) => Promise;\n setVolumeAsync!: (volume: number) => Promise;\n setIsMutedAsync!: (isMuted: boolean) => Promise;\n setIsLoopingAsync!: (isLooping: boolean) => Promise;\n setProgressUpdateIntervalAsync!: (\n progressUpdateIntervalMillis: number\n ) => Promise;\n}\n\nObject.assign(Sound.prototype, PlaybackMixin);\n"]} \ No newline at end of file diff --git a/src/Audio/Recording.ts b/src/Audio/Recording.ts index d5ac56d2c6c46..77dd01df41c53 100644 --- a/src/Audio/Recording.ts +++ b/src/Audio/Recording.ts @@ -365,6 +365,7 @@ export class Recording { return this._uri; } + /** @deprecated Use `createNewLoadedSoundAsync()` instead */ async createNewLoadedSound( initialStatus: AVPlaybackStatusToSet = {}, onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null diff --git a/src/Audio/Sound.ts b/src/Audio/Sound.ts index ed8cb4a40f33c..366c64f32afad 100644 --- a/src/Audio/Sound.ts +++ b/src/Audio/Sound.ts @@ -26,6 +26,7 @@ export class Sound implements Playback { _coalesceStatusUpdatesInMillis: number = 100; _onPlaybackStatusUpdate: ((status: AVPlaybackStatus) => void) | null = null; + /** @deprecated Use `Sound.createAsync()` instead */ static create = async ( source: AVPlaybackSource, initialStatus: AVPlaybackStatusToSet = {},