Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
bd600bb2
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
bd600bb2
编写于
9月 01, 2023
作者:
O
openharmony_ci
提交者:
Gitee
9月 01, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23664 鸿蒙指南文档ArkTS适配
Merge pull request !23664 from shuboxu/master
上级
32fac733
53e0f638
变更
2
展开全部
显示空白变更内容
内联
并排
Showing
2 changed file
with
238 addition
and
241 deletion
+238
-241
en/application-dev/reference/apis/js-apis-media.md
en/application-dev/reference/apis/js-apis-media.md
+119
-121
zh-cn/application-dev/reference/apis/js-apis-media.md
zh-cn/application-dev/reference/apis/js-apis-media.md
+119
-120
未找到文件。
en/application-dev/reference/apis/js-apis-media.md
浏览文件 @
bd600bb2
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-media.md
浏览文件 @
bd600bb2
...
...
@@ -16,7 +16,7 @@
## 导入模块
```
j
s
```
t
s
import
media
from
'
@ohos.multimedia.media
'
;
```
...
...
@@ -121,10 +121,10 @@ createAVRecorder(callback: AsyncCallback\<AVRecorder>): void
**示例:**
```
j
s
let
avRecorder
;
```
t
s
let
avRecorder
:
media
.
AVRecorder
;
media
.
createAVRecorder
((
error
,
r
ecorder
)
=>
{
media
.
createAVRecorder
((
error
:
BusinessError
,
recorder
:
media
.
AVR
ecorder
)
=>
{
if
(
recorder
!=
null
)
{
avRecorder
=
recorder
;
console
.
info
(
'
createAVRecorder success
'
);
...
...
@@ -159,17 +159,17 @@ createAVRecorder(): Promise\<AVRecorder>
**示例:**
```
j
s
let
avRecorder
;
```
t
s
let
avRecorder
:
media
.
AVRecorder
;
media
.
createAVRecorder
().
then
((
recorder
)
=>
{
media
.
createAVRecorder
().
then
((
recorder
:
media
.
AVRecorder
)
=>
{
if
(
recorder
!=
null
)
{
avRecorder
=
recorder
;
console
.
info
(
'
createAVRecorder success
'
);
}
else
{
console
.
error
(
'
createAVRecorder fail
'
);
}
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Error
)
=>
{
console
.
error
(
`createAVRecorder catchCallback, error message:
${
error
.
message
}
`
);
});
```
...
...
@@ -201,10 +201,10 @@ createVideoRecorder(callback: AsyncCallback\<VideoRecorder>): void
**示例:**
```
j
s
let
videoRecorder
;
```
t
s
let
videoRecorder
:
media
.
VideoRecorder
;
media
.
createVideoRecorder
((
error
,
video
)
=>
{
media
.
createVideoRecorder
((
error
:
BusinessError
,
video
:
media
.
VideoRecorder
)
=>
{
if
(
video
!=
null
)
{
videoRecorder
=
video
;
console
.
info
(
'
video createVideoRecorder success
'
);
...
...
@@ -241,17 +241,17 @@ createVideoRecorder(): Promise\<VideoRecorder>
**示例:**
```
j
s
let
videoRecorder
;
```
t
s
let
videoRecorder
:
media
.
VideoRecorder
;
media
.
createVideoRecorder
().
then
((
video
)
=>
{
media
.
createVideoRecorder
().
then
((
video
:
media
.
VideoRecorder
)
=>
{
if
(
video
!=
null
)
{
videoRecorder
=
video
;
console
.
info
(
'
video createVideoRecorder success
'
);
}
else
{
console
.
error
(
'
video createVideoRecorder fail
'
);
}
}).
catch
((
error
)
=>
{
}).
catch
((
error
:
Error
)
=>
{
console
.
error
(
`video catchCallback, error message:
${
error
.
message
}
`
);
});
```
...
...
@@ -1766,9 +1766,9 @@ prepare(config: AVRecorderConfig, callback: AsyncCallback\<void>): void
**示例:**
```
j
s
```
t
s
// 配置参数以实际硬件设备支持的范围为准
let
AVRecorderProfile
=
{
let
AVRecorderProfile
:
media
.
AVRecorderProfile
=
{
audioBitrate
:
48000
,
audioChannels
:
2
,
audioCodec
:
media
.
CodecMimeType
.
AUDIO_AAC
,
...
...
@@ -1780,7 +1780,7 @@ let AVRecorderProfile = {
videoFrameHeight
:
480
,
videoFrameRate
:
30
}
let
AVRecorderConfig
=
{
let
AVRecorderConfig
:
media
.
AVRecorderConfig
=
{
audioSourceType
:
media
.
AudioSourceType
.
AUDIO_SOURCE_TYPE_MIC
,
videoSourceType
:
media
.
VideoSourceType
.
VIDEO_SOURCE_TYPE_SURFACE_YUV
,
profile
:
AVRecorderProfile
,
...
...
@@ -1789,7 +1789,7 @@ let AVRecorderConfig = {
location
:
{
latitude
:
30
,
longitude
:
130
}
}
avRecorder
.
prepare
(
AVRecorderConfig
,
(
err
)
=>
{
avRecorder
.
prepare
(
AVRecorderConfig
,
(
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
prepare success
'
);
}
else
{
...
...
@@ -1837,9 +1837,9 @@ prepare(config: AVRecorderConfig): Promise\<void>
**示例:**
```
j
s
```
t
s
// 配置参数以实际硬件设备支持的范围为准
let
AVRecorderProfile
=
{
let
AVRecorderProfile
:
media
.
AVRecorderProfile
=
{
audioBitrate
:
48000
,
audioChannels
:
2
,
audioCodec
:
media
.
CodecMimeType
.
AUDIO_AAC
,
...
...
@@ -1851,7 +1851,7 @@ let AVRecorderProfile = {
videoFrameHeight
:
480
,
videoFrameRate
:
30
}
let
AVRecorderConfig
=
{
let
AVRecorderConfig
:
media
.
AVRecorderConfig
=
{
audioSourceType
:
media
.
AudioSourceType
.
AUDIO_SOURCE_TYPE_MIC
,
videoSourceType
:
media
.
VideoSourceType
.
VIDEO_SOURCE_TYPE_SURFACE_YUV
,
profile
:
AVRecorderProfile
,
...
...
@@ -1862,10 +1862,9 @@ let AVRecorderConfig = {
avRecorder
.
prepare
(
AVRecorderConfig
).
then
(()
=>
{
console
.
info
(
'
prepare success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
prepare failed and catch error is
'
+
err
.
message
);
});
```
### getInputSurface<sup>9+</sup><a name=avrecorder_getinputsurface></a>
...
...
@@ -1898,10 +1897,10 @@ getInputSurface(callback: AsyncCallback\<string>): void
**示例:**
```
j
s
let
surfaceID
=
null
;
// 该surfaceID用于传递给相机接口创造videoOutput
```
t
s
let
surfaceID
:
string
;
// 该surfaceID用于传递给相机接口创造videoOutput
avRecorder
.
getInputSurface
((
err
,
surfaceId
)
=>
{
avRecorder
.
getInputSurface
((
err
:
BusinessError
,
surfaceId
:
string
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
getInputSurface success
'
);
surfaceID
=
surfaceId
;
...
...
@@ -1942,13 +1941,13 @@ getInputSurface(): Promise\<string>
**示例:**
```
j
s
let
surfaceID
=
null
;
// 该surfaceID用于传递给相机接口创造videoOutput
```
t
s
let
surfaceID
:
string
;
// 该surfaceID用于传递给相机接口创造videoOutput
avRecorder
.
getInputSurface
().
then
((
surfaceId
)
=>
{
avRecorder
.
getInputSurface
().
then
((
surfaceId
:
string
)
=>
{
console
.
info
(
'
getInputSurface success
'
);
surfaceID
=
surfaceId
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
getInputSurface failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -1981,8 +1980,8 @@ start(callback: AsyncCallback\<void>): void
**示例:**
```
j
s
avRecorder
.
start
((
err
)
=>
{
```
t
s
avRecorder
.
start
((
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
start AVRecorder success
'
);
}
else
{
...
...
@@ -2019,10 +2018,10 @@ start(): Promise\<void>
**示例:**
```
j
s
```
t
s
avRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
start AVRecorder success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
start AVRecorder failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -2055,8 +2054,8 @@ pause(callback: AsyncCallback\<void>): void
**示例:**
```
j
s
avRecorder
.
pause
((
err
)
=>
{
```
t
s
avRecorder
.
pause
((
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
pause AVRecorder success
'
);
}
else
{
...
...
@@ -2093,10 +2092,10 @@ pause(): Promise\<void>
**示例:**
```
j
s
```
t
s
avRecorder
.
pause
().
then
(()
=>
{
console
.
info
(
'
pause AVRecorder success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
pause AVRecorder failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -2129,8 +2128,8 @@ resume(callback: AsyncCallback\<void>): void
**示例:**
```
j
s
avRecorder
.
resume
((
err
)
=>
{
```
t
s
avRecorder
.
resume
((
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
resume AVRecorder success
'
);
}
else
{
...
...
@@ -2167,10 +2166,10 @@ resume(): Promise\<void>
**示例:**
```
j
s
```
t
s
avRecorder
.
resume
().
then
(()
=>
{
console
.
info
(
'
resume AVRecorder success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
resume AVRecorder failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -2205,8 +2204,8 @@ stop(callback: AsyncCallback\<void>): void
**示例:**
```
j
s
avRecorder
.
stop
((
err
)
=>
{
```
t
s
avRecorder
.
stop
((
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
stop AVRecorder success
'
);
}
else
{
...
...
@@ -2245,10 +2244,10 @@ stop(): Promise\<void>
**示例:**
```
j
s
```
t
s
avRecorder
.
stop
().
then
(()
=>
{
console
.
info
(
'
stop AVRecorder success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
stop AVRecorder failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -2280,8 +2279,8 @@ reset(callback: AsyncCallback\<void>): void
**示例:**
```
j
s
avRecorder
.
reset
((
err
)
=>
{
```
t
s
avRecorder
.
reset
((
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
reset AVRecorder success
'
);
}
else
{
...
...
@@ -2317,10 +2316,10 @@ reset(): Promise\<void>
**示例:**
```
j
s
```
t
s
avRecorder
.
reset
().
then
(()
=>
{
console
.
info
(
'
reset AVRecorder success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
reset AVRecorder failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -2351,8 +2350,8 @@ release(callback: AsyncCallback\<void>): void
**示例:**
```
j
s
avRecorder
.
release
((
err
)
=>
{
```
t
s
avRecorder
.
release
((
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
release AVRecorder success
'
);
}
else
{
...
...
@@ -2387,10 +2386,10 @@ release(): Promise\<void>
**示例:**
```
j
s
```
t
s
avRecorder
.
release
().
then
(()
=>
{
console
.
info
(
'
release AVRecorder success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
release AVRecorder failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -2412,8 +2411,8 @@ on(type: 'stateChange', callback: (state: AVRecorderState, reason: StateChangeRe
**示例:**
```
j
s
avRecorder
.
on
(
'
stateChange
'
,
async
(
state
,
r
eason
)
=>
{
```
t
s
avRecorder
.
on
(
'
stateChange
'
,
async
(
state
:
media
.
AVRecorderState
,
reason
:
media
.
StateChangeR
eason
)
=>
{
console
.
info
(
'
case state has changed, new state is :
'
+
state
+
'
,and new reason is :
'
+
reason
);
});
```
...
...
@@ -2434,7 +2433,7 @@ off(type: 'stateChange'): void
**示例:**
```
j
s
```
t
s
avRecorder
.
off
(
'
stateChange
'
);
```
...
...
@@ -2466,8 +2465,8 @@ on(type: 'error', callback: ErrorCallback): void
**示例:**
```
j
s
avRecorder
.
on
(
'
error
'
,
(
err
)
=>
{
```
t
s
avRecorder
.
on
(
'
error
'
,
(
err
:
BusinessError
)
=>
{
console
.
error
(
'
case avRecorder.on(error) called, errMessage is
'
+
err
.
message
);
});
```
...
...
@@ -2497,7 +2496,7 @@ off(type: 'error'): void
**示例:**
```
j
s
```
t
s
avRecorder
.
off
(
'
error
'
);
```
...
...
@@ -2646,9 +2645,9 @@ prepare(config: VideoRecorderConfig, callback: AsyncCallback\<void>): void;
**示例:**
```
j
s
```
t
s
// 配置参数以实际硬件设备支持的范围为准
let
videoProfile
=
{
let
videoProfile
:
media
.
VideoRecorderProfile
=
{
audioBitrate
:
48000
,
audioChannels
:
2
,
audioCodec
:
'
audio/mp4a-latm
'
,
...
...
@@ -2661,7 +2660,7 @@ let videoProfile = {
videoFrameRate
:
30
}
let
videoConfig
=
{
let
videoConfig
:
media
.
VideoRecorderConfig
=
{
audioSourceType
:
1
,
videoSourceType
:
0
,
profile
:
videoProfile
,
...
...
@@ -2671,7 +2670,7 @@ let videoConfig = {
}
// asyncallback
videoRecorder
.
prepare
(
videoConfig
,
(
err
)
=>
{
videoRecorder
.
prepare
(
videoConfig
,
(
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
prepare success
'
);
}
else
{
...
...
@@ -2717,9 +2716,9 @@ prepare(config: VideoRecorderConfig): Promise\<void>;
**示例:**
```
j
s
```
t
s
// 配置参数以实际硬件设备支持的范围为准
let
videoProfile
=
{
let
videoProfile
:
media
.
VideoRecorderProfile
=
{
audioBitrate
:
48000
,
audioChannels
:
2
,
audioCodec
:
'
audio/mp4a-latm
'
,
...
...
@@ -2732,7 +2731,7 @@ let videoProfile = {
videoFrameRate
:
30
}
let
videoConfig
=
{
let
videoConfig
:
media
.
VideoRecorderConfig
=
{
audioSourceType
:
1
,
videoSourceType
:
0
,
profile
:
videoProfile
,
...
...
@@ -2744,7 +2743,7 @@ let videoConfig = {
// promise
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
prepare success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
prepare failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -2781,10 +2780,10 @@ getInputSurface(callback: AsyncCallback\<string>): void;
**示例:**
```
j
s
```
t
s
// asyncallback
let
surfaceID
=
null
;
// 传递给外界的surfaceID
videoRecorder
.
getInputSurface
((
err
,
surfaceId
)
=>
{
let
surfaceID
:
string
;
// 传递给外界的surfaceID
videoRecorder
.
getInputSurface
((
err
:
BusinessError
,
surfaceId
:
string
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
getInputSurface success
'
);
surfaceID
=
surfaceId
;
...
...
@@ -2826,13 +2825,13 @@ getInputSurface(): Promise\<string>;
**示例:**
```
j
s
```
t
s
// promise
let
surfaceID
=
null
;
// 传递给外界的surfaceID
videoRecorder
.
getInputSurface
().
then
((
surfaceId
)
=>
{
let
surfaceID
:
string
;
// 传递给外界的surfaceID
videoRecorder
.
getInputSurface
().
then
((
surfaceId
:
string
)
=>
{
console
.
info
(
'
getInputSurface success
'
);
surfaceID
=
surfaceId
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
getInputSurface failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -2867,9 +2866,9 @@ start(callback: AsyncCallback\<void>): void;
**示例:**
```
j
s
```
t
s
// asyncallback
videoRecorder
.
start
((
err
)
=>
{
videoRecorder
.
start
((
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
start videorecorder success
'
);
}
else
{
...
...
@@ -2908,11 +2907,11 @@ start(): Promise\<void>;
**示例:**
```
j
s
```
t
s
// promise
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
start videorecorder success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
start videorecorder failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -2947,9 +2946,9 @@ pause(callback: AsyncCallback\<void>): void;
**示例:**
```
j
s
```
t
s
// asyncallback
videoRecorder
.
pause
((
err
)
=>
{
videoRecorder
.
pause
((
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
pause videorecorder success
'
);
}
else
{
...
...
@@ -2988,11 +2987,11 @@ pause(): Promise\<void>;
**示例:**
```
j
s
```
t
s
// promise
videoRecorder
.
pause
().
then
(()
=>
{
console
.
info
(
'
pause videorecorder success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
pause videorecorder failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -3025,9 +3024,9 @@ resume(callback: AsyncCallback\<void>): void;
**示例:**
```
j
s
```
t
s
// asyncallback
videoRecorder
.
resume
((
err
)
=>
{
videoRecorder
.
resume
((
err
:
Error
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
resume videorecorder success
'
);
}
else
{
...
...
@@ -3064,11 +3063,11 @@ resume(): Promise\<void>;
**示例:**
```
j
s
```
t
s
// promise
videoRecorder
.
resume
().
then
(()
=>
{
console
.
info
(
'
resume videorecorder success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
resume videorecorder failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -3103,9 +3102,9 @@ stop(callback: AsyncCallback\<void>): void;
**示例:**
```
j
s
```
t
s
// asyncallback
videoRecorder
.
stop
((
err
)
=>
{
videoRecorder
.
stop
((
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
stop videorecorder success
'
);
}
else
{
...
...
@@ -3144,11 +3143,11 @@ stop(): Promise\<void>;
**示例:**
```
j
s
```
t
s
// promise
videoRecorder
.
stop
().
then
(()
=>
{
console
.
info
(
'
stop videorecorder success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
stop videorecorder failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -3179,9 +3178,9 @@ release(callback: AsyncCallback\<void>): void;
**示例:**
```
j
s
```
t
s
// asyncallback
videoRecorder
.
release
((
err
)
=>
{
videoRecorder
.
release
((
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
release videorecorder success
'
);
}
else
{
...
...
@@ -3216,11 +3215,11 @@ release(): Promise\<void>;
**示例:**
```
j
s
```
t
s
// promise
videoRecorder
.
release
().
then
(()
=>
{
console
.
info
(
'
release videorecorder success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
release videorecorder failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -3254,9 +3253,9 @@ reset(callback: AsyncCallback\<void>): void;
**示例:**
```
j
s
```
t
s
// asyncallback
videoRecorder
.
reset
((
err
)
=>
{
videoRecorder
.
reset
((
err
:
BusinessError
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
reset videorecorder success
'
);
}
else
{
...
...
@@ -3294,11 +3293,11 @@ reset(): Promise\<void>;
**示例:**
```
j
s
```
t
s
// promise
videoRecorder
.
reset
().
then
(()
=>
{
console
.
info
(
'
reset videorecorder success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
Error
)
=>
{
console
.
error
(
'
reset videorecorder failed and catch error is
'
+
err
.
message
);
});
```
...
...
@@ -3329,9 +3328,9 @@ on(type: 'error', callback: ErrorCallback): void
**示例:**
```
j
s
```
t
s
// 当获取videoRecordState接口出错时通过此订阅事件上报
videoRecorder
.
on
(
'
error
'
,
(
error
)
=>
{
// 设置'error'事件回调
videoRecorder
.
on
(
'
error
'
,
(
error
:
Error
)
=>
{
// 设置'error'事件回调
console
.
error
(
`audio error called, error:
${
error
}
`
);
})
```
...
...
@@ -3503,7 +3502,7 @@ createAudioRecorder(): AudioRecorder
**示例:**
```
js
let
audioRecorder
=
media
.
createAudioRecorder
();
let
audioRecorder
:
media
.
AudioRecorder
=
media
.
createAudioRecorder
();
```
## MediaErrorCode<sup>(deprecated)</sup><a name=mediaerrorcode></a>
...
...
@@ -4767,8 +4766,8 @@ prepare(config: AudioRecorderConfig): void
**示例:**
```
j
s
let
audioRecorderConfig
=
{
```
t
s
let
audioRecorderConfig
:
media
.
AudioRecorderConfig
=
{
audioEncoder
:
media
.
AudioEncoder
.
AAC_LC
,
audioEncodeBitRate
:
22050
,
audioSampleRate
:
22050
,
...
...
@@ -4794,7 +4793,7 @@ start(): void
**示例:**
```
j
s
```
t
s
audioRecorder
.
on
(
'
start
'
,
()
=>
{
//设置'start'事件回调
console
.
log
(
'
audio recorder start success
'
);
});
...
...
@@ -4811,7 +4810,7 @@ pause():void
**示例:**
```
j
s
```
t
s
audioRecorder
.
on
(
'
pause
'
,
()
=>
{
//设置'pause'事件回调
console
.
log
(
'
audio recorder pause success
'
);
});
...
...
@@ -4828,7 +4827,7 @@ resume():void
**示例:**
```
j
s
```
t
s
audioRecorder
.
on
(
'
resume
'
,
()
=>
{
//设置'resume'事件回调
console
.
log
(
'
audio recorder resume success
'
);
});
...
...
@@ -4845,7 +4844,7 @@ stop(): void
**示例:**
```
j
s
```
t
s
audioRecorder
.
on
(
'
stop
'
,
()
=>
{
//设置'stop'事件回调
console
.
log
(
'
audio recorder stop success
'
);
});
...
...
@@ -4862,7 +4861,7 @@ release(): void
**示例:**
```
j
s
```
t
s
audioRecorder
.
on
(
'
release
'
,
()
=>
{
//设置'release'事件回调
console
.
log
(
'
audio recorder release success
'
);
});
...
...
@@ -4882,7 +4881,7 @@ reset(): void
**示例:**
```
j
s
```
t
s
audioRecorder
.
on
(
'
reset
'
,
()
=>
{
//设置'reset'事件回调
console
.
log
(
'
audio recorder reset success
'
);
});
...
...
@@ -4906,9 +4905,9 @@ on(type: 'prepare' | 'start' | 'pause' | 'resume' | 'stop' | 'release' | 'reset'
**示例:**
```
j
s
let
audioRecorder
=
media
.
createAudioRecorder
();
// 创建一个音频录制实例
let
audioRecorderConfig
=
{
```
t
s
let
audioRecorder
:
media
.
AudioRecorder
=
media
.
createAudioRecorder
();
// 创建一个音频录制实例
let
audioRecorderConfig
:
media
.
AudioRecorderConfig
=
{
audioEncoder
:
media
.
AudioEncoder
.
AAC_LC
,
audioEncodeBitRate
:
22050
,
audioSampleRate
:
22050
,
...
...
@@ -4917,7 +4916,7 @@ let audioRecorderConfig = {
uri
:
'
fd://xx
'
,
// 文件需先由调用者创建,并给予适当的权限
location
:
{
latitude
:
30
,
longitude
:
130
},
}
audioRecorder
.
on
(
'
error
'
,
(
error
)
=>
{
// 设置'error'事件回调
audioRecorder
.
on
(
'
error
'
,
(
error
:
BusinessError
)
=>
{
// 设置'error'事件回调
console
.
info
(
`audio error called, error:
${
error
}
`
);
});
audioRecorder
.
on
(
'
prepare
'
,
()
=>
{
// 设置'prepare'事件回调
...
...
@@ -4962,8 +4961,8 @@ on(type: 'error', callback: ErrorCallback): void
**示例:**
```
j
s
let
audioRecorderConfig
=
{
```
t
s
let
audioRecorderConfig
:
media
.
AudioRecorderConfig
=
{
audioEncoder
:
media
.
AudioEncoder
.
AAC_LC
,
audioEncodeBitRate
:
22050
,
audioSampleRate
:
22050
,
...
...
@@ -4972,7 +4971,7 @@ let audioRecorderConfig = {
uri
:
'
fd://xx
'
,
// 文件需先由调用者创建,并给予适当的权限
location
:
{
latitude
:
30
,
longitude
:
130
},
}
audioRecorder
.
on
(
'
error
'
,
(
error
)
=>
{
// 设置'error'事件回调
audioRecorder
.
on
(
'
error
'
,
(
error
:
Error
)
=>
{
// 设置'error'事件回调
console
.
error
(
`audio error called, error:
${
error
}
`
);
});
audioRecorder
.
prepare
(
audioRecorderConfig
);
// prepare不设置参数,触发'error'事件
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录