@react-native-ohos/react-native-audio 4.2.3-rc.1 → 4.2.3-rc.2
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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"Name": "react-native-audio",
|
|
4
|
+
"License": "MIT License",
|
|
5
|
+
"License File": "https://github.com/jsierles/react-native-audio/blob/master/LICENSE",
|
|
6
|
+
"Version Number": "4.2.2",
|
|
7
|
+
"Owner" : "xiafeng@huawei.com",
|
|
8
|
+
"Upstream URL": "https://github.com/jsierles/react-native-audio",
|
|
9
|
+
"Description": "Audio recorder library for React Native"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
|
3
|
+
*/
|
|
4
|
+
export const HAR_VERSION = '4.2.3-rc.2';
|
|
5
|
+
export const BUILD_MODE_NAME = 'debug';
|
|
6
|
+
export const DEBUG = true;
|
|
7
|
+
export const TARGET_NAME = 'default';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* BuildProfile Class is used only for compatibility purposes.
|
|
11
|
+
*/
|
|
12
|
+
export default class BuildProfile {
|
|
13
|
+
static readonly HAR_VERSION = HAR_VERSION;
|
|
14
|
+
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
|
|
15
|
+
static readonly DEBUG = DEBUG;
|
|
16
|
+
static readonly TARGET_NAME = TARGET_NAME;
|
|
17
|
+
}
|
|
@@ -64,16 +64,16 @@ export class AudioRecordManager {
|
|
|
64
64
|
async prepareRecordingAtPath(path: string, options: RecordingOptions): Promise<void> {
|
|
65
65
|
if (this.isRecording) {
|
|
66
66
|
this.logger.error('Please call stopRecording before starting recording.');
|
|
67
|
-
return
|
|
67
|
+
return Promise.reject('Please call stopRecording before starting recording.')
|
|
68
68
|
}
|
|
69
69
|
if (path === '') {
|
|
70
70
|
this.logger.error('Invalid path.');
|
|
71
|
-
return
|
|
71
|
+
return Promise.reject('Invalid path.')
|
|
72
72
|
}
|
|
73
73
|
const isAuthorization = await this.checkAuthorizationStatus();
|
|
74
74
|
if (!isAuthorization) {
|
|
75
75
|
this.logger.error('Please obtain microphone authorization first.');
|
|
76
|
-
return
|
|
76
|
+
return Promise.reject('Please obtain microphone authorization first.')
|
|
77
77
|
}
|
|
78
78
|
try {
|
|
79
79
|
//创建录制实例
|
|
@@ -102,15 +102,12 @@ export class AudioRecordManager {
|
|
|
102
102
|
this.file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
|
|
103
103
|
this.avConfig.url = `fd://${this.file.fd}`;
|
|
104
104
|
this.includeBase64 = options.IncludeBase64;
|
|
105
|
-
await this.avRecorder.prepare(this.avConfig)
|
|
106
|
-
this.logger.info(`${res}.`);
|
|
107
|
-
}).catch((err) => {
|
|
108
|
-
this.logger.error(`${err}.`);
|
|
109
|
-
});
|
|
105
|
+
await this.avRecorder.prepare(this.avConfig)
|
|
110
106
|
this.logger.info(`Recording is prepared.`);
|
|
111
107
|
this.logger.debug('Recording is prepared.');
|
|
112
108
|
} catch (error) {
|
|
113
109
|
this.logger.error(`${JSON.stringify(error)}.`);
|
|
110
|
+
return Promise.reject(error)
|
|
114
111
|
}
|
|
115
112
|
}
|
|
116
113
|
|
|
@@ -150,6 +147,7 @@ export class AudioRecordManager {
|
|
|
150
147
|
}
|
|
151
148
|
} catch (error) {
|
|
152
149
|
this.logger.error(`requestPermissionsFromUser failed, code is ${error?.code}, message is ${error?.message}.`);
|
|
150
|
+
return Promise.reject(error)
|
|
153
151
|
}
|
|
154
152
|
}
|
|
155
153
|
|
|
@@ -165,17 +163,19 @@ export class AudioRecordManager {
|
|
|
165
163
|
tokenId = appInfo.accessTokenId;
|
|
166
164
|
} catch (error) {
|
|
167
165
|
this.logger.error(`getBundleInfoForSelf failed, code is ${error?.code}, message is ${error?.message}.`);
|
|
166
|
+
return Promise.reject(error)
|
|
168
167
|
}
|
|
169
168
|
//检查应用是否被授予权限
|
|
170
169
|
try {
|
|
171
170
|
grantStatus = await atManager.checkAccessToken(tokenId, permission);
|
|
172
171
|
} catch (error) {
|
|
173
172
|
this.logger.error(`checkAccessToken failed, code is ${error?.code}, message is ${error?.message}.`);
|
|
173
|
+
return Promise.reject(error)
|
|
174
174
|
}
|
|
175
175
|
return grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
//格式化音频输入源
|
|
178
|
+
//格式化音频输入源
|
|
179
179
|
getAudioSourceFormatString(audioSource: number) {
|
|
180
180
|
switch (audioSource) {
|
|
181
181
|
case 0:
|
|
@@ -215,11 +215,12 @@ export class AudioRecordManager {
|
|
|
215
215
|
try {
|
|
216
216
|
if (this.avRecorder.state === AVRecorderStateEnum.STARTED || this.avRecorder.state === AVRecorderStateEnum.PAUSED) {
|
|
217
217
|
this.logger.error('Please call stopRecording before starting recording.');
|
|
218
|
-
return
|
|
218
|
+
return Promise.reject('Please call stopRecording before starting recording.')
|
|
219
|
+
|
|
219
220
|
}
|
|
220
221
|
if (this.avRecorder.state !== AVRecorderStateEnum.PREPARED) {
|
|
221
222
|
this.logger.error('Please call prepareRecording before starting recording.');
|
|
222
|
-
return
|
|
223
|
+
return Promise.reject('Please call prepareRecording before starting recording.')
|
|
223
224
|
}
|
|
224
225
|
await this.avRecorder.start();
|
|
225
226
|
this.isRecording = true;
|
|
@@ -230,6 +231,7 @@ export class AudioRecordManager {
|
|
|
230
231
|
this.startTimer();
|
|
231
232
|
} catch (error) {
|
|
232
233
|
this.logger.error(`startRecording failed, code is ${error?.code}, message is ${error?.message}.`);
|
|
234
|
+
return Promise.reject(error)
|
|
233
235
|
}
|
|
234
236
|
}
|
|
235
237
|
|
|
@@ -242,10 +244,11 @@ export class AudioRecordManager {
|
|
|
242
244
|
this.logger.debug('pause recording.');
|
|
243
245
|
} catch (error) {
|
|
244
246
|
this.logger.error(`pauseRecording failed, code is ${error?.code}, message is ${error?.message}.`);
|
|
247
|
+
return Promise.reject(error)
|
|
245
248
|
}
|
|
246
249
|
} else {
|
|
247
250
|
this.logger.error('It is reasonable to call pauseRecording only in the started state.');
|
|
248
|
-
return
|
|
251
|
+
return Promise.reject('It is reasonable to call pauseRecording only in the started state.')
|
|
249
252
|
}
|
|
250
253
|
}
|
|
251
254
|
|
|
@@ -258,10 +261,11 @@ export class AudioRecordManager {
|
|
|
258
261
|
this.logger.debug('resume recording.');
|
|
259
262
|
} catch (error) {
|
|
260
263
|
this.logger.error(`resumeRecording failed. code is ${error?.code}, message is ${error?.message}.`);
|
|
264
|
+
return Promise.reject(`resumeRecording failed. code is ${error?.code}, message is ${error?.message}.`)
|
|
261
265
|
}
|
|
262
266
|
} else {
|
|
263
267
|
this.logger.error('It is reasonable to call resumeRecording only in the paused state.');
|
|
264
|
-
return
|
|
268
|
+
return Promise.reject('It is reasonable to call resumeRecording only in the paused state.')
|
|
265
269
|
}
|
|
266
270
|
}
|
|
267
271
|
|
|
@@ -288,7 +292,7 @@ export class AudioRecordManager {
|
|
|
288
292
|
}
|
|
289
293
|
} else {
|
|
290
294
|
this.logger.error('It is reasonable to call stopRecording only in the started or paused state.');
|
|
291
|
-
return
|
|
295
|
+
return Promise.reject('It is reasonable to call stopRecording only in the started or paused state.')
|
|
292
296
|
}
|
|
293
297
|
}
|
|
294
298
|
|
package/harmony/audio.har
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-ohos/react-native-audio",
|
|
3
|
-
"version": "4.2.3-rc.
|
|
3
|
+
"version": "4.2.3-rc.2",
|
|
4
4
|
"description": "React Native extension for recording audio",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Joshua Sierles <joshua@diluvia.net> (https://github.com/jsierles)",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"@rnoh/react-native-harmony-cli": "npm:@react-native-oh/react-native-harmony-cli@^0.0.27"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
|
-
"registry": "https://registry.npmjs.org/",
|
|
34
33
|
"access": "public"
|
|
35
34
|
},
|
|
36
35
|
"nativePackage": true
|