capacitor-voice-recorder-wav-stereo 7.0.10 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorVoiceRecorderWavStereo.podspec +17 -17
- package/README.md +213 -213
- package/android/build.gradle +80 -58
- package/android/src/main/AndroidManifest.xml +2 -2
- package/android/src/main/java/com/tchvu3/capacitorvoicerecorder/CurrentRecordingStatus.java +7 -7
- package/android/src/main/java/com/tchvu3/capacitorvoicerecorder/CustomMediaRecorder.java +186 -186
- package/android/src/main/java/com/tchvu3/capacitorvoicerecorder/Messages.java +15 -15
- package/android/src/main/java/com/tchvu3/capacitorvoicerecorder/NotSupportedOsVersion.java +4 -4
- package/android/src/main/java/com/tchvu3/capacitorvoicerecorder/RecordData.java +51 -51
- package/android/src/main/java/com/tchvu3/capacitorvoicerecorder/ResponseGenerator.java +37 -37
- package/android/src/main/java/com/tchvu3/capacitorvoicerecorder/VoiceRecorder.java +217 -217
- package/dist/docs.json +1 -1
- package/dist/esm/VoiceRecorderImpl.js.map +1 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/predefined-web-responses.js.map +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CurrentRecordingStatus.swift +9 -9
- package/ios/Plugin/CustomMediaRecorder.swift +82 -82
- package/ios/Plugin/Info.plist +24 -24
- package/ios/Plugin/Messages.swift +15 -15
- package/ios/Plugin/RecordData.swift +17 -17
- package/ios/Plugin/ResponseGenerator.swift +28 -28
- package/ios/Plugin/VoiceRecorder.swift +179 -179
- package/ios/Plugin/VoiceRecorderPlugin.h +10 -10
- package/ios/Plugin/VoiceRecorderPlugin.m +16 -16
- package/package.json +92 -92
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/predefined-web-responses.js","esm/VoiceRecorderImpl.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst VoiceRecorder = registerPlugin('VoiceRecorder', {\n web: () => import('./web').then(m => new m.VoiceRecorderWeb()),\n});\nexport * from './definitions';\nexport { VoiceRecorder };\n//# sourceMappingURL=index.js.map","export const successResponse = () => ({ value: true });\nexport const failureResponse = () => ({ value: false });\nexport const missingPermissionError = () => new Error('MISSING_PERMISSION');\nexport const alreadyRecordingError = () => new Error('ALREADY_RECORDING');\nexport const microphoneBeingUsedError = () => new Error('MICROPHONE_BEING_USED');\nexport const deviceCannotVoiceRecordError = () => new Error('DEVICE_CANNOT_VOICE_RECORD');\nexport const failedToRecordError = () => new Error('FAILED_TO_RECORD');\nexport const emptyRecordingError = () => new Error('EMPTY_RECORDING');\nexport const recordingHasNotStartedError = () => new Error('RECORDING_HAS_NOT_STARTED');\nexport const failedToFetchRecordingError = () => new Error('FAILED_TO_FETCH_RECORDING');\nexport const couldNotQueryPermissionStatusError = () => new Error('COULD_NOT_QUERY_PERMISSION_STATUS');\n//# sourceMappingURL=predefined-web-responses.js.map","import getBlobDuration from 'get-blob-duration';\nimport { alreadyRecordingError, couldNotQueryPermissionStatusError, deviceCannotVoiceRecordError, emptyRecordingError, failedToFetchRecordingError, failedToRecordError, failureResponse, missingPermissionError, recordingHasNotStartedError, successResponse, } from './predefined-web-responses';\n// these mime types will be checked one by one in order until one of them is found to be supported by the current browser\nconst possibleMimeTypes = ['audio/mp4', 'audio/webm;codecs=opus', 'audio/aac', 'audio/webm', 'audio/ogg;codecs=opus'];\nconst neverResolvingPromise = () => new Promise(() => undefined);\nexport class VoiceRecorderImpl {\n constructor() {\n this.mediaRecorder = null;\n this.chunks = [];\n this.pendingResult = neverResolvingPromise();\n }\n static async canDeviceVoiceRecord() {\n var _a;\n if (((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) == null || VoiceRecorderImpl.getSupportedMimeType() == null) {\n return failureResponse();\n }\n else {\n return successResponse();\n }\n }\n async startRecording() {\n if (this.mediaRecorder != null) {\n throw alreadyRecordingError();\n }\n const deviceCanRecord = await VoiceRecorderImpl.canDeviceVoiceRecord();\n if (!deviceCanRecord.value) {\n throw deviceCannotVoiceRecordError();\n }\n const havingPermission = await VoiceRecorderImpl.hasAudioRecordingPermission().catch(() => successResponse());\n if (!havingPermission.value) {\n throw missingPermissionError();\n }\n return navigator.mediaDevices.getUserMedia({ audio: true })\n .then(this.onSuccessfullyStartedRecording.bind(this))\n .catch(this.onFailedToStartRecording.bind(this));\n }\n async stopRecording() {\n if (this.mediaRecorder == null) {\n throw recordingHasNotStartedError();\n }\n try {\n this.mediaRecorder.stop();\n this.mediaRecorder.stream.getTracks().forEach(track => track.stop());\n return this.pendingResult;\n }\n catch (ignore) {\n throw failedToFetchRecordingError();\n }\n finally {\n this.prepareInstanceForNextOperation();\n }\n }\n static async hasAudioRecordingPermission() {\n return navigator.permissions.query({ name: 'microphone' })\n .then(result => ({ value: result.state === 'granted' }))\n .catch(() => {\n throw couldNotQueryPermissionStatusError();\n });\n }\n static async requestAudioRecordingPermission() {\n const havingPermission = await VoiceRecorderImpl.hasAudioRecordingPermission().catch(() => failureResponse());\n if (havingPermission.value) {\n return successResponse();\n }\n return navigator.mediaDevices.getUserMedia({ audio: true })\n .then(() => successResponse())\n .catch(() => failureResponse());\n }\n pauseRecording() {\n if (this.mediaRecorder == null) {\n throw recordingHasNotStartedError();\n }\n else if (this.mediaRecorder.state === 'recording') {\n this.mediaRecorder.pause();\n return Promise.resolve(successResponse());\n }\n else {\n return Promise.resolve(failureResponse());\n }\n }\n resumeRecording() {\n if (this.mediaRecorder == null) {\n throw recordingHasNotStartedError();\n }\n else if (this.mediaRecorder.state === 'paused') {\n this.mediaRecorder.resume();\n return Promise.resolve(successResponse());\n }\n else {\n return Promise.resolve(failureResponse());\n }\n }\n getCurrentStatus() {\n if (this.mediaRecorder == null) {\n return Promise.resolve({ status: 'NONE' });\n }\n else if (this.mediaRecorder.state === 'recording') {\n return Promise.resolve({ status: 'RECORDING' });\n }\n else if (this.mediaRecorder.state === 'paused') {\n return Promise.resolve({ status: 'PAUSED' });\n }\n else {\n return Promise.resolve({ status: 'NONE' });\n }\n }\n static getSupportedMimeType() {\n if ((MediaRecorder === null || MediaRecorder === void 0 ? void 0 : MediaRecorder.isTypeSupported) == null)\n return null;\n const foundSupportedType = possibleMimeTypes.find(type => MediaRecorder.isTypeSupported(type));\n return foundSupportedType !== null && foundSupportedType !== void 0 ? foundSupportedType : null;\n }\n onSuccessfullyStartedRecording(stream) {\n this.pendingResult = new Promise((resolve, reject) => {\n this.mediaRecorder = new MediaRecorder(stream);\n this.mediaRecorder.onerror = () => {\n this.prepareInstanceForNextOperation();\n reject(failedToRecordError());\n };\n this.mediaRecorder.onstop = async () => {\n const mimeType = VoiceRecorderImpl.getSupportedMimeType();\n if (mimeType == null) {\n this.prepareInstanceForNextOperation();\n reject(failedToFetchRecordingError());\n return;\n }\n const blobVoiceRecording = new Blob(this.chunks, { 'type': mimeType });\n if (blobVoiceRecording.size <= 0) {\n this.prepareInstanceForNextOperation();\n reject(emptyRecordingError());\n return;\n }\n const recordDataBase64 = await VoiceRecorderImpl.blobToBase64(blobVoiceRecording);\n const recordingDuration = await getBlobDuration(blobVoiceRecording);\n this.prepareInstanceForNextOperation();\n resolve({ value: { recordDataBase64, mimeType, msDuration: recordingDuration * 1000 } });\n };\n this.mediaRecorder.ondataavailable = (event) => this.chunks.push(event.data);\n this.mediaRecorder.start();\n });\n return successResponse();\n }\n onFailedToStartRecording() {\n this.prepareInstanceForNextOperation();\n throw failedToRecordError();\n }\n static blobToBase64(blob) {\n return new Promise(resolve => {\n const reader = new FileReader();\n reader.onloadend = () => {\n const recordingResult = String(reader.result);\n const splitResult = recordingResult.split('base64,');\n const toResolve = (splitResult.length > 1) ? splitResult[1] : recordingResult;\n resolve(toResolve.trim());\n };\n reader.readAsDataURL(blob);\n });\n }\n prepareInstanceForNextOperation() {\n if (this.mediaRecorder != null && this.mediaRecorder.state === 'recording') {\n try {\n this.mediaRecorder.stop();\n }\n catch (ignore) {\n }\n }\n this.pendingResult = neverResolvingPromise();\n this.mediaRecorder = null;\n this.chunks = [];\n }\n static async getConnectedDevices() {\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n return { devices };\n }\n catch (error) {\n // ブラウザがAPIをサポートしていない場合は空配列を返す\n return { devices: [] };\n }\n }\n}\n//# sourceMappingURL=VoiceRecorderImpl.js.map","import { WebPlugin } from '@capacitor/core';\nimport { VoiceRecorderImpl } from './VoiceRecorderImpl';\nexport class VoiceRecorderWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.voiceRecorderInstance = new VoiceRecorderImpl();\n }\n canDeviceVoiceRecord() {\n return VoiceRecorderImpl.canDeviceVoiceRecord();\n }\n hasAudioRecordingPermission() {\n return VoiceRecorderImpl.hasAudioRecordingPermission();\n }\n requestAudioRecordingPermission() {\n return VoiceRecorderImpl.requestAudioRecordingPermission();\n }\n startRecording() {\n return this.voiceRecorderInstance.startRecording();\n }\n stopRecording() {\n return this.voiceRecorderInstance.stopRecording();\n }\n pauseRecording() {\n return this.voiceRecorderInstance.pauseRecording();\n }\n resumeRecording() {\n return this.voiceRecorderInstance.resumeRecording();\n }\n getCurrentStatus() {\n return this.voiceRecorderInstance.getCurrentStatus();\n }\n getConnectedDevices() {\n return VoiceRecorderImpl.getConnectedDevices();\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;AACK,MAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;AACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAClE,CAAC;;ACHM,MAAM,eAAe,GAAG,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC/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AAC5D;AACA,IAAI,mBAAmB,GAAG;AAC1B,QAAQ,OAAO,iBAAiB,CAAC,mBAAmB,EAAE;AACtD;AACA;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/predefined-web-responses.js","esm/VoiceRecorderImpl.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst VoiceRecorder = registerPlugin('VoiceRecorder', {\n web: () => import('./web').then(m => new m.VoiceRecorderWeb()),\n});\nexport * from './definitions';\nexport { VoiceRecorder };\n//# sourceMappingURL=index.js.map","export const successResponse = () => ({ value: true });\nexport const failureResponse = () => ({ value: false });\nexport const missingPermissionError = () => new Error('MISSING_PERMISSION');\nexport const alreadyRecordingError = () => new Error('ALREADY_RECORDING');\nexport const microphoneBeingUsedError = () => new Error('MICROPHONE_BEING_USED');\nexport const deviceCannotVoiceRecordError = () => new Error('DEVICE_CANNOT_VOICE_RECORD');\nexport const failedToRecordError = () => new Error('FAILED_TO_RECORD');\nexport const emptyRecordingError = () => new Error('EMPTY_RECORDING');\nexport const recordingHasNotStartedError = () => new Error('RECORDING_HAS_NOT_STARTED');\nexport const failedToFetchRecordingError = () => new Error('FAILED_TO_FETCH_RECORDING');\nexport const couldNotQueryPermissionStatusError = () => new Error('COULD_NOT_QUERY_PERMISSION_STATUS');\n//# sourceMappingURL=predefined-web-responses.js.map","import getBlobDuration from 'get-blob-duration';\nimport { alreadyRecordingError, couldNotQueryPermissionStatusError, deviceCannotVoiceRecordError, emptyRecordingError, failedToFetchRecordingError, failedToRecordError, failureResponse, missingPermissionError, recordingHasNotStartedError, successResponse, } from './predefined-web-responses';\n// these mime types will be checked one by one in order until one of them is found to be supported by the current browser\nconst possibleMimeTypes = ['audio/mp4', 'audio/webm;codecs=opus', 'audio/aac', 'audio/webm', 'audio/ogg;codecs=opus'];\nconst neverResolvingPromise = () => new Promise(() => undefined);\nexport class VoiceRecorderImpl {\n constructor() {\n this.mediaRecorder = null;\n this.chunks = [];\n this.pendingResult = neverResolvingPromise();\n }\n static async canDeviceVoiceRecord() {\n var _a;\n if (((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) == null || VoiceRecorderImpl.getSupportedMimeType() == null) {\n return failureResponse();\n }\n else {\n return successResponse();\n }\n }\n async startRecording() {\n if (this.mediaRecorder != null) {\n throw alreadyRecordingError();\n }\n const deviceCanRecord = await VoiceRecorderImpl.canDeviceVoiceRecord();\n if (!deviceCanRecord.value) {\n throw deviceCannotVoiceRecordError();\n }\n const havingPermission = await VoiceRecorderImpl.hasAudioRecordingPermission().catch(() => successResponse());\n if (!havingPermission.value) {\n throw missingPermissionError();\n }\n return navigator.mediaDevices.getUserMedia({ audio: true })\n .then(this.onSuccessfullyStartedRecording.bind(this))\n .catch(this.onFailedToStartRecording.bind(this));\n }\n async stopRecording() {\n if (this.mediaRecorder == null) {\n throw recordingHasNotStartedError();\n }\n try {\n this.mediaRecorder.stop();\n this.mediaRecorder.stream.getTracks().forEach(track => track.stop());\n return this.pendingResult;\n }\n catch (ignore) {\n throw failedToFetchRecordingError();\n }\n finally {\n this.prepareInstanceForNextOperation();\n }\n }\n static async hasAudioRecordingPermission() {\n return navigator.permissions.query({ name: 'microphone' })\n .then(result => ({ value: result.state === 'granted' }))\n .catch(() => {\n throw couldNotQueryPermissionStatusError();\n });\n }\n static async requestAudioRecordingPermission() {\n const havingPermission = await VoiceRecorderImpl.hasAudioRecordingPermission().catch(() => failureResponse());\n if (havingPermission.value) {\n return successResponse();\n }\n return navigator.mediaDevices.getUserMedia({ audio: true })\n .then(() => successResponse())\n .catch(() => failureResponse());\n }\n pauseRecording() {\n if (this.mediaRecorder == null) {\n throw recordingHasNotStartedError();\n }\n else if (this.mediaRecorder.state === 'recording') {\n this.mediaRecorder.pause();\n return Promise.resolve(successResponse());\n }\n else {\n return Promise.resolve(failureResponse());\n }\n }\n resumeRecording() {\n if (this.mediaRecorder == null) {\n throw recordingHasNotStartedError();\n }\n else if (this.mediaRecorder.state === 'paused') {\n this.mediaRecorder.resume();\n return Promise.resolve(successResponse());\n }\n else {\n return Promise.resolve(failureResponse());\n }\n }\n getCurrentStatus() {\n if (this.mediaRecorder == null) {\n return Promise.resolve({ status: 'NONE' });\n }\n else if (this.mediaRecorder.state === 'recording') {\n return Promise.resolve({ status: 'RECORDING' });\n }\n else if (this.mediaRecorder.state === 'paused') {\n return Promise.resolve({ status: 'PAUSED' });\n }\n else {\n return Promise.resolve({ status: 'NONE' });\n }\n }\n static getSupportedMimeType() {\n if ((MediaRecorder === null || MediaRecorder === void 0 ? void 0 : MediaRecorder.isTypeSupported) == null)\n return null;\n const foundSupportedType = possibleMimeTypes.find(type => MediaRecorder.isTypeSupported(type));\n return foundSupportedType !== null && foundSupportedType !== void 0 ? foundSupportedType : null;\n }\n onSuccessfullyStartedRecording(stream) {\n this.pendingResult = new Promise((resolve, reject) => {\n this.mediaRecorder = new MediaRecorder(stream);\n this.mediaRecorder.onerror = () => {\n this.prepareInstanceForNextOperation();\n reject(failedToRecordError());\n };\n this.mediaRecorder.onstop = async () => {\n const mimeType = VoiceRecorderImpl.getSupportedMimeType();\n if (mimeType == null) {\n this.prepareInstanceForNextOperation();\n reject(failedToFetchRecordingError());\n return;\n }\n const blobVoiceRecording = new Blob(this.chunks, { 'type': mimeType });\n if (blobVoiceRecording.size <= 0) {\n this.prepareInstanceForNextOperation();\n reject(emptyRecordingError());\n return;\n }\n const recordDataBase64 = await VoiceRecorderImpl.blobToBase64(blobVoiceRecording);\n const recordingDuration = await getBlobDuration(blobVoiceRecording);\n this.prepareInstanceForNextOperation();\n resolve({ value: { recordDataBase64, mimeType, msDuration: recordingDuration * 1000 } });\n };\n this.mediaRecorder.ondataavailable = (event) => this.chunks.push(event.data);\n this.mediaRecorder.start();\n });\n return successResponse();\n }\n onFailedToStartRecording() {\n this.prepareInstanceForNextOperation();\n throw failedToRecordError();\n }\n static blobToBase64(blob) {\n return new Promise(resolve => {\n const reader = new FileReader();\n reader.onloadend = () => {\n const recordingResult = String(reader.result);\n const splitResult = recordingResult.split('base64,');\n const toResolve = (splitResult.length > 1) ? splitResult[1] : recordingResult;\n resolve(toResolve.trim());\n };\n reader.readAsDataURL(blob);\n });\n }\n prepareInstanceForNextOperation() {\n if (this.mediaRecorder != null && this.mediaRecorder.state === 'recording') {\n try {\n this.mediaRecorder.stop();\n }\n catch (ignore) {\n }\n }\n this.pendingResult = neverResolvingPromise();\n this.mediaRecorder = null;\n this.chunks = [];\n }\n static async getConnectedDevices() {\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n return { devices };\n }\n catch (error) {\n // ブラウザがAPIをサポートしていない場合は空配列を返す\n return { devices: [] };\n }\n }\n}\n//# sourceMappingURL=VoiceRecorderImpl.js.map","import { WebPlugin } from '@capacitor/core';\nimport { VoiceRecorderImpl } from './VoiceRecorderImpl';\nexport class VoiceRecorderWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.voiceRecorderInstance = new VoiceRecorderImpl();\n }\n canDeviceVoiceRecord() {\n return VoiceRecorderImpl.canDeviceVoiceRecord();\n }\n hasAudioRecordingPermission() {\n return VoiceRecorderImpl.hasAudioRecordingPermission();\n }\n requestAudioRecordingPermission() {\n return VoiceRecorderImpl.requestAudioRecordingPermission();\n }\n startRecording() {\n return this.voiceRecorderInstance.startRecording();\n }\n stopRecording() {\n return this.voiceRecorderInstance.stopRecording();\n }\n pauseRecording() {\n return this.voiceRecorderInstance.pauseRecording();\n }\n resumeRecording() {\n return this.voiceRecorderInstance.resumeRecording();\n }\n getCurrentStatus() {\n return this.voiceRecorderInstance.getCurrentStatus();\n }\n getConnectedDevices() {\n return VoiceRecorderImpl.getConnectedDevices();\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;AACK,MAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;AACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,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AACJ,IAAI,+BAA+B,GAAG;AACtC,QAAQ,OAAO,iBAAiB,CAAC,+BAA+B,EAAE;AAClE,IAAI;AACJ,IAAI,cAAc,GAAG;AACrB,QAAQ,OAAO,IAAI,CAAC,qBAAqB,CAAC,cAAc,EAAE;AAC1D,IAAI;AACJ,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,IAAI,CAAC,qBAAqB,CAAC,aAAa,EAAE;AACzD,IAAI;AACJ,IAAI,cAAc,GAAG;AACrB,QAAQ,OAAO,IAAI,CAAC,qBAAqB,CAAC,cAAc,EAAE;AAC1D,IAAI;AACJ,IAAI,eAAe,GAAG;AACtB,QAAQ,OAAO,IAAI,CAAC,qBAAqB,CAAC,eAAe,EAAE;AAC3D,IAAI;AACJ,IAAI,gBAAgB,GAAG;AACvB,QAAQ,OAAO,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,EAAE;AAC5D,IAAI;AACJ,IAAI,mBAAmB,GAAG;AAC1B,QAAQ,OAAO,iBAAiB,CAAC,mBAAmB,EAAE;AACtD,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/predefined-web-responses.js","esm/VoiceRecorderImpl.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst VoiceRecorder = registerPlugin('VoiceRecorder', {\n web: () => import('./web').then(m => new m.VoiceRecorderWeb()),\n});\nexport * from './definitions';\nexport { VoiceRecorder };\n//# sourceMappingURL=index.js.map","export const successResponse = () => ({ value: true });\nexport const failureResponse = () => ({ value: false });\nexport const missingPermissionError = () => new Error('MISSING_PERMISSION');\nexport const alreadyRecordingError = () => new Error('ALREADY_RECORDING');\nexport const microphoneBeingUsedError = () => new Error('MICROPHONE_BEING_USED');\nexport const deviceCannotVoiceRecordError = () => new Error('DEVICE_CANNOT_VOICE_RECORD');\nexport const failedToRecordError = () => new Error('FAILED_TO_RECORD');\nexport const emptyRecordingError = () => new Error('EMPTY_RECORDING');\nexport const recordingHasNotStartedError = () => new Error('RECORDING_HAS_NOT_STARTED');\nexport const failedToFetchRecordingError = () => new Error('FAILED_TO_FETCH_RECORDING');\nexport const couldNotQueryPermissionStatusError = () => new Error('COULD_NOT_QUERY_PERMISSION_STATUS');\n//# sourceMappingURL=predefined-web-responses.js.map","import getBlobDuration from 'get-blob-duration';\nimport { alreadyRecordingError, couldNotQueryPermissionStatusError, deviceCannotVoiceRecordError, emptyRecordingError, failedToFetchRecordingError, failedToRecordError, failureResponse, missingPermissionError, recordingHasNotStartedError, successResponse, } from './predefined-web-responses';\n// these mime types will be checked one by one in order until one of them is found to be supported by the current browser\nconst possibleMimeTypes = ['audio/mp4', 'audio/webm;codecs=opus', 'audio/aac', 'audio/webm', 'audio/ogg;codecs=opus'];\nconst neverResolvingPromise = () => new Promise(() => undefined);\nexport class VoiceRecorderImpl {\n constructor() {\n this.mediaRecorder = null;\n this.chunks = [];\n this.pendingResult = neverResolvingPromise();\n }\n static async canDeviceVoiceRecord() {\n var _a;\n if (((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) == null || VoiceRecorderImpl.getSupportedMimeType() == null) {\n return failureResponse();\n }\n else {\n return successResponse();\n }\n }\n async startRecording() {\n if (this.mediaRecorder != null) {\n throw alreadyRecordingError();\n }\n const deviceCanRecord = await VoiceRecorderImpl.canDeviceVoiceRecord();\n if (!deviceCanRecord.value) {\n throw deviceCannotVoiceRecordError();\n }\n const havingPermission = await VoiceRecorderImpl.hasAudioRecordingPermission().catch(() => successResponse());\n if (!havingPermission.value) {\n throw missingPermissionError();\n }\n return navigator.mediaDevices.getUserMedia({ audio: true })\n .then(this.onSuccessfullyStartedRecording.bind(this))\n .catch(this.onFailedToStartRecording.bind(this));\n }\n async stopRecording() {\n if (this.mediaRecorder == null) {\n throw recordingHasNotStartedError();\n }\n try {\n this.mediaRecorder.stop();\n this.mediaRecorder.stream.getTracks().forEach(track => track.stop());\n return this.pendingResult;\n }\n catch (ignore) {\n throw failedToFetchRecordingError();\n }\n finally {\n this.prepareInstanceForNextOperation();\n }\n }\n static async hasAudioRecordingPermission() {\n return navigator.permissions.query({ name: 'microphone' })\n .then(result => ({ value: result.state === 'granted' }))\n .catch(() => {\n throw couldNotQueryPermissionStatusError();\n });\n }\n static async requestAudioRecordingPermission() {\n const havingPermission = await VoiceRecorderImpl.hasAudioRecordingPermission().catch(() => failureResponse());\n if (havingPermission.value) {\n return successResponse();\n }\n return navigator.mediaDevices.getUserMedia({ audio: true })\n .then(() => successResponse())\n .catch(() => failureResponse());\n }\n pauseRecording() {\n if (this.mediaRecorder == null) {\n throw recordingHasNotStartedError();\n }\n else if (this.mediaRecorder.state === 'recording') {\n this.mediaRecorder.pause();\n return Promise.resolve(successResponse());\n }\n else {\n return Promise.resolve(failureResponse());\n }\n }\n resumeRecording() {\n if (this.mediaRecorder == null) {\n throw recordingHasNotStartedError();\n }\n else if (this.mediaRecorder.state === 'paused') {\n this.mediaRecorder.resume();\n return Promise.resolve(successResponse());\n }\n else {\n return Promise.resolve(failureResponse());\n }\n }\n getCurrentStatus() {\n if (this.mediaRecorder == null) {\n return Promise.resolve({ status: 'NONE' });\n }\n else if (this.mediaRecorder.state === 'recording') {\n return Promise.resolve({ status: 'RECORDING' });\n }\n else if (this.mediaRecorder.state === 'paused') {\n return Promise.resolve({ status: 'PAUSED' });\n }\n else {\n return Promise.resolve({ status: 'NONE' });\n }\n }\n static getSupportedMimeType() {\n if ((MediaRecorder === null || MediaRecorder === void 0 ? void 0 : MediaRecorder.isTypeSupported) == null)\n return null;\n const foundSupportedType = possibleMimeTypes.find(type => MediaRecorder.isTypeSupported(type));\n return foundSupportedType !== null && foundSupportedType !== void 0 ? foundSupportedType : null;\n }\n onSuccessfullyStartedRecording(stream) {\n this.pendingResult = new Promise((resolve, reject) => {\n this.mediaRecorder = new MediaRecorder(stream);\n this.mediaRecorder.onerror = () => {\n this.prepareInstanceForNextOperation();\n reject(failedToRecordError());\n };\n this.mediaRecorder.onstop = async () => {\n const mimeType = VoiceRecorderImpl.getSupportedMimeType();\n if (mimeType == null) {\n this.prepareInstanceForNextOperation();\n reject(failedToFetchRecordingError());\n return;\n }\n const blobVoiceRecording = new Blob(this.chunks, { 'type': mimeType });\n if (blobVoiceRecording.size <= 0) {\n this.prepareInstanceForNextOperation();\n reject(emptyRecordingError());\n return;\n }\n const recordDataBase64 = await VoiceRecorderImpl.blobToBase64(blobVoiceRecording);\n const recordingDuration = await getBlobDuration(blobVoiceRecording);\n this.prepareInstanceForNextOperation();\n resolve({ value: { recordDataBase64, mimeType, msDuration: recordingDuration * 1000 } });\n };\n this.mediaRecorder.ondataavailable = (event) => this.chunks.push(event.data);\n this.mediaRecorder.start();\n });\n return successResponse();\n }\n onFailedToStartRecording() {\n this.prepareInstanceForNextOperation();\n throw failedToRecordError();\n }\n static blobToBase64(blob) {\n return new Promise(resolve => {\n const reader = new FileReader();\n reader.onloadend = () => {\n const recordingResult = String(reader.result);\n const splitResult = recordingResult.split('base64,');\n const toResolve = (splitResult.length > 1) ? splitResult[1] : recordingResult;\n resolve(toResolve.trim());\n };\n reader.readAsDataURL(blob);\n });\n }\n prepareInstanceForNextOperation() {\n if (this.mediaRecorder != null && this.mediaRecorder.state === 'recording') {\n try {\n this.mediaRecorder.stop();\n }\n catch (ignore) {\n }\n }\n this.pendingResult = neverResolvingPromise();\n this.mediaRecorder = null;\n this.chunks = [];\n }\n static async getConnectedDevices() {\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n return { devices };\n }\n catch (error) {\n // ブラウザがAPIをサポートしていない場合は空配列を返す\n return { devices: [] };\n }\n }\n}\n//# sourceMappingURL=VoiceRecorderImpl.js.map","import { WebPlugin } from '@capacitor/core';\nimport { VoiceRecorderImpl } from './VoiceRecorderImpl';\nexport class VoiceRecorderWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.voiceRecorderInstance = new VoiceRecorderImpl();\n }\n canDeviceVoiceRecord() {\n return VoiceRecorderImpl.canDeviceVoiceRecord();\n }\n hasAudioRecordingPermission() {\n return VoiceRecorderImpl.hasAudioRecordingPermission();\n }\n requestAudioRecordingPermission() {\n return VoiceRecorderImpl.requestAudioRecordingPermission();\n }\n startRecording() {\n return this.voiceRecorderInstance.startRecording();\n }\n stopRecording() {\n return this.voiceRecorderInstance.stopRecording();\n }\n pauseRecording() {\n return this.voiceRecorderInstance.pauseRecording();\n }\n resumeRecording() {\n return this.voiceRecorderInstance.resumeRecording();\n }\n getCurrentStatus() {\n return this.voiceRecorderInstance.getCurrentStatus();\n }\n getConnectedDevices() {\n return VoiceRecorderImpl.getConnectedDevices();\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;IACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAClE,CAAC;;ICHM,MAAM,eAAe,GAAG,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC/C,MAAM,eAAe,GAAG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAChD,MAAM,sBAAsB,GAAG,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC;IACpE,MAAM,qBAAqB,GAAG,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC;IAElE,MAAM,4BAA4B,GAAG,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC;IAClF,MAAM,mBAAmB,GAAG,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC;IAC/D,MAAM,mBAAmB,GAAG,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;IAC9D,MAAM,2BAA2B,GAAG,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC;IAChF,MAAM,2BAA2B,GAAG,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CAAC;IAC3B,QAAQ,IAAI,CAAC,qBAAqB,GAAG,IAAI,iBAAiB,EAAE;IAC5D;IACA,IAAI,oBAAoB,GAAG;IAC3B,QAAQ,OAAO,iBAAiB,CAAC,oBAAoB,EAAE;IACvD;IACA,IAAI,2BAA2B,GAAG;IAClC,QAAQ,OAAO,iBAAiB,CAAC,2BAA2B,EAAE;IAC9D;IACA,IAAI,+BAA+B,GAAG;IACtC,QAAQ,OAAO,iBAAiB,CAAC,+BAA+B,EAAE;IAClE;IACA,IAAI,cAAc,GAAG;IACrB,QAAQ,OAAO,IAAI,CAAC,qBAAqB,CAAC,cAAc,EAAE;IAC1D;IACA,IAAI,aAAa,GAAG;IACpB,QAAQ,OAAO,IAAI,CAAC,qBAAqB,CAAC,aAAa,EAAE;IACzD;IACA,IAAI,cAAc,GAAG;IACrB,QAAQ,OAAO,IAAI,CAAC,qBAAqB,CAAC,cAAc,EAAE;IAC1D;IACA,IAAI,eAAe,GAAG;IACtB,QAAQ,OAAO,IAAI,CAAC,qBAAqB,CAAC,eAAe,EAAE;IAC3D;IACA,IAAI,gBAAgB,GAAG;IACvB,QAAQ,OAAO,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,EAAE;IAC5D;IACA,IAAI,mBAAmB,GAAG;IAC1B,QAAQ,OAAO,iBAAiB,CAAC,mBAAmB,EAAE;IACtD;IACA;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/predefined-web-responses.js","esm/VoiceRecorderImpl.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst VoiceRecorder = registerPlugin('VoiceRecorder', {\n web: () => import('./web').then(m => new m.VoiceRecorderWeb()),\n});\nexport * from './definitions';\nexport { VoiceRecorder };\n//# sourceMappingURL=index.js.map","export const successResponse = () => ({ value: true });\nexport const failureResponse = () => ({ value: false });\nexport const missingPermissionError = () => new Error('MISSING_PERMISSION');\nexport const alreadyRecordingError = () => new Error('ALREADY_RECORDING');\nexport const microphoneBeingUsedError = () => new Error('MICROPHONE_BEING_USED');\nexport const deviceCannotVoiceRecordError = () => new Error('DEVICE_CANNOT_VOICE_RECORD');\nexport const failedToRecordError = () => new Error('FAILED_TO_RECORD');\nexport const emptyRecordingError = () => new Error('EMPTY_RECORDING');\nexport const recordingHasNotStartedError = () => new Error('RECORDING_HAS_NOT_STARTED');\nexport const failedToFetchRecordingError = () => new Error('FAILED_TO_FETCH_RECORDING');\nexport const couldNotQueryPermissionStatusError = () => new Error('COULD_NOT_QUERY_PERMISSION_STATUS');\n//# sourceMappingURL=predefined-web-responses.js.map","import getBlobDuration from 'get-blob-duration';\nimport { alreadyRecordingError, couldNotQueryPermissionStatusError, deviceCannotVoiceRecordError, emptyRecordingError, failedToFetchRecordingError, failedToRecordError, failureResponse, missingPermissionError, recordingHasNotStartedError, successResponse, } from './predefined-web-responses';\n// these mime types will be checked one by one in order until one of them is found to be supported by the current browser\nconst possibleMimeTypes = ['audio/mp4', 'audio/webm;codecs=opus', 'audio/aac', 'audio/webm', 'audio/ogg;codecs=opus'];\nconst neverResolvingPromise = () => new Promise(() => undefined);\nexport class VoiceRecorderImpl {\n constructor() {\n this.mediaRecorder = null;\n this.chunks = [];\n this.pendingResult = neverResolvingPromise();\n }\n static async canDeviceVoiceRecord() {\n var _a;\n if (((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) == null || VoiceRecorderImpl.getSupportedMimeType() == null) {\n return failureResponse();\n }\n else {\n return successResponse();\n }\n }\n async startRecording() {\n if (this.mediaRecorder != null) {\n throw alreadyRecordingError();\n }\n const deviceCanRecord = await VoiceRecorderImpl.canDeviceVoiceRecord();\n if (!deviceCanRecord.value) {\n throw deviceCannotVoiceRecordError();\n }\n const havingPermission = await VoiceRecorderImpl.hasAudioRecordingPermission().catch(() => successResponse());\n if (!havingPermission.value) {\n throw missingPermissionError();\n }\n return navigator.mediaDevices.getUserMedia({ audio: true })\n .then(this.onSuccessfullyStartedRecording.bind(this))\n .catch(this.onFailedToStartRecording.bind(this));\n }\n async stopRecording() {\n if (this.mediaRecorder == null) {\n throw recordingHasNotStartedError();\n }\n try {\n this.mediaRecorder.stop();\n this.mediaRecorder.stream.getTracks().forEach(track => track.stop());\n return this.pendingResult;\n }\n catch (ignore) {\n throw failedToFetchRecordingError();\n }\n finally {\n this.prepareInstanceForNextOperation();\n }\n }\n static async hasAudioRecordingPermission() {\n return navigator.permissions.query({ name: 'microphone' })\n .then(result => ({ value: result.state === 'granted' }))\n .catch(() => {\n throw couldNotQueryPermissionStatusError();\n });\n }\n static async requestAudioRecordingPermission() {\n const havingPermission = await VoiceRecorderImpl.hasAudioRecordingPermission().catch(() => failureResponse());\n if (havingPermission.value) {\n return successResponse();\n }\n return navigator.mediaDevices.getUserMedia({ audio: true })\n .then(() => successResponse())\n .catch(() => failureResponse());\n }\n pauseRecording() {\n if (this.mediaRecorder == null) {\n throw recordingHasNotStartedError();\n }\n else if (this.mediaRecorder.state === 'recording') {\n this.mediaRecorder.pause();\n return Promise.resolve(successResponse());\n }\n else {\n return Promise.resolve(failureResponse());\n }\n }\n resumeRecording() {\n if (this.mediaRecorder == null) {\n throw recordingHasNotStartedError();\n }\n else if (this.mediaRecorder.state === 'paused') {\n this.mediaRecorder.resume();\n return Promise.resolve(successResponse());\n }\n else {\n return Promise.resolve(failureResponse());\n }\n }\n getCurrentStatus() {\n if (this.mediaRecorder == null) {\n return Promise.resolve({ status: 'NONE' });\n }\n else if (this.mediaRecorder.state === 'recording') {\n return Promise.resolve({ status: 'RECORDING' });\n }\n else if (this.mediaRecorder.state === 'paused') {\n return Promise.resolve({ status: 'PAUSED' });\n }\n else {\n return Promise.resolve({ status: 'NONE' });\n }\n }\n static getSupportedMimeType() {\n if ((MediaRecorder === null || MediaRecorder === void 0 ? void 0 : MediaRecorder.isTypeSupported) == null)\n return null;\n const foundSupportedType = possibleMimeTypes.find(type => MediaRecorder.isTypeSupported(type));\n return foundSupportedType !== null && foundSupportedType !== void 0 ? foundSupportedType : null;\n }\n onSuccessfullyStartedRecording(stream) {\n this.pendingResult = new Promise((resolve, reject) => {\n this.mediaRecorder = new MediaRecorder(stream);\n this.mediaRecorder.onerror = () => {\n this.prepareInstanceForNextOperation();\n reject(failedToRecordError());\n };\n this.mediaRecorder.onstop = async () => {\n const mimeType = VoiceRecorderImpl.getSupportedMimeType();\n if (mimeType == null) {\n this.prepareInstanceForNextOperation();\n reject(failedToFetchRecordingError());\n return;\n }\n const blobVoiceRecording = new Blob(this.chunks, { 'type': mimeType });\n if (blobVoiceRecording.size <= 0) {\n this.prepareInstanceForNextOperation();\n reject(emptyRecordingError());\n return;\n }\n const recordDataBase64 = await VoiceRecorderImpl.blobToBase64(blobVoiceRecording);\n const recordingDuration = await getBlobDuration(blobVoiceRecording);\n this.prepareInstanceForNextOperation();\n resolve({ value: { recordDataBase64, mimeType, msDuration: recordingDuration * 1000 } });\n };\n this.mediaRecorder.ondataavailable = (event) => this.chunks.push(event.data);\n this.mediaRecorder.start();\n });\n return successResponse();\n }\n onFailedToStartRecording() {\n this.prepareInstanceForNextOperation();\n throw failedToRecordError();\n }\n static blobToBase64(blob) {\n return new Promise(resolve => {\n const reader = new FileReader();\n reader.onloadend = () => {\n const recordingResult = String(reader.result);\n const splitResult = recordingResult.split('base64,');\n const toResolve = (splitResult.length > 1) ? splitResult[1] : recordingResult;\n resolve(toResolve.trim());\n };\n reader.readAsDataURL(blob);\n });\n }\n prepareInstanceForNextOperation() {\n if (this.mediaRecorder != null && this.mediaRecorder.state === 'recording') {\n try {\n this.mediaRecorder.stop();\n }\n catch (ignore) {\n }\n }\n this.pendingResult = neverResolvingPromise();\n this.mediaRecorder = null;\n this.chunks = [];\n }\n static async getConnectedDevices() {\n try {\n const devices = await navigator.mediaDevices.enumerateDevices();\n return { devices };\n }\n catch (error) {\n // ブラウザがAPIをサポートしていない場合は空配列を返す\n return { devices: [] };\n }\n }\n}\n//# sourceMappingURL=VoiceRecorderImpl.js.map","import { WebPlugin } from '@capacitor/core';\nimport { VoiceRecorderImpl } from './VoiceRecorderImpl';\nexport class VoiceRecorderWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.voiceRecorderInstance = new VoiceRecorderImpl();\n }\n canDeviceVoiceRecord() {\n return VoiceRecorderImpl.canDeviceVoiceRecord();\n }\n hasAudioRecordingPermission() {\n return VoiceRecorderImpl.hasAudioRecordingPermission();\n }\n requestAudioRecordingPermission() {\n return VoiceRecorderImpl.requestAudioRecordingPermission();\n }\n startRecording() {\n return this.voiceRecorderInstance.startRecording();\n }\n stopRecording() {\n return this.voiceRecorderInstance.stopRecording();\n }\n pauseRecording() {\n return this.voiceRecorderInstance.pauseRecording();\n }\n resumeRecording() {\n return this.voiceRecorderInstance.resumeRecording();\n }\n getCurrentStatus() {\n return this.voiceRecorderInstance.getCurrentStatus();\n }\n getConnectedDevices() {\n return VoiceRecorderImpl.getConnectedDevices();\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;IACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAClE,CAAC;;ICHM,MAAM,eAAe,GAAG,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC/C,MAAM,eAAe,GAAG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAChD,MAAM,sBAAsB,GAAG,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC;IACpE,MAAM,qBAAqB,GAAG,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC;IAElE,MAAM,4BAA4B,GAAG,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC;IAClF,MAAM,mBAAmB,GAAG,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC;IAC/D,MAAM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AgB,GAAG;IACvB,QAAQ,OAAO,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,EAAE;IAC5D,IAAI;IACJ,IAAI,mBAAmB,GAAG;IAC1B,QAAQ,OAAO,iBAAiB,CAAC,mBAAmB,EAAE;IACtD,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
|
|
3
|
-
enum CurrentRecordingStatus: String {
|
|
4
|
-
|
|
5
|
-
case RECORDING
|
|
6
|
-
case PAUSED
|
|
7
|
-
case NONE
|
|
8
|
-
|
|
9
|
-
}
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
enum CurrentRecordingStatus: String {
|
|
4
|
+
|
|
5
|
+
case RECORDING
|
|
6
|
+
case PAUSED
|
|
7
|
+
case NONE
|
|
8
|
+
|
|
9
|
+
}
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
import AVFoundation
|
|
3
|
-
|
|
4
|
-
class CustomMediaRecorder {
|
|
5
|
-
|
|
6
|
-
private var recordingSession: AVAudioSession!
|
|
7
|
-
private var audioRecorder: AVAudioRecorder!
|
|
8
|
-
private var audioFilePath: URL!
|
|
9
|
-
private var originalRecordingSessionCategory: AVAudioSession.Category!
|
|
10
|
-
private var status = CurrentRecordingStatus.NONE
|
|
11
|
-
|
|
12
|
-
private let settings = [
|
|
13
|
-
AVFormatIDKey: Int(kAudioFormatLinearPCM), // Changed to Linear PCM for WAV
|
|
14
|
-
AVSampleRateKey: 44100,
|
|
15
|
-
AVNumberOfChannelsKey: 2, // Stereo
|
|
16
|
-
AVLinearPCMBitDepthKey: 16, // Typical bit depth for WAV
|
|
17
|
-
AVLinearPCMIsBigEndianKey: false,
|
|
18
|
-
AVLinearPCMIsFloatKey: false,
|
|
19
|
-
AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
|
|
20
|
-
] as [String : Any]
|
|
21
|
-
|
|
22
|
-
private func getDirectoryToSaveAudioFile() -> URL {
|
|
23
|
-
return URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public func startRecording() -> Bool {
|
|
27
|
-
do {
|
|
28
|
-
recordingSession = AVAudioSession.sharedInstance()
|
|
29
|
-
originalRecordingSessionCategory = recordingSession.category
|
|
30
|
-
try recordingSession.setCategory(AVAudioSession.Category.playAndRecord, options: [.allowBluetoothA2DP, .defaultToSpeaker])
|
|
31
|
-
try recordingSession.setActive(true)
|
|
32
|
-
audioFilePath = getDirectoryToSaveAudioFile().appendingPathComponent("\(UUID().uuidString).wav")
|
|
33
|
-
audioRecorder = try AVAudioRecorder(url: audioFilePath, settings: settings)
|
|
34
|
-
audioRecorder.record()
|
|
35
|
-
status = CurrentRecordingStatus.RECORDING
|
|
36
|
-
return true
|
|
37
|
-
} catch {
|
|
38
|
-
return false
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public func stopRecording() {
|
|
43
|
-
do {
|
|
44
|
-
audioRecorder.stop()
|
|
45
|
-
try recordingSession.setActive(false)
|
|
46
|
-
try recordingSession.setCategory(originalRecordingSessionCategory)
|
|
47
|
-
originalRecordingSessionCategory = nil
|
|
48
|
-
audioRecorder = nil
|
|
49
|
-
recordingSession = nil
|
|
50
|
-
status = CurrentRecordingStatus.NONE
|
|
51
|
-
} catch {}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public func getOutputFile() -> URL {
|
|
55
|
-
return audioFilePath
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public func pauseRecording() -> Bool {
|
|
59
|
-
if(status == CurrentRecordingStatus.RECORDING) {
|
|
60
|
-
audioRecorder.pause()
|
|
61
|
-
status = CurrentRecordingStatus.PAUSED
|
|
62
|
-
return true
|
|
63
|
-
} else {
|
|
64
|
-
return false
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public func resumeRecording() -> Bool {
|
|
69
|
-
if(status == CurrentRecordingStatus.PAUSED) {
|
|
70
|
-
audioRecorder.record()
|
|
71
|
-
status = CurrentRecordingStatus.RECORDING
|
|
72
|
-
return true
|
|
73
|
-
} else {
|
|
74
|
-
return false
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public func getCurrentStatus() -> CurrentRecordingStatus {
|
|
79
|
-
return status
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
}
|
|
1
|
+
import Foundation
|
|
2
|
+
import AVFoundation
|
|
3
|
+
|
|
4
|
+
class CustomMediaRecorder {
|
|
5
|
+
|
|
6
|
+
private var recordingSession: AVAudioSession!
|
|
7
|
+
private var audioRecorder: AVAudioRecorder!
|
|
8
|
+
private var audioFilePath: URL!
|
|
9
|
+
private var originalRecordingSessionCategory: AVAudioSession.Category!
|
|
10
|
+
private var status = CurrentRecordingStatus.NONE
|
|
11
|
+
|
|
12
|
+
private let settings = [
|
|
13
|
+
AVFormatIDKey: Int(kAudioFormatLinearPCM), // Changed to Linear PCM for WAV
|
|
14
|
+
AVSampleRateKey: 44100,
|
|
15
|
+
AVNumberOfChannelsKey: 2, // Stereo
|
|
16
|
+
AVLinearPCMBitDepthKey: 16, // Typical bit depth for WAV
|
|
17
|
+
AVLinearPCMIsBigEndianKey: false,
|
|
18
|
+
AVLinearPCMIsFloatKey: false,
|
|
19
|
+
AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
|
|
20
|
+
] as [String : Any]
|
|
21
|
+
|
|
22
|
+
private func getDirectoryToSaveAudioFile() -> URL {
|
|
23
|
+
return URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public func startRecording() -> Bool {
|
|
27
|
+
do {
|
|
28
|
+
recordingSession = AVAudioSession.sharedInstance()
|
|
29
|
+
originalRecordingSessionCategory = recordingSession.category
|
|
30
|
+
try recordingSession.setCategory(AVAudioSession.Category.playAndRecord, options: [.allowBluetoothA2DP, .defaultToSpeaker])
|
|
31
|
+
try recordingSession.setActive(true)
|
|
32
|
+
audioFilePath = getDirectoryToSaveAudioFile().appendingPathComponent("\(UUID().uuidString).wav")
|
|
33
|
+
audioRecorder = try AVAudioRecorder(url: audioFilePath, settings: settings)
|
|
34
|
+
audioRecorder.record()
|
|
35
|
+
status = CurrentRecordingStatus.RECORDING
|
|
36
|
+
return true
|
|
37
|
+
} catch {
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public func stopRecording() {
|
|
43
|
+
do {
|
|
44
|
+
audioRecorder.stop()
|
|
45
|
+
try recordingSession.setActive(false)
|
|
46
|
+
try recordingSession.setCategory(originalRecordingSessionCategory)
|
|
47
|
+
originalRecordingSessionCategory = nil
|
|
48
|
+
audioRecorder = nil
|
|
49
|
+
recordingSession = nil
|
|
50
|
+
status = CurrentRecordingStatus.NONE
|
|
51
|
+
} catch {}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public func getOutputFile() -> URL {
|
|
55
|
+
return audioFilePath
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public func pauseRecording() -> Bool {
|
|
59
|
+
if(status == CurrentRecordingStatus.RECORDING) {
|
|
60
|
+
audioRecorder.pause()
|
|
61
|
+
status = CurrentRecordingStatus.PAUSED
|
|
62
|
+
return true
|
|
63
|
+
} else {
|
|
64
|
+
return false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public func resumeRecording() -> Bool {
|
|
69
|
+
if(status == CurrentRecordingStatus.PAUSED) {
|
|
70
|
+
audioRecorder.record()
|
|
71
|
+
status = CurrentRecordingStatus.RECORDING
|
|
72
|
+
return true
|
|
73
|
+
} else {
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public func getCurrentStatus() -> CurrentRecordingStatus {
|
|
79
|
+
return status
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
package/ios/Plugin/Info.plist
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
-
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
-
<key>CFBundleExecutable</key>
|
|
8
|
-
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
-
<key>CFBundleIdentifier</key>
|
|
10
|
-
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
-
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
-
<string>6.0</string>
|
|
13
|
-
<key>CFBundleName</key>
|
|
14
|
-
<string>$(PRODUCT_NAME)</string>
|
|
15
|
-
<key>CFBundlePackageType</key>
|
|
16
|
-
<string>FMWK</string>
|
|
17
|
-
<key>CFBundleShortVersionString</key>
|
|
18
|
-
<string>1.0</string>
|
|
19
|
-
<key>CFBundleVersion</key>
|
|
20
|
-
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
-
<key>NSPrincipalClass</key>
|
|
22
|
-
<string></string>
|
|
23
|
-
</dict>
|
|
24
|
-
</plist>
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
struct Messages {
|
|
5
|
-
|
|
6
|
-
static let MISSING_PERMISSION = "MISSING_PERMISSION"
|
|
7
|
-
static let CANNOT_RECORD_ON_THIS_PHONE = "CANNOT_RECORD_ON_THIS_PHONE"
|
|
8
|
-
static let FAILED_TO_RECORD = "FAILED_TO_RECORD"
|
|
9
|
-
static let RECORDING_HAS_NOT_STARTED = "RECORDING_HAS_NOT_STARTED"
|
|
10
|
-
static let FAILED_TO_FETCH_RECORDING = "FAILED_TO_FETCH_RECORDING"
|
|
11
|
-
static let EMPTY_RECORDING = "EMPTY_RECORDING"
|
|
12
|
-
static let ALREADY_RECORDING = "ALREADY_RECORDING"
|
|
13
|
-
static let MICROPHONE_BEING_USED = "MICROPHONE_BEING_USED"
|
|
14
|
-
|
|
15
|
-
}
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
struct Messages {
|
|
5
|
+
|
|
6
|
+
static let MISSING_PERMISSION = "MISSING_PERMISSION"
|
|
7
|
+
static let CANNOT_RECORD_ON_THIS_PHONE = "CANNOT_RECORD_ON_THIS_PHONE"
|
|
8
|
+
static let FAILED_TO_RECORD = "FAILED_TO_RECORD"
|
|
9
|
+
static let RECORDING_HAS_NOT_STARTED = "RECORDING_HAS_NOT_STARTED"
|
|
10
|
+
static let FAILED_TO_FETCH_RECORDING = "FAILED_TO_FETCH_RECORDING"
|
|
11
|
+
static let EMPTY_RECORDING = "EMPTY_RECORDING"
|
|
12
|
+
static let ALREADY_RECORDING = "ALREADY_RECORDING"
|
|
13
|
+
static let MICROPHONE_BEING_USED = "MICROPHONE_BEING_USED"
|
|
14
|
+
|
|
15
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
|
|
3
|
-
struct RecordData {
|
|
4
|
-
|
|
5
|
-
public let recordDataBase64: String?
|
|
6
|
-
public let mimeType: String
|
|
7
|
-
public let msDuration: Int
|
|
8
|
-
|
|
9
|
-
public func toDictionary() -> Dictionary<String, Any> {
|
|
10
|
-
return [
|
|
11
|
-
"recordDataBase64": recordDataBase64 ?? "",
|
|
12
|
-
"msDuration": msDuration,
|
|
13
|
-
"mimeType": mimeType
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
}
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
struct RecordData {
|
|
4
|
+
|
|
5
|
+
public let recordDataBase64: String?
|
|
6
|
+
public let mimeType: String
|
|
7
|
+
public let msDuration: Int
|
|
8
|
+
|
|
9
|
+
public func toDictionary() -> Dictionary<String, Any> {
|
|
10
|
+
return [
|
|
11
|
+
"recordDataBase64": recordDataBase64 ?? "",
|
|
12
|
+
"msDuration": msDuration,
|
|
13
|
+
"mimeType": mimeType
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
|
|
3
|
-
struct ResponseGenerator {
|
|
4
|
-
|
|
5
|
-
private static let VALUE_RESPONSE_KEY = "value"
|
|
6
|
-
private static let STATUS_RESPONSE_KEY = "status"
|
|
7
|
-
|
|
8
|
-
public static func fromBoolean(_ value: Bool) -> Dictionary<String, Bool> {
|
|
9
|
-
return value ? successResponse() : failResponse()
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public static func successResponse() -> Dictionary<String, Bool> {
|
|
13
|
-
return [VALUE_RESPONSE_KEY: true]
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public static func failResponse() -> Dictionary<String, Bool> {
|
|
17
|
-
return [VALUE_RESPONSE_KEY: false]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public static func dataResponse(_ data: Any) -> Dictionary<String, Any> {
|
|
21
|
-
return [VALUE_RESPONSE_KEY: data]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public static func statusResponse(_ data: CurrentRecordingStatus) -> Dictionary<String, String> {
|
|
25
|
-
return [STATUS_RESPONSE_KEY: data.rawValue]
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
}
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
struct ResponseGenerator {
|
|
4
|
+
|
|
5
|
+
private static let VALUE_RESPONSE_KEY = "value"
|
|
6
|
+
private static let STATUS_RESPONSE_KEY = "status"
|
|
7
|
+
|
|
8
|
+
public static func fromBoolean(_ value: Bool) -> Dictionary<String, Bool> {
|
|
9
|
+
return value ? successResponse() : failResponse()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public static func successResponse() -> Dictionary<String, Bool> {
|
|
13
|
+
return [VALUE_RESPONSE_KEY: true]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public static func failResponse() -> Dictionary<String, Bool> {
|
|
17
|
+
return [VALUE_RESPONSE_KEY: false]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public static func dataResponse(_ data: Any) -> Dictionary<String, Any> {
|
|
21
|
+
return [VALUE_RESPONSE_KEY: data]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public static func statusResponse(_ data: CurrentRecordingStatus) -> Dictionary<String, String> {
|
|
25
|
+
return [STATUS_RESPONSE_KEY: data.rawValue]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|