Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
4888f85d
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看板
提交
4888f85d
编写于
7月 27, 2022
作者:
W
wusongqing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update docs against 6397
Signed-off-by:
N
wusongqing
<
wusongqing@huawei.com
>
上级
cf8034d0
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
44 addition
and
44 deletion
+44
-44
en/application-dev/media/audio-playback.md
en/application-dev/media/audio-playback.md
+44
-44
未找到文件。
en/application-dev/media/audio-playback.md
浏览文件 @
4888f85d
...
...
@@ -39,28 +39,28 @@ function printfDescription(obj) {
// Set the player callbacks.
function
setCallBack
(
audioPlayer
)
{
audioPlayer
.
on
(
'
dataLoad
'
,
()
=>
{
// Set the 'dataLoad'
event callback, which is triggered when the src attribute is set successfully.
audioPlayer
.
on
(
'
dataLoad
'
,
()
=>
{
// Set the `dataLoad`
event callback, which is triggered when the src attribute is set successfully.
console
.
info
(
'
audio set source success
'
);
audioPlayer
.
play
();
// The play() API can be invoked only after the 'dataLoad' event callback is complete. The 'play' event callback is then triggered.
});
audioPlayer
.
on
(
'
play
'
,
()
=>
{
// Set the 'play'
event callback.
audioPlayer
.
on
(
'
play
'
,
()
=>
{
// Set the `play`
event callback.
console
.
info
(
'
audio play success
'
);
audioPlayer
.
pause
();
// Trigger the 'pause' event callback and pause the playback.
});
audioPlayer
.
on
(
'
pause
'
,
()
=>
{
// Set the 'pause'
event callback.
audioPlayer
.
on
(
'
pause
'
,
()
=>
{
// Set the `pause`
event callback.
console
.
info
(
'
audio pause success
'
);
audioPlayer
.
seek
(
5000
);
// Trigger the 'timeUpdate' event callback, and seek to 5000 ms for playback.
});
audioPlayer
.
on
(
'
stop
'
,
()
=>
{
// Set the 'stop'
event callback.
audioPlayer
.
on
(
'
stop
'
,
()
=>
{
// Set the `stop`
event callback.
console
.
info
(
'
audio stop success
'
);
audioPlayer
.
reset
();
// Trigger the 'reset' event callback, and reconfigure the src attribute to switch to the next song.
});
audioPlayer
.
on
(
'
reset
'
,
()
=>
{
// Set the 'reset'
event callback.
audioPlayer
.
on
(
'
reset
'
,
()
=>
{
// Set the `reset`
event callback.
console
.
info
(
'
audio reset success
'
);
audioPlayer
.
release
();
// Release the AudioPlayer instance.
audioPlayer
=
undefined
;
});
audioPlayer
.
on
(
'
timeUpdate
'
,
(
seekDoneTime
)
=>
{
// Set the 'timeUpdate'
event callback.
audioPlayer
.
on
(
'
timeUpdate
'
,
(
seekDoneTime
)
=>
{
// Set the `timeUpdate`
event callback.
if
(
typeof
(
seekDoneTime
)
==
'
undefined
'
)
{
console
.
info
(
'
audio seek fail
'
);
return
;
...
...
@@ -68,7 +68,7 @@ function setCallBack(audioPlayer) {
console
.
info
(
'
audio seek success, and seek time is
'
+
seekDoneTime
);
audioPlayer
.
setVolume
(
0.5
);
// Trigger the 'volumeChange' event callback.
});
audioPlayer
.
on
(
'
volumeChange
'
,
()
=>
{
// Set the 'volumeChange'
event callback.
audioPlayer
.
on
(
'
volumeChange
'
,
()
=>
{
// Set the `volumeChange`
event callback.
console
.
info
(
'
audio volumeChange success
'
);
audioPlayer
.
getTrackDescription
((
error
,
arrlist
)
=>
{
// Obtain the audio track information in callback mode.
if
(
typeof
(
arrlist
)
!=
'
undefined
'
)
{
...
...
@@ -107,7 +107,7 @@ async function audioPlayerDemo() {
}).
catch
((
err
)
=>
{
console
.
info
(
'
open fd failed err is
'
+
err
);
});
audioPlayer
.
src
=
fdPath
;
// Set the src attribute and trigger the
'dataLoad'
event callback.
audioPlayer
.
src
=
fdPath
;
// Set the src attribute and trigger the
`dataLoad`
event callback.
}
```
...
...
@@ -119,11 +119,11 @@ import fileIO from '@ohos.fileio'
export
class
AudioDemo
{
// Set the player callbacks.
setCallBack
(
audioPlayer
)
{
audioPlayer
.
on
(
'
dataLoad
'
,
()
=>
{
// Set the 'dataLoad'
event callback, which is triggered when the src attribute is set successfully.
audioPlayer
.
on
(
'
dataLoad
'
,
()
=>
{
// Set the `dataLoad`
event callback, which is triggered when the src attribute is set successfully.
console
.
info
(
'
audio set source success
'
);
audioPlayer
.
play
();
// Call the play() API to start the playback and trigger the 'play' event callback.
});
audioPlayer
.
on
(
'
play
'
,
()
=>
{
// Set the 'play'
event callback.
audioPlayer
.
on
(
'
play
'
,
()
=>
{
// Set the `play`
event callback.
console
.
info
(
'
audio play success
'
);
});
audioPlayer
.
on
(
'
finish
'
,
()
=>
{
// Set the 'finish' event callback, which is triggered when the playback is complete.
...
...
@@ -147,7 +147,7 @@ export class AudioDemo {
}).
catch
((
err
)
=>
{
console
.
info
(
'
open fd failed err is
'
+
err
);
});
audioPlayer
.
src
=
fdPath
;
// Set the src attribute and trigger the
'dataLoad'
event callback.
audioPlayer
.
src
=
fdPath
;
// Set the src attribute and trigger the
`dataLoad`
event callback.
}
}
```
...
...
@@ -161,15 +161,15 @@ export class AudioDemo {
// Set the player callbacks.
private
isNextMusic
=
false
;
setCallBack
(
audioPlayer
)
{
audioPlayer
.
on
(
'
dataLoad
'
,
()
=>
{
// Set the 'dataLoad'
event callback, which is triggered when the src attribute is set successfully.
audioPlayer
.
on
(
'
dataLoad
'
,
()
=>
{
// Set the `dataLoad`
event callback, which is triggered when the src attribute is set successfully.
console
.
info
(
'
audio set source success
'
);
audioPlayer
.
play
();
// Call the play() API to start the playback and trigger the 'play' event callback.
});
audioPlayer
.
on
(
'
play
'
,
()
=>
{
// Set the 'play'
event callback.
audioPlayer
.
on
(
'
play
'
,
()
=>
{
// Set the `play`
event callback.
console
.
info
(
'
audio play success
'
);
audioPlayer
.
reset
();
// Call the reset() API and trigger the 'reset' event callback.
});
audioPlayer
.
on
(
'
reset
'
,
()
=>
{
// Set the 'reset'
event callback.
audioPlayer
.
on
(
'
reset
'
,
()
=>
{
// Set the `reset`
event callback.
console
.
info
(
'
audio play success
'
);
if
(
!
this
.
isNextMusic
)
{
// When isNextMusic is false, changing songs is implemented.
this
.
nextMusic
(
audioPlayer
);
// Changing songs is implemented.
...
...
@@ -223,7 +223,7 @@ import fileIO from '@ohos.fileio'
export
class
AudioDemo
{
// Set the player callbacks.
setCallBack
(
audioPlayer
)
{
audioPlayer
.
on
(
'
dataLoad
'
,
()
=>
{
// Set the 'dataLoad'
event callback, which is triggered when the src attribute is set successfully.
audioPlayer
.
on
(
'
dataLoad
'
,
()
=>
{
// Set the `dataLoad`
event callback, which is triggered when the src attribute is set successfully.
console
.
info
(
'
audio set source success
'
);
audioPlayer
.
loop
=
true
;
// Set the loop playback attribute.
audioPlayer
.
play
();
// Call the play() API to start the playback and trigger the 'play' event callback.
...
...
@@ -247,7 +247,7 @@ export class AudioDemo {
}).
catch
((
err
)
=>
{
console
.
info
(
'
open fd failed err is
'
+
err
);
});
audioPlayer
.
src
=
fdPath
;
// Set the src attribute and trigger the
'dataLoad'
event callback.
audioPlayer
.
src
=
fdPath
;
// Set the src attribute and trigger the
`dataLoad`
event callback.
}
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录