@react-native-ohos/react-native-audio-recorder-player 3.6.12 → 3.6.13-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 CHANGED
@@ -1,6 +1,9 @@
1
1
  ## Changelogs
2
2
 
3
3
  ## 鸿蒙化Log
4
+ ### v3.6.13-beta.1
5
+ - fix: fix multiple-instance and repeated-click issues, bump version to 3.6.13-beta.1 [#52](https://gitcode.com/CPF-RN/rntpc_react-native-audio-recorder-player/pull/52)
6
+
4
7
  ### v3.6.12
5
8
  - release: @react-native-ohos/react-native-audio-recorder-player@3.6.12
6
9
  [#49](https://gitcode.com/CPF-RN/rntpc_react-native-audio-recorder-player/pull/49)
package/README.md CHANGED
@@ -193,7 +193,7 @@ ohpm install
193
193
 
194
194
  #### 在 entry 目录下的module.json5中添加权限
195
195
 
196
- 在`entry/src/main/module.json5`,添加:
196
+ 在`entry/src/main/module.json5`中添加:
197
197
 
198
198
  ```json
199
199
  "requestPermissions": [
@@ -770,7 +770,7 @@ this.audioRecorderPlayer.mmss(
770
770
 
771
771
  | Name | Description | Type | Required | Platform | HarmonyOS Support |
772
772
  | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | -------- | -------- | ----------------- |
773
- | `mmss` | 将秒转换为“分:秒”格式的字符串 | function(seconds:number): string | No | Android,iOS | yes |
773
+ | `mmss` | 将毫秒转换为“分:秒”格式的字符串 | function(seconds:number): string | No | Android,iOS | yes |
774
774
  | `mmssss` | 将毫秒转换为“分钟:秒:毫秒”格式的字符串 | function(milisecs:number): string | No | Android,iOS | yes |
775
775
  | `setSubscriptionDuration` | 设置录音器或播放器启动时的默认回调时间间隔。默认为 0.5,即 500 毫秒。| function(sec:number):Promise<string> | No | Android,iOS | yes |
776
776
  | `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.6.12';
4
+ export const HAR_VERSION = '3.6.13-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.6.12",
8
+ "version": "3.6.13-beta.1",
9
9
  "dependencies": {
10
10
  "@rnoh/react-native-openharmony": "file:../libs/react_native_openharmony-5.0.0.500.har"
11
11
  },
@@ -25,7 +25,7 @@ import { TurboModule, TurboModuleContext, } from '@rnoh/react-native-openharmony
25
25
  import { media } from '@kit.MediaKit';
26
26
  import type { AudioSet } from '.';
27
27
  import Recorder from './recorder/Recorder';
28
- import { AVRecorderState, defaultBitrate, defaultChannels, defaultSampleRate, RecordBackName, } from './recorder/types';
28
+ import { AVRecorderState, defaultBitrate, defaultChannels, defaultSampleRate, RecordBackName, processValue as recorderProcessValue } from './recorder/types';
29
29
  import AudioPlayer from './audioPlayer/AudioPlayer';
30
30
  import { AVPlayerState, EventTarget, playBackName, processValue, } from './audioPlayer/types';
31
31
  import { deviceInfo } from '@kit.BasicServicesKit';
@@ -150,7 +150,7 @@ export class RNAudioRecorderPlayerTurboModule extends TurboModule {
150
150
  meteringEnabled?: boolean,
151
151
  ): Promise<string> {
152
152
  if (this.isRecording()) {
153
- return Promise.reject(processValue.play);
153
+ return Promise.reject(recorderProcessValue.start);
154
154
  }
155
155
 
156
156
  if (!!!uri) {
@@ -199,7 +199,7 @@ export class RNAudioRecorderPlayerTurboModule extends TurboModule {
199
199
  this.removeRecordBackListener();
200
200
  return this.AVRecorderInstance.pauseRecordingProcess();
201
201
  }
202
- return Promise.reject(processValue.stateError);
202
+ return Promise.reject(recorderProcessValue.stateError);
203
203
  }
204
204
 
205
205
  /**
@@ -211,7 +211,7 @@ export class RNAudioRecorderPlayerTurboModule extends TurboModule {
211
211
  this.addRecordBackListener();
212
212
  return this.AVRecorderInstance.resumeRecordingProcess();
213
213
  }
214
- return Promise.reject(processValue.stateError);
214
+ return Promise.reject(recorderProcessValue.stateError);
215
215
  }
216
216
 
217
217
  /**
@@ -228,7 +228,7 @@ export class RNAudioRecorderPlayerTurboModule extends TurboModule {
228
228
  this.removeRecordBackListener();
229
229
  return this.AVRecorderInstance.stopRecordingProcess();
230
230
  }
231
- return Promise.reject(processValue.stateError);
231
+ return Promise.reject(recorderProcessValue.stateError);
232
232
  }
233
233
 
234
234
  /**
@@ -98,7 +98,7 @@ export default class Player {
98
98
  // start button process
99
99
  async startPlayeringProcess(url?: string, httpHeaders?: Record<string, string>): Promise<string> {
100
100
  Logger.debug(TAG, 'startPlayering called');
101
- if (this.isPlaying || this.PlayerState === AVPlayerState.paused) {
101
+ if (this.isPlaying || this.PlayerState === AVPlayerState.paused || this.PlayerState === AVPlayerState.initialized) {
102
102
  return;
103
103
  }
104
104
  try {
@@ -108,7 +108,7 @@ export default class Player {
108
108
  return this.playUrl;
109
109
  } catch (err) {
110
110
  Logger.error(TAG, `startPlayering fail code:${(err as BusinessError).code}`);
111
- this.stopPlayeringProcess();
111
+ await this.stopPlayeringProcess();
112
112
  return this.playUrl;
113
113
  }
114
114
  }
@@ -143,8 +143,8 @@ export default class Player {
143
143
  // stop button process
144
144
  async stopPlayeringProcess(): Promise<string> {
145
145
  Logger.debug(TAG, 'stopPlayering called');
146
- if (!this.isHandleState()) {
147
- return processValue.stateError;
146
+ if (!this.audioPlayer) {
147
+ return processValue.stop;
148
148
  }
149
149
  this.isPlaying = false;
150
150
  this.currentPosition = 0;
@@ -204,7 +204,7 @@ export default class Player {
204
204
 
205
205
  private async createAudioPlayer(): Promise<void> {
206
206
  if (this.audioPlayer) {
207
- this.stopPlayeringProcess();
207
+ await this.stopPlayeringProcess();
208
208
  }
209
209
  await media
210
210
  .createAVPlayer()
@@ -245,6 +245,7 @@ export default class Player {
245
245
  break;
246
246
  }
247
247
  case AVPlayerState.initialized: {
248
+ this.PlayerState = AVPlayerState.initialized;
248
249
  this.getDurationTime();
249
250
  this.prepareAudioPlayer();
250
251
  this.getCurrentPosition();
@@ -413,7 +414,7 @@ export default class Player {
413
414
 
414
415
  if (this.EventMap) {
415
416
  this.EventMap.clear()
416
- }
417
+ }
417
418
  }
418
419
  }
419
420
  }
@@ -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
@@ -409,10 +409,10 @@ class AudioRecorderPlayer {
409
409
 
410
410
  if (this._hasPaused) {
411
411
  this._hasPaused = false;
412
-
412
+
413
413
  return RNAudioRecorderPlayer.resumePlayer();
414
414
  }
415
-
415
+
416
416
  return 'Already playing';
417
417
  };
418
418
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-ohos/react-native-audio-recorder-player",
3
- "version": "3.6.12",
3
+ "version": "3.6.13-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",
@@ -33,7 +33,11 @@
33
33
  "record",
34
34
  "recorder",
35
35
  "player",
36
- "harmony"
36
+ "harmony",
37
+ "harmonyos",
38
+ "ohos",
39
+ "openharmony",
40
+ "rnoh"
37
41
  ],
38
42
  "files": [
39
43
  "src",
@@ -41,6 +45,7 @@
41
45
  "index.ts",
42
46
  "index.d.ts",
43
47
  "!build",
48
+ "README.md",
44
49
  "CHANGELOG.md"
45
50
  ],
46
51
  "author": "dooboolab",