@react-native-ohos/react-native-audio-recorder-player 3.7.2 → 3.7.3-beta.1
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/CHANGELOG.md +4 -0
- package/README.md +2 -2
- package/harmony/audio_recorder_player/BuildProfile.ets +1 -1
- package/harmony/audio_recorder_player/oh-package.json5 +1 -1
- package/harmony/audio_recorder_player/src/main/ets/RNAudioRecorderPlayerTurboModule.ts +5 -5
- package/harmony/audio_recorder_player/src/main/ets/audioPlayer/AudioPlayer.ts +7 -6
- package/harmony/audio_recorder_player/src/main/ets/recorder/Recorder.ts +3 -3
- package/harmony/audio_recorder_player.har +0 -0
- package/index.ts +2 -2
- package/package.json +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
## 鸿蒙化Log
|
|
4
|
+
- fix: fix multiple-instance and repeated-click issues, bump version to 3.7.3-beta.1 [#51](https://gitcode.com/CPF-RN/rntpc_react-native-audio-recorder-player/pull/51)
|
|
5
|
+
|
|
6
|
+
### v3.7.3-beta.1
|
|
7
|
+
|
|
4
8
|
### v3.7.2
|
|
5
9
|
- release:@react-native-ohos/react-native-audio-recorder-player@3.7.2 [#50](https://gitcode.com/CPF-RN/rntpc_react-native-audio-recorder-player/pull/50)
|
|
6
10
|
- fix:The problem of file not being overwritten when recording again with the same file name modified [#45](https://gitcode.com/CPF-RN/rntpc_react-native-audio-recorder-player/pull/45)
|
package/README.md
CHANGED
|
@@ -192,7 +192,7 @@ ohpm install
|
|
|
192
192
|
|
|
193
193
|
#### 在 entry 目录下的module.json5中添加权限
|
|
194
194
|
|
|
195
|
-
在`entry/src/main/module.json5
|
|
195
|
+
在`entry/src/main/module.json5`中添加:
|
|
196
196
|
|
|
197
197
|
```json
|
|
198
198
|
"requestPermissions": [
|
|
@@ -769,7 +769,7 @@ this.audioRecorderPlayer.mmss(
|
|
|
769
769
|
|
|
770
770
|
| Name | Description | Type | Required | Platform | HarmonyOS Support |
|
|
771
771
|
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | -------- | -------- | ----------------- |
|
|
772
|
-
| `mmss` |
|
|
772
|
+
| `mmss` | 将毫秒转换为“分:秒”格式的字符串 | function(seconds:number): string | No | Android,iOS | yes |
|
|
773
773
|
| `mmssss` | 将毫秒转换为“分钟:秒:毫秒”格式的字符串 | function(milisecs:number): string | No | Android,iOS | yes |
|
|
774
774
|
| `setSubscriptionDuration` | 设置录音器或播放器启动时的默认回调时间间隔。默认为 0.5,即 500 毫秒。| function(sec:number):Promise<string> | No | Android,iOS | yes |
|
|
775
775
|
| `addRecordBackListener` |从原生模块获取回调。将接收 currentPosition、currentMetering(如果在 startRecorder 中进行了配置)。 | function(callBack:(value:RecordBackType)=>void): void | No | Android,iOS | yes |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
|
3
3
|
*/
|
|
4
|
-
export const HAR_VERSION = '3.7.
|
|
4
|
+
export const HAR_VERSION = '3.7.3-beta.1';
|
|
5
5
|
export const BUILD_MODE_NAME = 'debug';
|
|
6
6
|
export const DEBUG = true;
|
|
7
7
|
export const TARGET_NAME = 'default';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "@react-native-ohos/react-native-audio-recorder-player",
|
|
6
6
|
"description": "",
|
|
7
7
|
"main": "index.ets",
|
|
8
|
-
"version": "3.7.
|
|
8
|
+
"version": "3.7.3-beta.1",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@rnoh/react-native-openharmony": "file:../../node_modules/@react-native-oh/react-native-harmony/harmony/react_native_openharmony.har"
|
|
11
11
|
},
|
|
@@ -26,7 +26,7 @@ import { AnyThreadTurboModule, AnyThreadTurboModuleContext } from '@rnoh/react-n
|
|
|
26
26
|
import { media } from '@kit.MediaKit';
|
|
27
27
|
import type { AudioSet } from '.';
|
|
28
28
|
import Recorder from './recorder/Recorder';
|
|
29
|
-
import { AVRecorderState, defaultBitrate, defaultChannels, defaultSampleRate, RecordBackName, } from './recorder/types';
|
|
29
|
+
import { AVRecorderState, defaultBitrate, defaultChannels, defaultSampleRate, RecordBackName, processValue as recorderProcessValue } from './recorder/types';
|
|
30
30
|
import AudioPlayer from './audioPlayer/AudioPlayer';
|
|
31
31
|
import { AVPlayerState, EventTarget, playBackName, processValue, } from './audioPlayer/types';
|
|
32
32
|
import deviceinfo from '@ohos.deviceInfo';
|
|
@@ -152,7 +152,7 @@ export class RNAudioRecorderPlayerTurboModule extends AnyThreadTurboModule {
|
|
|
152
152
|
meteringEnabled?: boolean,
|
|
153
153
|
): Promise<string> {
|
|
154
154
|
if (this.isRecording()) {
|
|
155
|
-
return Promise.reject(
|
|
155
|
+
return Promise.reject(recorderProcessValue.start);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
if (!!!uri) {
|
|
@@ -195,7 +195,7 @@ export class RNAudioRecorderPlayerTurboModule extends AnyThreadTurboModule {
|
|
|
195
195
|
this.removeRecordBackListener();
|
|
196
196
|
return this.AVRecorderInstance.pauseRecordingProcess();
|
|
197
197
|
}
|
|
198
|
-
return Promise.reject(
|
|
198
|
+
return Promise.reject(recorderProcessValue.stateError);
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
/**
|
|
@@ -207,7 +207,7 @@ export class RNAudioRecorderPlayerTurboModule extends AnyThreadTurboModule {
|
|
|
207
207
|
this.addRecordBackListener();
|
|
208
208
|
return this.AVRecorderInstance.resumeRecordingProcess();
|
|
209
209
|
}
|
|
210
|
-
return Promise.reject(
|
|
210
|
+
return Promise.reject(recorderProcessValue.stateError);
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
/**
|
|
@@ -224,7 +224,7 @@ export class RNAudioRecorderPlayerTurboModule extends AnyThreadTurboModule {
|
|
|
224
224
|
this.removeRecordBackListener();
|
|
225
225
|
return this.AVRecorderInstance.stopRecordingProcess();
|
|
226
226
|
}
|
|
227
|
-
return Promise.reject(
|
|
227
|
+
return Promise.reject(recorderProcessValue.stateError);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
/**
|
|
@@ -127,7 +127,7 @@ export default class Player {
|
|
|
127
127
|
// start button process
|
|
128
128
|
async startPlayeringProcess(url?: string, httpHeaders?: Record<string, string>): Promise<string> {
|
|
129
129
|
Logger.debug(TAG, 'startPlayering called');
|
|
130
|
-
if (this.isPlaying || this.PlayerState === AVPlayerState.paused) {
|
|
130
|
+
if (this.isPlaying || this.PlayerState === AVPlayerState.paused || this.PlayerState === AVPlayerState.initialized) {
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
133
|
try {
|
|
@@ -137,7 +137,7 @@ export default class Player {
|
|
|
137
137
|
return this.playUrl;
|
|
138
138
|
} catch (err) {
|
|
139
139
|
Logger.error(TAG, `startPlayering fail code:${(err as BusinessError).code}`);
|
|
140
|
-
this.stopPlayeringProcess();
|
|
140
|
+
await this.stopPlayeringProcess();
|
|
141
141
|
return this.playUrl;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -172,8 +172,8 @@ export default class Player {
|
|
|
172
172
|
// stop button process
|
|
173
173
|
async stopPlayeringProcess(): Promise<string> {
|
|
174
174
|
Logger.debug(TAG, 'stopPlayering called');
|
|
175
|
-
if (!this.
|
|
176
|
-
return processValue.
|
|
175
|
+
if (!this.audioPlayer) {
|
|
176
|
+
return processValue.stop;
|
|
177
177
|
}
|
|
178
178
|
this.isPlaying = false;
|
|
179
179
|
this.currentPosition = 0;
|
|
@@ -254,7 +254,7 @@ export default class Player {
|
|
|
254
254
|
|
|
255
255
|
private async createAudioPlayer(): Promise<void> {
|
|
256
256
|
if (this.audioPlayer) {
|
|
257
|
-
this.stopPlayeringProcess();
|
|
257
|
+
await this.stopPlayeringProcess();
|
|
258
258
|
}
|
|
259
259
|
await media
|
|
260
260
|
.createAVPlayer()
|
|
@@ -295,6 +295,7 @@ export default class Player {
|
|
|
295
295
|
break;
|
|
296
296
|
}
|
|
297
297
|
case AVPlayerState.initialized: {
|
|
298
|
+
this.PlayerState = AVPlayerState.initialized;
|
|
298
299
|
this.getDurationTime();
|
|
299
300
|
this.prepareAudioPlayer();
|
|
300
301
|
this.getCurrentPosition();
|
|
@@ -463,7 +464,7 @@ export default class Player {
|
|
|
463
464
|
|
|
464
465
|
if (this.EventMap) {
|
|
465
466
|
this.EventMap.clear()
|
|
466
|
-
}
|
|
467
|
+
}
|
|
467
468
|
}
|
|
468
469
|
}
|
|
469
470
|
}
|
|
@@ -250,8 +250,8 @@ export default class Recorder {
|
|
|
250
250
|
private async prepareAudioRecorder(): Promise<void> {
|
|
251
251
|
Logger.debug(TAG, 'case prepareAudioRecorder in');
|
|
252
252
|
await this.audioRecorder!.prepare(this.avConfig)
|
|
253
|
-
.then(() => {
|
|
254
|
-
this.audioRecorder!.start();
|
|
253
|
+
.then(async() => {
|
|
254
|
+
await this.audioRecorder!.start();
|
|
255
255
|
Logger.debug(TAG, 'case prepare AVRecorder called');
|
|
256
256
|
}, this.catchCallback)
|
|
257
257
|
.catch(this.catchCallback);
|
|
@@ -270,7 +270,7 @@ export default class Recorder {
|
|
|
270
270
|
if (this.audioRecorder) {
|
|
271
271
|
await this.audioRecorder.off(AVRecorderState.onStateChange);
|
|
272
272
|
await this.audioRecorder.off(AVRecorderState.error);
|
|
273
|
-
this.audioRecorder
|
|
273
|
+
await this.audioRecorder
|
|
274
274
|
.release()
|
|
275
275
|
.then(() => {
|
|
276
276
|
this.audioRecorder = undefined;
|
|
Binary file
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-ohos/react-native-audio-recorder-player",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.3-beta.1",
|
|
4
4
|
"description": "React Native Audio Recorder and Player.",
|
|
5
5
|
"homepage": "https://gitcode.com/CPF-RN/rntpc_react-native-audio-recorder-player",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -37,7 +37,11 @@
|
|
|
37
37
|
"record",
|
|
38
38
|
"recorder",
|
|
39
39
|
"player",
|
|
40
|
-
"harmony"
|
|
40
|
+
"harmony",
|
|
41
|
+
"harmonyos",
|
|
42
|
+
"ohos",
|
|
43
|
+
"openharmony",
|
|
44
|
+
"rnoh"
|
|
41
45
|
],
|
|
42
46
|
"files": [
|
|
43
47
|
"src",
|
|
@@ -45,6 +49,7 @@
|
|
|
45
49
|
"index.ts",
|
|
46
50
|
"index.d.ts",
|
|
47
51
|
"!build",
|
|
52
|
+
"README.md",
|
|
48
53
|
"CHANGELOG.md"
|
|
49
54
|
],
|
|
50
55
|
"author": "dooboolab",
|