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
|
@@ -1,187 +1,187 @@
|
|
|
1
|
-
package com.tchvu3.capacitorvoicerecorder;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.media.AudioFormat;
|
|
5
|
-
import android.media.AudioRecord;
|
|
6
|
-
import android.media.MediaRecorder;
|
|
7
|
-
import android.os.Build;
|
|
8
|
-
import android.util.Log;
|
|
9
|
-
|
|
10
|
-
import java.io.File;
|
|
11
|
-
import java.io.FileOutputStream;
|
|
12
|
-
import java.io.FileInputStream;
|
|
13
|
-
import java.io.IOException;
|
|
14
|
-
import java.nio.ByteBuffer;
|
|
15
|
-
import java.nio.ByteOrder;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
public class CustomMediaRecorder {
|
|
19
|
-
|
|
20
|
-
private final Context context;
|
|
21
|
-
private AudioRecord audioRecord;
|
|
22
|
-
private File outputFile;
|
|
23
|
-
private CurrentRecordingStatus currentRecordingStatus = CurrentRecordingStatus.NONE;
|
|
24
|
-
private Thread recordingThread;
|
|
25
|
-
private boolean isRecording = false;
|
|
26
|
-
|
|
27
|
-
private static final int SAMPLE_RATE = 44100;
|
|
28
|
-
private static final int CHANNEL_CONFIG = AudioFormat.CHANNEL_IN_STEREO;
|
|
29
|
-
private static final int AUDIO_FORMAT = AudioFormat.ENCODING_PCM_16BIT;
|
|
30
|
-
|
|
31
|
-
public CustomMediaRecorder(Context context) {
|
|
32
|
-
this.context = context;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public void initializeAudioRecord() throws IOException {
|
|
36
|
-
int minBufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIG, AUDIO_FORMAT);
|
|
37
|
-
try {
|
|
38
|
-
audioRecord = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, SAMPLE_RATE, CHANNEL_CONFIG, AUDIO_FORMAT, minBufferSize);
|
|
39
|
-
} catch (SecurityException e) {
|
|
40
|
-
throw new IOException("Missing permission to record audio", e);
|
|
41
|
-
}
|
|
42
|
-
setRecorderOutputFile();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private void setRecorderOutputFile() throws IOException {
|
|
46
|
-
File outputDir = context.getCacheDir();
|
|
47
|
-
outputFile = File.createTempFile("voice_record_temp", ".wav", outputDir);
|
|
48
|
-
outputFile.deleteOnExit();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public void startRecording() throws IOException {
|
|
52
|
-
if (audioRecord == null) {
|
|
53
|
-
initializeAudioRecord();
|
|
54
|
-
}
|
|
55
|
-
audioRecord.startRecording();
|
|
56
|
-
isRecording = true;
|
|
57
|
-
currentRecordingStatus = CurrentRecordingStatus.RECORDING;
|
|
58
|
-
|
|
59
|
-
recordingThread = new Thread(this::writeAudioDataToFile, "AudioRecorder Thread");
|
|
60
|
-
recordingThread.start();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private void writeAudioDataToFile() {
|
|
64
|
-
byte[] data = new byte[AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIG, AUDIO_FORMAT)];
|
|
65
|
-
FileOutputStream os = null;
|
|
66
|
-
try {
|
|
67
|
-
os = new FileOutputStream(outputFile);
|
|
68
|
-
while (isRecording) {
|
|
69
|
-
int read = audioRecord.read(data, 0, data.length);
|
|
70
|
-
if (AudioRecord.ERROR_INVALID_OPERATION != read) {
|
|
71
|
-
os.write(data);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
} catch (IOException e) {
|
|
75
|
-
Log.e("CustomMediaRecorder", "Error writing audio data to file", e);
|
|
76
|
-
} finally {
|
|
77
|
-
try {
|
|
78
|
-
if (os != null) {
|
|
79
|
-
os.close();
|
|
80
|
-
}
|
|
81
|
-
} catch (IOException e) {
|
|
82
|
-
Log.e("CustomMediaRecorder", "Error closing output stream", e);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
public void stopRecording() {
|
|
88
|
-
if (audioRecord != null) {
|
|
89
|
-
isRecording = false;
|
|
90
|
-
audioRecord.stop();
|
|
91
|
-
audioRecord.release();
|
|
92
|
-
audioRecord = null;
|
|
93
|
-
recordingThread = null;
|
|
94
|
-
currentRecordingStatus = CurrentRecordingStatus.NONE;
|
|
95
|
-
writeWavHeader();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private void writeWavHeader() {
|
|
100
|
-
try {
|
|
101
|
-
FileInputStream fis = new FileInputStream(outputFile);
|
|
102
|
-
byte[] audioData = new byte[(int) outputFile.length()];
|
|
103
|
-
int bytesRead = fis.read(audioData);
|
|
104
|
-
if (bytesRead < 0) {
|
|
105
|
-
Log.e("CustomMediaRecorder", "Error reading audio data from file");
|
|
106
|
-
} else if (bytesRead < audioData.length) {
|
|
107
|
-
Log.w("CustomMediaRecorder", "Audio data size mismatch");
|
|
108
|
-
}
|
|
109
|
-
fis.close();
|
|
110
|
-
byte[] header = createWavHeader(audioData.length);
|
|
111
|
-
FileOutputStream os = new FileOutputStream(outputFile);
|
|
112
|
-
os.write(header);
|
|
113
|
-
os.write(audioData);
|
|
114
|
-
os.close();
|
|
115
|
-
} catch (IOException e) {
|
|
116
|
-
Log.e("CustomMediaRecorder", "Error writing audio data to file", e);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private byte[] createWavHeader(int audioLength) {
|
|
121
|
-
int totalLength = audioLength + 36;
|
|
122
|
-
byte[] header = new byte[44];
|
|
123
|
-
ByteBuffer buffer = ByteBuffer.wrap(header).order(ByteOrder.LITTLE_ENDIAN);
|
|
124
|
-
|
|
125
|
-
buffer.put("RIFF".getBytes());
|
|
126
|
-
buffer.putInt(totalLength);
|
|
127
|
-
buffer.put("WAVE".getBytes());
|
|
128
|
-
buffer.put("fmt ".getBytes());
|
|
129
|
-
buffer.putInt(16);
|
|
130
|
-
buffer.putShort((short) 1);
|
|
131
|
-
buffer.putShort((short) 2);
|
|
132
|
-
buffer.putInt(SAMPLE_RATE);
|
|
133
|
-
buffer.putInt(SAMPLE_RATE * 2 * 2);
|
|
134
|
-
buffer.putShort((short) 4);
|
|
135
|
-
buffer.putShort((short) 16);
|
|
136
|
-
buffer.put("data".getBytes());
|
|
137
|
-
buffer.putInt(audioLength);
|
|
138
|
-
|
|
139
|
-
return header;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
public File getOutputFile() {
|
|
143
|
-
return outputFile;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
public boolean pauseRecording() throws NotSupportedOsVersion {
|
|
147
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
|
148
|
-
throw new NotSupportedOsVersion();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (currentRecordingStatus == CurrentRecordingStatus.RECORDING) {
|
|
152
|
-
isRecording = false;
|
|
153
|
-
currentRecordingStatus = CurrentRecordingStatus.PAUSED;
|
|
154
|
-
return true;
|
|
155
|
-
} else {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
public boolean resumeRecording() throws NotSupportedOsVersion {
|
|
161
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
|
162
|
-
throw new NotSupportedOsVersion();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (currentRecordingStatus == CurrentRecordingStatus.PAUSED) {
|
|
166
|
-
isRecording = true;
|
|
167
|
-
currentRecordingStatus = CurrentRecordingStatus.RECORDING;
|
|
168
|
-
recordingThread = new Thread(this::writeAudioDataToFile, "AudioRecorder Thread");
|
|
169
|
-
recordingThread.start();
|
|
170
|
-
return true;
|
|
171
|
-
} else {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
public CurrentRecordingStatus getCurrentStatus() {
|
|
177
|
-
return currentRecordingStatus;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
public boolean deleteOutputFile() {
|
|
181
|
-
return outputFile.delete();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
public static boolean canPhoneCreateMediaRecorder(Context ignoredContext) {
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
1
|
+
package com.tchvu3.capacitorvoicerecorder;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.media.AudioFormat;
|
|
5
|
+
import android.media.AudioRecord;
|
|
6
|
+
import android.media.MediaRecorder;
|
|
7
|
+
import android.os.Build;
|
|
8
|
+
import android.util.Log;
|
|
9
|
+
|
|
10
|
+
import java.io.File;
|
|
11
|
+
import java.io.FileOutputStream;
|
|
12
|
+
import java.io.FileInputStream;
|
|
13
|
+
import java.io.IOException;
|
|
14
|
+
import java.nio.ByteBuffer;
|
|
15
|
+
import java.nio.ByteOrder;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
public class CustomMediaRecorder {
|
|
19
|
+
|
|
20
|
+
private final Context context;
|
|
21
|
+
private AudioRecord audioRecord;
|
|
22
|
+
private File outputFile;
|
|
23
|
+
private CurrentRecordingStatus currentRecordingStatus = CurrentRecordingStatus.NONE;
|
|
24
|
+
private Thread recordingThread;
|
|
25
|
+
private boolean isRecording = false;
|
|
26
|
+
|
|
27
|
+
private static final int SAMPLE_RATE = 44100;
|
|
28
|
+
private static final int CHANNEL_CONFIG = AudioFormat.CHANNEL_IN_STEREO;
|
|
29
|
+
private static final int AUDIO_FORMAT = AudioFormat.ENCODING_PCM_16BIT;
|
|
30
|
+
|
|
31
|
+
public CustomMediaRecorder(Context context) {
|
|
32
|
+
this.context = context;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public void initializeAudioRecord() throws IOException {
|
|
36
|
+
int minBufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIG, AUDIO_FORMAT);
|
|
37
|
+
try {
|
|
38
|
+
audioRecord = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, SAMPLE_RATE, CHANNEL_CONFIG, AUDIO_FORMAT, minBufferSize);
|
|
39
|
+
} catch (SecurityException e) {
|
|
40
|
+
throw new IOException("Missing permission to record audio", e);
|
|
41
|
+
}
|
|
42
|
+
setRecorderOutputFile();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private void setRecorderOutputFile() throws IOException {
|
|
46
|
+
File outputDir = context.getCacheDir();
|
|
47
|
+
outputFile = File.createTempFile("voice_record_temp", ".wav", outputDir);
|
|
48
|
+
outputFile.deleteOnExit();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public void startRecording() throws IOException {
|
|
52
|
+
if (audioRecord == null) {
|
|
53
|
+
initializeAudioRecord();
|
|
54
|
+
}
|
|
55
|
+
audioRecord.startRecording();
|
|
56
|
+
isRecording = true;
|
|
57
|
+
currentRecordingStatus = CurrentRecordingStatus.RECORDING;
|
|
58
|
+
|
|
59
|
+
recordingThread = new Thread(this::writeAudioDataToFile, "AudioRecorder Thread");
|
|
60
|
+
recordingThread.start();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private void writeAudioDataToFile() {
|
|
64
|
+
byte[] data = new byte[AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIG, AUDIO_FORMAT)];
|
|
65
|
+
FileOutputStream os = null;
|
|
66
|
+
try {
|
|
67
|
+
os = new FileOutputStream(outputFile);
|
|
68
|
+
while (isRecording) {
|
|
69
|
+
int read = audioRecord.read(data, 0, data.length);
|
|
70
|
+
if (AudioRecord.ERROR_INVALID_OPERATION != read) {
|
|
71
|
+
os.write(data);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} catch (IOException e) {
|
|
75
|
+
Log.e("CustomMediaRecorder", "Error writing audio data to file", e);
|
|
76
|
+
} finally {
|
|
77
|
+
try {
|
|
78
|
+
if (os != null) {
|
|
79
|
+
os.close();
|
|
80
|
+
}
|
|
81
|
+
} catch (IOException e) {
|
|
82
|
+
Log.e("CustomMediaRecorder", "Error closing output stream", e);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public void stopRecording() {
|
|
88
|
+
if (audioRecord != null) {
|
|
89
|
+
isRecording = false;
|
|
90
|
+
audioRecord.stop();
|
|
91
|
+
audioRecord.release();
|
|
92
|
+
audioRecord = null;
|
|
93
|
+
recordingThread = null;
|
|
94
|
+
currentRecordingStatus = CurrentRecordingStatus.NONE;
|
|
95
|
+
writeWavHeader();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private void writeWavHeader() {
|
|
100
|
+
try {
|
|
101
|
+
FileInputStream fis = new FileInputStream(outputFile);
|
|
102
|
+
byte[] audioData = new byte[(int) outputFile.length()];
|
|
103
|
+
int bytesRead = fis.read(audioData);
|
|
104
|
+
if (bytesRead < 0) {
|
|
105
|
+
Log.e("CustomMediaRecorder", "Error reading audio data from file");
|
|
106
|
+
} else if (bytesRead < audioData.length) {
|
|
107
|
+
Log.w("CustomMediaRecorder", "Audio data size mismatch");
|
|
108
|
+
}
|
|
109
|
+
fis.close();
|
|
110
|
+
byte[] header = createWavHeader(audioData.length);
|
|
111
|
+
FileOutputStream os = new FileOutputStream(outputFile);
|
|
112
|
+
os.write(header);
|
|
113
|
+
os.write(audioData);
|
|
114
|
+
os.close();
|
|
115
|
+
} catch (IOException e) {
|
|
116
|
+
Log.e("CustomMediaRecorder", "Error writing audio data to file", e);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
private byte[] createWavHeader(int audioLength) {
|
|
121
|
+
int totalLength = audioLength + 36;
|
|
122
|
+
byte[] header = new byte[44];
|
|
123
|
+
ByteBuffer buffer = ByteBuffer.wrap(header).order(ByteOrder.LITTLE_ENDIAN);
|
|
124
|
+
|
|
125
|
+
buffer.put("RIFF".getBytes());
|
|
126
|
+
buffer.putInt(totalLength);
|
|
127
|
+
buffer.put("WAVE".getBytes());
|
|
128
|
+
buffer.put("fmt ".getBytes());
|
|
129
|
+
buffer.putInt(16);
|
|
130
|
+
buffer.putShort((short) 1);
|
|
131
|
+
buffer.putShort((short) 2);
|
|
132
|
+
buffer.putInt(SAMPLE_RATE);
|
|
133
|
+
buffer.putInt(SAMPLE_RATE * 2 * 2);
|
|
134
|
+
buffer.putShort((short) 4);
|
|
135
|
+
buffer.putShort((short) 16);
|
|
136
|
+
buffer.put("data".getBytes());
|
|
137
|
+
buffer.putInt(audioLength);
|
|
138
|
+
|
|
139
|
+
return header;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public File getOutputFile() {
|
|
143
|
+
return outputFile;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public boolean pauseRecording() throws NotSupportedOsVersion {
|
|
147
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
|
148
|
+
throw new NotSupportedOsVersion();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (currentRecordingStatus == CurrentRecordingStatus.RECORDING) {
|
|
152
|
+
isRecording = false;
|
|
153
|
+
currentRecordingStatus = CurrentRecordingStatus.PAUSED;
|
|
154
|
+
return true;
|
|
155
|
+
} else {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public boolean resumeRecording() throws NotSupportedOsVersion {
|
|
161
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
|
162
|
+
throw new NotSupportedOsVersion();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (currentRecordingStatus == CurrentRecordingStatus.PAUSED) {
|
|
166
|
+
isRecording = true;
|
|
167
|
+
currentRecordingStatus = CurrentRecordingStatus.RECORDING;
|
|
168
|
+
recordingThread = new Thread(this::writeAudioDataToFile, "AudioRecorder Thread");
|
|
169
|
+
recordingThread.start();
|
|
170
|
+
return true;
|
|
171
|
+
} else {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public CurrentRecordingStatus getCurrentStatus() {
|
|
177
|
+
return currentRecordingStatus;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public boolean deleteOutputFile() {
|
|
181
|
+
return outputFile.delete();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
public static boolean canPhoneCreateMediaRecorder(Context ignoredContext) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
187
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
package com.tchvu3.capacitorvoicerecorder;
|
|
2
|
-
|
|
3
|
-
public abstract class Messages {
|
|
4
|
-
|
|
5
|
-
public static final String MISSING_PERMISSION = "MISSING_PERMISSION";
|
|
6
|
-
public static final String CANNOT_RECORD_ON_THIS_PHONE = "CANNOT_RECORD_ON_THIS_PHONE";
|
|
7
|
-
public static final String FAILED_TO_RECORD = "FAILED_TO_RECORD";
|
|
8
|
-
public static final String RECORDING_HAS_NOT_STARTED = "RECORDING_HAS_NOT_STARTED";
|
|
9
|
-
public static final String FAILED_TO_FETCH_RECORDING = "FAILED_TO_FETCH_RECORDING";
|
|
10
|
-
public static final String NOT_SUPPORTED_OS_VERSION = "NOT_SUPPORTED_OS_VERSION";
|
|
11
|
-
public static final String ALREADY_RECORDING = "ALREADY_RECORDING";
|
|
12
|
-
public static final String EMPTY_RECORDING = "EMPTY_RECORDING";
|
|
13
|
-
public static final String MICROPHONE_BEING_USED = "MICROPHONE_BEING_USED";
|
|
14
|
-
|
|
15
|
-
}
|
|
1
|
+
package com.tchvu3.capacitorvoicerecorder;
|
|
2
|
+
|
|
3
|
+
public abstract class Messages {
|
|
4
|
+
|
|
5
|
+
public static final String MISSING_PERMISSION = "MISSING_PERMISSION";
|
|
6
|
+
public static final String CANNOT_RECORD_ON_THIS_PHONE = "CANNOT_RECORD_ON_THIS_PHONE";
|
|
7
|
+
public static final String FAILED_TO_RECORD = "FAILED_TO_RECORD";
|
|
8
|
+
public static final String RECORDING_HAS_NOT_STARTED = "RECORDING_HAS_NOT_STARTED";
|
|
9
|
+
public static final String FAILED_TO_FETCH_RECORDING = "FAILED_TO_FETCH_RECORDING";
|
|
10
|
+
public static final String NOT_SUPPORTED_OS_VERSION = "NOT_SUPPORTED_OS_VERSION";
|
|
11
|
+
public static final String ALREADY_RECORDING = "ALREADY_RECORDING";
|
|
12
|
+
public static final String EMPTY_RECORDING = "EMPTY_RECORDING";
|
|
13
|
+
public static final String MICROPHONE_BEING_USED = "MICROPHONE_BEING_USED";
|
|
14
|
+
|
|
15
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.tchvu3.capacitorvoicerecorder;
|
|
2
|
-
|
|
3
|
-
public class NotSupportedOsVersion extends Exception {
|
|
4
|
-
}
|
|
1
|
+
package com.tchvu3.capacitorvoicerecorder;
|
|
2
|
+
|
|
3
|
+
public class NotSupportedOsVersion extends Exception {
|
|
4
|
+
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
package com.tchvu3.capacitorvoicerecorder;
|
|
2
|
-
|
|
3
|
-
import com.getcapacitor.JSObject;
|
|
4
|
-
|
|
5
|
-
public class RecordData {
|
|
6
|
-
|
|
7
|
-
private String recordDataBase64;
|
|
8
|
-
private String mimeType;
|
|
9
|
-
private int msDuration;
|
|
10
|
-
|
|
11
|
-
public RecordData() {
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public RecordData(String recordDataBase64, int msDuration, String mimeType) {
|
|
15
|
-
this.recordDataBase64 = recordDataBase64;
|
|
16
|
-
this.msDuration = msDuration;
|
|
17
|
-
this.mimeType = mimeType;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public String getRecordDataBase64() {
|
|
21
|
-
return recordDataBase64;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public void setRecordDataBase64(String recordDataBase64) {
|
|
25
|
-
this.recordDataBase64 = recordDataBase64;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public int getMsDuration() {
|
|
29
|
-
return msDuration;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public void setMsDuration(int msDuration) {
|
|
33
|
-
this.msDuration = msDuration;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public String getMimeType() {
|
|
37
|
-
return mimeType;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public void setMimeType(String mimeType) {
|
|
41
|
-
this.mimeType = mimeType;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public JSObject toJSObject() {
|
|
45
|
-
JSObject toReturn = new JSObject();
|
|
46
|
-
toReturn.put("recordDataBase64", recordDataBase64);
|
|
47
|
-
toReturn.put("msDuration", msDuration);
|
|
48
|
-
toReturn.put("mimeType", mimeType);
|
|
49
|
-
return toReturn;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
package com.tchvu3.capacitorvoicerecorder;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
|
|
5
|
+
public class RecordData {
|
|
6
|
+
|
|
7
|
+
private String recordDataBase64;
|
|
8
|
+
private String mimeType;
|
|
9
|
+
private int msDuration;
|
|
10
|
+
|
|
11
|
+
public RecordData() {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public RecordData(String recordDataBase64, int msDuration, String mimeType) {
|
|
15
|
+
this.recordDataBase64 = recordDataBase64;
|
|
16
|
+
this.msDuration = msDuration;
|
|
17
|
+
this.mimeType = mimeType;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public String getRecordDataBase64() {
|
|
21
|
+
return recordDataBase64;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public void setRecordDataBase64(String recordDataBase64) {
|
|
25
|
+
this.recordDataBase64 = recordDataBase64;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public int getMsDuration() {
|
|
29
|
+
return msDuration;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public void setMsDuration(int msDuration) {
|
|
33
|
+
this.msDuration = msDuration;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public String getMimeType() {
|
|
37
|
+
return mimeType;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public void setMimeType(String mimeType) {
|
|
41
|
+
this.mimeType = mimeType;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public JSObject toJSObject() {
|
|
45
|
+
JSObject toReturn = new JSObject();
|
|
46
|
+
toReturn.put("recordDataBase64", recordDataBase64);
|
|
47
|
+
toReturn.put("msDuration", msDuration);
|
|
48
|
+
toReturn.put("mimeType", mimeType);
|
|
49
|
+
return toReturn;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
package com.tchvu3.capacitorvoicerecorder;
|
|
2
|
-
|
|
3
|
-
import com.getcapacitor.JSObject;
|
|
4
|
-
|
|
5
|
-
public class ResponseGenerator {
|
|
6
|
-
|
|
7
|
-
private static final String VALUE_RESPONSE_KEY = "value";
|
|
8
|
-
private static final String STATUS_RESPONSE_KEY = "status";
|
|
9
|
-
|
|
10
|
-
public static JSObject fromBoolean(boolean value) {
|
|
11
|
-
return value ? successResponse() : failResponse();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public static JSObject successResponse() {
|
|
15
|
-
JSObject success = new JSObject();
|
|
16
|
-
success.put(VALUE_RESPONSE_KEY, true);
|
|
17
|
-
return success;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public static JSObject failResponse() {
|
|
21
|
-
JSObject success = new JSObject();
|
|
22
|
-
success.put(VALUE_RESPONSE_KEY, false);
|
|
23
|
-
return success;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public static JSObject dataResponse(Object data) {
|
|
27
|
-
JSObject success = new JSObject();
|
|
28
|
-
success.put(VALUE_RESPONSE_KEY, data);
|
|
29
|
-
return success;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public static JSObject statusResponse(CurrentRecordingStatus status) {
|
|
33
|
-
JSObject success = new JSObject();
|
|
34
|
-
success.put(STATUS_RESPONSE_KEY, status.name());
|
|
35
|
-
return success;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
package com.tchvu3.capacitorvoicerecorder;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
|
|
5
|
+
public class ResponseGenerator {
|
|
6
|
+
|
|
7
|
+
private static final String VALUE_RESPONSE_KEY = "value";
|
|
8
|
+
private static final String STATUS_RESPONSE_KEY = "status";
|
|
9
|
+
|
|
10
|
+
public static JSObject fromBoolean(boolean value) {
|
|
11
|
+
return value ? successResponse() : failResponse();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public static JSObject successResponse() {
|
|
15
|
+
JSObject success = new JSObject();
|
|
16
|
+
success.put(VALUE_RESPONSE_KEY, true);
|
|
17
|
+
return success;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public static JSObject failResponse() {
|
|
21
|
+
JSObject success = new JSObject();
|
|
22
|
+
success.put(VALUE_RESPONSE_KEY, false);
|
|
23
|
+
return success;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public static JSObject dataResponse(Object data) {
|
|
27
|
+
JSObject success = new JSObject();
|
|
28
|
+
success.put(VALUE_RESPONSE_KEY, data);
|
|
29
|
+
return success;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static JSObject statusResponse(CurrentRecordingStatus status) {
|
|
33
|
+
JSObject success = new JSObject();
|
|
34
|
+
success.put(STATUS_RESPONSE_KEY, status.name());
|
|
35
|
+
return success;
|
|
36
|
+
}
|
|
37
|
+
}
|