@react-native-ohos/react-native-audio-recorder-player 3.7.1-beta.1 → 3.7.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.
Files changed (33) hide show
  1. package/LICENSE +20 -20
  2. package/README.OpenSource +10 -10
  3. package/README.md +822 -753
  4. package/harmony/audio_recorder_player/BuildProfile.ets +16 -16
  5. package/harmony/audio_recorder_player/LICENSE +21 -21
  6. package/harmony/audio_recorder_player/build-profile.json5 +28 -28
  7. package/harmony/audio_recorder_player/index.ets +27 -25
  8. package/harmony/audio_recorder_player/oh-package-lock.json5 +18 -0
  9. package/harmony/audio_recorder_player/oh-package.json5 +20 -20
  10. package/harmony/audio_recorder_player/src/main/cpp/CMakeLists.txt +7 -7
  11. package/harmony/audio_recorder_player/src/main/cpp/RNAudioRecorderPlayerPackage.h +48 -48
  12. package/harmony/audio_recorder_player/src/main/cpp/RNAudioRecorderPlayerTurboModule.cpp +90 -90
  13. package/harmony/audio_recorder_player/src/main/cpp/RNAudioRecorderPlayerTurboModule.h +35 -35
  14. package/harmony/audio_recorder_player/src/main/ets/{RNAudioRecorderPlayerPackage.ts → RNAudioRecorderPlayerPackage.ets} +48 -47
  15. package/harmony/audio_recorder_player/src/main/ets/RNAudioRecorderPlayerTurboModule.ts +324 -323
  16. package/harmony/audio_recorder_player/src/main/ets/audioPlayer/AudioPlayer.ts +464 -464
  17. package/harmony/audio_recorder_player/src/main/ets/audioPlayer/types.ts +45 -45
  18. package/harmony/audio_recorder_player/src/main/ets/index.ts +209 -209
  19. package/harmony/audio_recorder_player/src/main/ets/recorder/Recorder.ts +299 -299
  20. package/harmony/audio_recorder_player/src/main/ets/recorder/types.ts +61 -61
  21. package/harmony/audio_recorder_player/src/main/ets/utils/DateTimeUtils.ts +88 -88
  22. package/harmony/audio_recorder_player/src/main/ets/utils/Logger.ts +45 -45
  23. package/harmony/audio_recorder_player/src/main/ets/utils/SaveAudioAsset.ts +105 -105
  24. package/harmony/audio_recorder_player/src/main/module.json5 +9 -9
  25. package/harmony/audio_recorder_player/src/main/resources/base/element/string.json +8 -8
  26. package/harmony/audio_recorder_player/src/main/resources/base/media/ic_public_error.svg +9 -9
  27. package/harmony/audio_recorder_player/src/main/resources/en_US/element/string.json +8 -8
  28. package/harmony/audio_recorder_player/src/main/resources/zh_CN/element/string.json +8 -8
  29. package/harmony/audio_recorder_player/{ts.ts → ts.ets} +26 -26
  30. package/harmony/audio_recorder_player.har +0 -0
  31. package/index.ts +539 -539
  32. package/package.json +71 -60
  33. package/src/NativeAudioRecorderPlayerModule.ts +42 -42
@@ -1,61 +1,61 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- import media from '@ohos.multimedia.media';
8
-
9
- export const defaultBitrate: number = 48000;
10
-
11
- export const defaultSampleRate: number = 48000;
12
-
13
- export const defaultChannels: number = 2;
14
-
15
- export const defaultTimeOut: number = 200;
16
-
17
- export const TAG: string = 'Audio_Recorder';
18
-
19
- export const RecordBackName: string = 'rn-recordback';
20
-
21
- export const fdPath: string = 'fd://';
22
-
23
- export enum PERMISSIONS {
24
- MICROPHONE = 'ohos.permission.MICROPHONE',
25
- WRITE_MEDIA = 'ohos.permission.WRITE_MEDIA',
26
- READ_MEDIA = 'ohos.permission.READ_MEDIA',
27
- }
28
-
29
- export const avProfile: media.AVRecorderProfile = {
30
- audioBitrate: defaultBitrate, // set audioBitrate according to device ability
31
- audioChannels: defaultChannels, // set audioChannels, valid value 1-8
32
- audioCodec: media.CodecMimeType.AUDIO_AAC, // set audioCodec, AUDIO_AAC is the only choice
33
- audioSampleRate: defaultSampleRate, // set audioSampleRate according to device ability
34
- fileFormat: media.ContainerFormatType.CFT_MPEG_4A, // set fileFormat, for video is m4a
35
- };
36
-
37
- export const avConfig: media.AVRecorderConfig = {
38
- audioSourceType: media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
39
- profile: avProfile,
40
- url: fdPath,
41
- };
42
-
43
- export enum AVRecorderState {
44
- idle = 'idle',
45
- prepared = 'prepared',
46
- started = 'started',
47
- paused = 'paused',
48
- stopped = 'stopped',
49
- released = 'released',
50
- error = 'error',
51
- onStateChange = 'stateChange',
52
- }
53
-
54
- export enum processValue {
55
- start = 'Already recording.',
56
- pause = 'Already paused recording.',
57
- resume = 'Currently recording.',
58
- stop = 'Already stopped',
59
- NoPermissions = 'No permissions of recorder',
60
- stateError = 'current state is not allowed',
61
- }
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import media from '@ohos.multimedia.media';
8
+
9
+ export const defaultBitrate: number = 48000;
10
+
11
+ export const defaultSampleRate: number = 48000;
12
+
13
+ export const defaultChannels: number = 2;
14
+
15
+ export const defaultTimeOut: number = 200;
16
+
17
+ export const TAG: string = 'Audio_Recorder';
18
+
19
+ export const RecordBackName: string = 'rn-recordback';
20
+
21
+ export const fdPath: string = 'fd://';
22
+
23
+ export enum PERMISSIONS {
24
+ MICROPHONE = 'ohos.permission.MICROPHONE',
25
+ WRITE_MEDIA = 'ohos.permission.WRITE_MEDIA',
26
+ READ_MEDIA = 'ohos.permission.READ_MEDIA',
27
+ }
28
+
29
+ export const avProfile: media.AVRecorderProfile = {
30
+ audioBitrate: defaultBitrate, // set audioBitrate according to device ability
31
+ audioChannels: defaultChannels, // set audioChannels, valid value 1-8
32
+ audioCodec: media.CodecMimeType.AUDIO_AAC, // set audioCodec, AUDIO_AAC is the only choice
33
+ audioSampleRate: defaultSampleRate, // set audioSampleRate according to device ability
34
+ fileFormat: media.ContainerFormatType.CFT_MPEG_4A, // set fileFormat, for video is m4a
35
+ };
36
+
37
+ export const avConfig: media.AVRecorderConfig = {
38
+ audioSourceType: media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC,
39
+ profile: avProfile,
40
+ url: fdPath,
41
+ };
42
+
43
+ export enum AVRecorderState {
44
+ idle = 'idle',
45
+ prepared = 'prepared',
46
+ started = 'started',
47
+ paused = 'paused',
48
+ stopped = 'stopped',
49
+ released = 'released',
50
+ error = 'error',
51
+ onStateChange = 'stateChange',
52
+ }
53
+
54
+ export enum processValue {
55
+ start = 'Already recording.',
56
+ pause = 'Already paused recording.',
57
+ resume = 'Currently recording.',
58
+ stop = 'Already stopped',
59
+ NoPermissions = 'No permissions of recorder',
60
+ stateError = 'current state is not allowed',
61
+ }
@@ -1,88 +1,88 @@
1
- /*
2
- * Copyright (C) 2023 Huawei Device Co., Ltd.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- export default class DateTimeUtil {
17
- getTime(): string {
18
- const DATETIME = new Date();
19
- return this.concatTime(
20
- DATETIME.getHours(),
21
- DATETIME.getMinutes(),
22
- DATETIME.getSeconds(),
23
- );
24
- }
25
-
26
- getDate(): string {
27
- const DATETIME = new Date();
28
- return this.concatDate(
29
- DATETIME.getFullYear(),
30
- DATETIME.getMonth() + 1,
31
- DATETIME.getDate(),
32
- );
33
- }
34
-
35
- fill(value: number): string {
36
- return (value > 9 ? '' : '0') + value;
37
- }
38
-
39
- concatDate(year: number, month: number, date: number): string {
40
- return `${year}${month}${date}`;
41
- }
42
-
43
- concatTime(hour: number, minute: number, second: number): string {
44
- return `${this.fill(hour)}${this.fill(minute)}${this.fill(second)}`;
45
- }
46
- }
47
-
48
- export function getShownTimer(ms: number): string {
49
- let seconds: number = Math.round(ms / 1000);
50
- let sec: number | string = seconds % 60;
51
- let min: number | string = (seconds - sec) / 60;
52
- if (sec < 10) {
53
- sec = '0' + sec;
54
- }
55
- if (min < 10) {
56
- min = '0' + min;
57
- }
58
- return min + ':' + sec;
59
- }
60
-
61
- export function dateTime(t: number): string {
62
- let minute: number = Math.floor(t / 60) % 60;
63
- let m = minute < 10 ? '0' + minute : minute;
64
- let second: number = t % 60;
65
- let s = second < 10 ? '0' + second : second;
66
- return m + ':' + s;
67
- }
68
-
69
- export function getMMSSSS(milisecs: number): string {
70
- const secs = Math.floor(milisecs / 1000);
71
- const minutes = Math.floor(secs / 60);
72
- const seconds = secs % 60;
73
- const miliseconds = Math.floor((milisecs % 1000) / 10);
74
- return `${formatString(minutes)}:${formatString(
75
- seconds,
76
- )}:${formatString(miliseconds)}`;
77
- }
78
-
79
- export function getMMSS(milisecs: number): string {
80
- const secs = Math.floor(milisecs / 1000);
81
- const minutes = Math.floor(secs / 60);
82
- const seconds = secs % 60;
83
- return `${formatString(minutes)}:${formatString(seconds)}`;
84
- }
85
-
86
- function formatString(num: number): string {
87
- return `0${num}`.slice(-2);
88
- }
1
+ /*
2
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ export default class DateTimeUtil {
17
+ getTime(): string {
18
+ const DATETIME = new Date();
19
+ return this.concatTime(
20
+ DATETIME.getHours(),
21
+ DATETIME.getMinutes(),
22
+ DATETIME.getSeconds(),
23
+ );
24
+ }
25
+
26
+ getDate(): string {
27
+ const DATETIME = new Date();
28
+ return this.concatDate(
29
+ DATETIME.getFullYear(),
30
+ DATETIME.getMonth() + 1,
31
+ DATETIME.getDate(),
32
+ );
33
+ }
34
+
35
+ fill(value: number): string {
36
+ return (value > 9 ? '' : '0') + value;
37
+ }
38
+
39
+ concatDate(year: number, month: number, date: number): string {
40
+ return `${year}${month}${date}`;
41
+ }
42
+
43
+ concatTime(hour: number, minute: number, second: number): string {
44
+ return `${this.fill(hour)}${this.fill(minute)}${this.fill(second)}`;
45
+ }
46
+ }
47
+
48
+ export function getShownTimer(ms: number): string {
49
+ let seconds: number = Math.round(ms / 1000);
50
+ let sec: number | string = seconds % 60;
51
+ let min: number | string = (seconds - sec) / 60;
52
+ if (sec < 10) {
53
+ sec = '0' + sec;
54
+ }
55
+ if (min < 10) {
56
+ min = '0' + min;
57
+ }
58
+ return min + ':' + sec;
59
+ }
60
+
61
+ export function dateTime(t: number): string {
62
+ let minute: number = Math.floor(t / 60) % 60;
63
+ let m = minute < 10 ? '0' + minute : minute;
64
+ let second: number = t % 60;
65
+ let s = second < 10 ? '0' + second : second;
66
+ return m + ':' + s;
67
+ }
68
+
69
+ export function getMMSSSS(milisecs: number): string {
70
+ const secs = Math.floor(milisecs / 1000);
71
+ const minutes = Math.floor(secs / 60);
72
+ const seconds = secs % 60;
73
+ const miliseconds = Math.floor((milisecs % 1000) / 10);
74
+ return `${formatString(minutes)}:${formatString(
75
+ seconds,
76
+ )}:${formatString(miliseconds)}`;
77
+ }
78
+
79
+ export function getMMSS(milisecs: number): string {
80
+ const secs = Math.floor(milisecs / 1000);
81
+ const minutes = Math.floor(secs / 60);
82
+ const seconds = secs % 60;
83
+ return `${formatString(minutes)}:${formatString(seconds)}`;
84
+ }
85
+
86
+ function formatString(num: number): string {
87
+ return `0${num}`.slice(-2);
88
+ }
@@ -1,45 +1,45 @@
1
- /*
2
- * Copyright (c) 2023 Huawei Device Co., Ltd.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- import hilog from '@ohos.hilog';
17
-
18
- class Logger {
19
- private domain: number;
20
- private prefix: string;
21
- private format: string = '%{public}s, %{public}s';
22
-
23
- constructor(prefix: string) {
24
- this.prefix = prefix;
25
- this.domain = 0xff00;
26
- }
27
-
28
- debug(...args: string[]): void {
29
- hilog.debug(this.domain, this.prefix, this.format, args);
30
- }
31
-
32
- info(...args: string[]): void {
33
- hilog.info(this.domain, this.prefix, this.format, args);
34
- }
35
-
36
- warn(...args: string[]): void {
37
- hilog.warn(this.domain, this.prefix, this.format, args);
38
- }
39
-
40
- error(...args: string[]): void {
41
- hilog.error(this.domain, this.prefix, this.format, args);
42
- }
43
- }
44
-
45
- export default new Logger('AVRecorderSample');
1
+ /*
2
+ * Copyright (c) 2023 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ import hilog from '@ohos.hilog';
17
+
18
+ class Logger {
19
+ private domain: number;
20
+ private prefix: string;
21
+ private format: string = '%{public}s, %{public}s';
22
+
23
+ constructor(prefix: string) {
24
+ this.prefix = prefix;
25
+ this.domain = 0xff00;
26
+ }
27
+
28
+ debug(...args: string[]): void {
29
+ hilog.debug(this.domain, this.prefix, this.format, args);
30
+ }
31
+
32
+ info(...args: string[]): void {
33
+ hilog.info(this.domain, this.prefix, this.format, args);
34
+ }
35
+
36
+ warn(...args: string[]): void {
37
+ hilog.warn(this.domain, this.prefix, this.format, args);
38
+ }
39
+
40
+ error(...args: string[]): void {
41
+ hilog.error(this.domain, this.prefix, this.format, args);
42
+ }
43
+ }
44
+
45
+ export default new Logger('AVRecorderSample');
@@ -1,105 +1,105 @@
1
- /*
2
- * Copyright (C) 2023 Huawei Device Co., Ltd.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- import DateTimeUtil from './DateTimeUtils';
17
- import Logger from './Logger';
18
- import fs from '@ohos.file.fs';
19
- import { common } from '@kit.AbilityKit';
20
- import audio from '@ohos.multimedia.audio';
21
- import { uri } from '@kit.ArkTS';
22
- import { media } from '@kit.MediaKit';
23
-
24
- export default class SaveCameraAsset {
25
- public file: fs.File;
26
- private tag: string;
27
- private lastSaveTime: string = '';
28
- private saveIndex: number = 0;
29
- private audioManager: audio.AudioManager = audio.getAudioManager();
30
- private audioVolumeManager: audio.AudioVolumeManager =
31
- this.audioManager.getVolumeManager();
32
- private audioVolumeGroupManager =
33
- this.audioVolumeManager.getVolumeGroupManagerSync(
34
- audio.DEFAULT_VOLUME_GROUP_ID,
35
- );
36
- private fileName: string;
37
- private context: common.UIAbilityContext;
38
-
39
- constructor(tag: string, context: common.UIAbilityContext) {
40
- this.tag = tag;
41
- this.context = context;
42
- }
43
-
44
- public async createAudioFd(url?: string, fileFormat?: media.ContainerFormatType): Promise<number> {
45
- Logger.info(this.tag, 'get Recorder File Fd');
46
- const context = this.context as common.UIAbilityContext;
47
- let path = '';
48
- if (uri) {
49
- path = `${context.filesDir}/${url}`;
50
- this.fileName = url;
51
- if (url === 'DEFAULT') {
52
- path = `${context.filesDir}/${'sound.'}${fileFormat ? fileFormat : media.ContainerFormatType.CFT_MPEG_4A}`;
53
- this.fileName = `${'sound.'}${fileFormat ? fileFormat : media.ContainerFormatType.CFT_MPEG_4A}`;
54
- }
55
- } else {
56
- const mDateTimeUtil = new DateTimeUtil();
57
- const displayName = this.checkName(
58
- `REC_${mDateTimeUtil.getDate()}_${mDateTimeUtil.getTime()}.m4a`,
59
- );
60
- path = `${context.filesDir}/${displayName}`;
61
- this.fileName = displayName;
62
- }
63
-
64
- this.file = this.createOrOpen(path);
65
- return this.file?.fd ?? 0;
66
- }
67
-
68
- public getFilePath() {
69
- return this.file.path;
70
- }
71
-
72
- public getFileName() {
73
- return this.fileName;
74
- }
75
-
76
- public mediaIsMute(): boolean {
77
- return this.audioVolumeGroupManager.isMuteSync(audio.AudioVolumeType.MEDIA);
78
- }
79
-
80
- public closeFile() {
81
- fs.closeSync(this.file);
82
- }
83
-
84
- private createOrOpen(path: string): fs.File {
85
- const isExist = fs.accessSync(path);
86
- let file: fs.File;
87
- if (isExist) {
88
- file = fs.openSync(path, fs.OpenMode.READ_WRITE);
89
- } else {
90
- file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
91
- }
92
- return file;
93
- }
94
-
95
- private checkName(name: string): string {
96
- if (this.lastSaveTime == name) {
97
- this.saveIndex += 1;
98
- return `${name}_${this.saveIndex}`;
99
- }
100
- this.lastSaveTime = name;
101
- this.saveIndex = 0;
102
- Logger.info(this.tag, 'get Recorder File name is: ' + name);
103
- return name;
104
- }
105
- }
1
+ /*
2
+ * Copyright (C) 2023 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ import DateTimeUtil from './DateTimeUtils';
17
+ import Logger from './Logger';
18
+ import fs from '@ohos.file.fs';
19
+ import { common } from '@kit.AbilityKit';
20
+ import audio from '@ohos.multimedia.audio';
21
+ import { uri } from '@kit.ArkTS';
22
+ import { media } from '@kit.MediaKit';
23
+
24
+ export default class SaveCameraAsset {
25
+ public file: fs.File;
26
+ private tag: string;
27
+ private lastSaveTime: string = '';
28
+ private saveIndex: number = 0;
29
+ private audioManager: audio.AudioManager = audio.getAudioManager();
30
+ private audioVolumeManager: audio.AudioVolumeManager =
31
+ this.audioManager.getVolumeManager();
32
+ private audioVolumeGroupManager =
33
+ this.audioVolumeManager.getVolumeGroupManagerSync(
34
+ audio.DEFAULT_VOLUME_GROUP_ID,
35
+ );
36
+ private fileName: string;
37
+ private context: common.UIAbilityContext;
38
+
39
+ constructor(tag: string, context: common.UIAbilityContext) {
40
+ this.tag = tag;
41
+ this.context = context;
42
+ }
43
+
44
+ public async createAudioFd(url?: string, fileFormat?: media.ContainerFormatType): Promise<number> {
45
+ Logger.info(this.tag, 'get Recorder File Fd');
46
+ const context = this.context as common.UIAbilityContext;
47
+ let path = '';
48
+ if (uri) {
49
+ path = `${context.filesDir}/${url}`;
50
+ this.fileName = url;
51
+ if (url === 'DEFAULT') {
52
+ path = `${context.filesDir}/${'sound.'}${fileFormat ? fileFormat : media.ContainerFormatType.CFT_MPEG_4A}`;
53
+ this.fileName = `${'sound.'}${fileFormat ? fileFormat : media.ContainerFormatType.CFT_MPEG_4A}`;
54
+ }
55
+ } else {
56
+ const mDateTimeUtil = new DateTimeUtil();
57
+ const displayName = this.checkName(
58
+ `REC_${mDateTimeUtil.getDate()}_${mDateTimeUtil.getTime()}.m4a`,
59
+ );
60
+ path = `${context.filesDir}/${displayName}`;
61
+ this.fileName = displayName;
62
+ }
63
+
64
+ this.file = this.createOrOpen(path);
65
+ return this.file?.fd ?? 0;
66
+ }
67
+
68
+ public getFilePath() {
69
+ return this.file.path;
70
+ }
71
+
72
+ public getFileName() {
73
+ return this.fileName;
74
+ }
75
+
76
+ public mediaIsMute(): boolean {
77
+ return this.audioVolumeGroupManager.isMuteSync(audio.AudioVolumeType.MEDIA);
78
+ }
79
+
80
+ public closeFile() {
81
+ fs.closeSync(this.file);
82
+ }
83
+
84
+ private createOrOpen(path: string): fs.File {
85
+ const isExist = fs.accessSync(path);
86
+ let file: fs.File;
87
+ if (isExist) {
88
+ file = fs.openSync(path, fs.OpenMode.READ_WRITE);
89
+ } else {
90
+ file = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
91
+ }
92
+ return file;
93
+ }
94
+
95
+ private checkName(name: string): string {
96
+ if (this.lastSaveTime == name) {
97
+ this.saveIndex += 1;
98
+ return `${name}_${this.saveIndex}`;
99
+ }
100
+ this.lastSaveTime = name;
101
+ this.saveIndex = 0;
102
+ Logger.info(this.tag, 'get Recorder File name is: ' + name);
103
+ return name;
104
+ }
105
+ }
@@ -1,9 +1,9 @@
1
- {
2
- "module": {
3
- "name": "audio_recorder_player",
4
- "type": "har",
5
- "deviceTypes": [
6
- "default"
7
- ],
8
- }
9
- }
1
+ {
2
+ "module": {
3
+ "name": "audio_recorder_player",
4
+ "type": "har",
5
+ "deviceTypes": [
6
+ "default"
7
+ ],
8
+ }
9
+ }
@@ -1,8 +1,8 @@
1
- {
2
- "string": [
3
- {
4
- "name": "page_show",
5
- "value": "page from npm package"
6
- }
7
- ]
8
- }
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from npm package"
6
+ }
7
+ ]
8
+ }
@@ -1,10 +1,10 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 24 24" version="1.1">
3
- <!-- Generator: Sketch 63.1 (92452) - https://sketch.com -->
4
- <title>Public/ic_public_error</title>
5
- <desc>Created with Sketch.</desc>
6
- <g id="_Public/ic_public_error" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
7
- <circle id="_colorError" fill="#E84026" cx="12" cy="12" r="11"/>
8
- <path d="M12,15.5 C12.6903125,15.5 13.25,16.0596875 13.25,16.75 C13.25,17.4403125 12.6903125,18 12,18 C11.3096875,18 10.75,17.4403125 10.75,16.75 C10.75,16.0596875 11.3096875,15.5 12,15.5 Z M12,6 C12.6414582,6 13.1614628,6.5200046 13.1614628,7.16146279 C13.1614628,7.18988207 13.1604197,7.21829177 13.1583357,7.24663453 L12.6708322,13.8766827 C12.6449936,14.2280877 12.3523536,14.5 12,14.5 C11.6476464,14.5 11.3550064,14.2280877 11.3291678,13.8766827 L10.8416643,7.24663453 C10.7946252,6.60690339 11.2750971,6.05016615 11.9148283,6.00312709 C11.943171,6.00104307 11.9715807,6 12,6 Z" id="_形状结合" fill="#FFFFFF"/>
9
- </g>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 24 24" version="1.1">
3
+ <!-- Generator: Sketch 63.1 (92452) - https://sketch.com -->
4
+ <title>Public/ic_public_error</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <g id="_Public/ic_public_error" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
7
+ <circle id="_colorError" fill="#E84026" cx="12" cy="12" r="11"/>
8
+ <path d="M12,15.5 C12.6903125,15.5 13.25,16.0596875 13.25,16.75 C13.25,17.4403125 12.6903125,18 12,18 C11.3096875,18 10.75,17.4403125 10.75,16.75 C10.75,16.0596875 11.3096875,15.5 12,15.5 Z M12,6 C12.6414582,6 13.1614628,6.5200046 13.1614628,7.16146279 C13.1614628,7.18988207 13.1604197,7.21829177 13.1583357,7.24663453 L12.6708322,13.8766827 C12.6449936,14.2280877 12.3523536,14.5 12,14.5 C11.6476464,14.5 11.3550064,14.2280877 11.3291678,13.8766827 L10.8416643,7.24663453 C10.7946252,6.60690339 11.2750971,6.05016615 11.9148283,6.00312709 C11.943171,6.00104307 11.9715807,6 12,6 Z" id="_形状结合" fill="#FFFFFF"/>
9
+ </g>
10
10
  </svg>