Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ijianbo
winxin-app-watch-life.net
提交
e50dcf58
W
winxin-app-watch-life.net
项目概览
ijianbo
/
winxin-app-watch-life.net
通知
60
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
winxin-app-watch-life.net
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e50dcf58
编写于
12月 29, 2021
作者:
ijianbo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整音频播放,采用背景播放方式
上级
8ed31f21
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
5 addition
and
1 deletion
+5
-1
app.json
app.json
+4
-0
components/mp-html/audio/audio.js
components/mp-html/audio/audio.js
+1
-1
未找到文件。
app.json
浏览文件 @
e50dcf58
...
...
@@ -49,6 +49,10 @@
}
]
},
"requiredBackgroundModes"
:
[
"audio"
,
"location"
],
"networkTimeout"
:
{
"request"
:
10000
,
"connectSocket"
:
10000
,
...
...
components/mp-html/audio/audio.js
浏览文件 @
e50dcf58
"
use strict
"
;
var
t
=
require
(
"
./context
"
);
Component
({
data
:{
time
:
"
00:00
"
},
properties
:{
name
:
String
,
author
:
String
,
poster
:
String
,
autoplay
:
Boolean
,
controls
:
Boolean
,
loop
:
Boolean
,
src
:{
type
:
String
,
observer
:
function
(
t
){
this
.
setSrc
(
t
)}}},
created
:
function
(){
var
t
=
this
;
this
.
_ctx
=
wx
.
createInnerAudioContext
(),
wx
.
setInnerAudioOption
({
obeyMuteSwitch
:
!
1
}),
this
.
_ctx
.
onError
(
function
(
i
){
t
.
setData
({
error
:
!
0
}),
t
.
triggerEvent
(
"
error
"
,
i
)}),
this
.
_ctx
.
onTimeUpdate
(
function
(){
var
i
=
t
.
_ctx
.
currentTime
,
e
=
parseInt
(
i
/
60
),
s
=
Math
.
ceil
(
i
%
60
),
a
=
{};
a
.
time
=
(
e
>
9
?
e
:
"
0
"
+
e
)
+
"
:
"
+
(
s
>
9
?
s
:
"
0
"
+
s
),
t
.
lastTime
||
(
a
.
value
=
i
/
t
.
_ctx
.
duration
*
100
),
t
.
setData
(
a
)}),
this
.
_ctx
.
onEnded
(
function
(){
t
.
data
.
loop
||
t
.
setData
({
playing
:
!
1
})})},
attached
:
function
(){
t
.
set
(
this
.
id
,
this
)},
detached
:
function
(){
this
.
_ctx
.
destroy
(),
t
.
remove
(
this
.
data
.
audioId
)},
pageLifetimes
:{
show
:
function
(){
this
.
data
.
playing
&&
this
.
_ctx
.
paused
&&
this
.
_ctx
.
play
()}},
methods
:{
setSrc
:
function
(
t
){
this
.
_ctx
.
autoplay
=
this
.
data
.
autoplay
,
this
.
_ctx
.
loop
=
this
.
data
.
loop
,
this
.
_ctx
.
src
=
t
,
this
.
data
.
autoplay
&&!
this
.
data
.
playing
&&
this
.
setData
({
playing
:
!
0
})},
play
:
function
(){
this
.
_ctx
.
play
(),
this
.
setData
({
playing
:
!
0
}),
this
.
triggerEvent
(
"
play
"
)},
pause
:
function
(){
this
.
_ctx
.
pause
(),
this
.
setData
({
playing
:
!
1
}),
this
.
triggerEvent
(
"
pause
"
)},
stop
:
function
(){
this
.
_ctx
.
stop
(),
this
.
setData
({
playing
:
!
1
,
time
:
"
00:00
"
}),
this
.
triggerEvent
(
"
stop
"
)},
seek
:
function
(
t
){
this
.
_ctx
.
seek
(
t
)},
_seeking
:
function
(
t
){
if
(
!
(
t
.
timeStamp
-
this
.
lastTime
<
200
)){
var
i
=
Math
.
round
(
t
.
detail
.
value
/
100
*
this
.
_ctx
.
duration
),
e
=
parseInt
(
i
/
60
),
s
=
i
%
60
;
this
.
setData
({
time
:(
e
>
9
?
e
:
"
0
"
+
e
)
+
"
:
"
+
(
s
>
9
?
s
:
"
0
"
+
s
)}),
this
.
lastTime
=
t
.
timeStamp
}},
_seeked
:
function
(
t
){
this
.
_ctx
.
seek
(
t
.
detail
.
value
/
100
*
this
.
_ctx
.
duration
),
this
.
lastTime
=
void
0
}}});
\ No newline at end of file
"
use strict
"
;
var
t
=
require
(
"
./context
"
);
Component
({
data
:{
time
:
"
00:00
"
},
properties
:{
name
:
String
,
author
:
String
,
poster
:
String
,
autoplay
:
Boolean
,
controls
:
Boolean
,
loop
:
Boolean
,
src
:{
type
:
String
,
observer
:
function
(
t
){
this
.
setSrc
(
t
)}}},
created
:
function
(){
var
t
=
this
;
this
.
_ctx
=
wx
.
getBackgroundAudioManager
(),
wx
.
setInnerAudioOption
({
obeyMuteSwitch
:
!
1
}),
this
.
_ctx
.
onError
(
function
(
i
){
t
.
setData
({
error
:
!
0
}),
t
.
triggerEvent
(
"
error
"
,
i
)}),
this
.
_ctx
.
onTimeUpdate
(
function
(){
var
i
=
t
.
_ctx
.
currentTime
,
e
=
parseInt
(
i
/
60
),
s
=
Math
.
ceil
(
i
%
60
),
a
=
{};
a
.
time
=
(
e
>
9
?
e
:
"
0
"
+
e
)
+
"
:
"
+
(
s
>
9
?
s
:
"
0
"
+
s
),
t
.
lastTime
||
(
a
.
value
=
i
/
t
.
_ctx
.
duration
*
100
),
t
.
setData
(
a
)}),
this
.
_ctx
.
onEnded
(
function
(){
t
.
data
.
loop
||
t
.
setData
({
playing
:
!
1
,
time
:
"
00:00
"
})}),
this
.
_ctx
.
onStop
(
function
(){
t
.
setData
({
playing
:
!
1
,
time
:
"
00:00
"
}),
t
.
triggerEvent
(
"
stop
"
)})},
attached
:
function
(){
t
.
set
(
this
.
id
,
this
)},
detached
:
function
(){
this
.
_ctx
&&
(
this
.
setData
({
playing
:
!
1
,
time
:
"
00:00
"
}),
this
.
_ctx
.
stop
()),
t
.
remove
(
this
.
data
.
audioId
)},
pageLifetimes
:{
show
:
function
(){
this
.
data
.
playing
&&
this
.
_ctx
.
paused
&&
this
.
_ctx
.
play
()}},
methods
:{
setSrc
:
function
(
t
){
this
.
_ctx
.
autoplay
=
this
.
data
.
autoplay
,
this
.
_ctx
.
loop
=
this
.
data
.
loop
,
this
.
data
.
autoplay
&&!
this
.
data
.
playing
&&
this
.
setData
({
playing
:
!
0
})},
play
:
function
(){
"
00:00
"
==
this
.
data
.
time
?(
this
.
_ctx
.
src
=
this
.
data
.
src
,
this
.
_ctx
.
title
=
this
.
data
.
name
||
"
音频
"
,
this
.
_ctx
.
singer
=
this
.
data
.
author
):
this
.
_ctx
.
play
(),
this
.
setData
({
playing
:
!
0
}),
this
.
triggerEvent
(
"
play
"
)},
pause
:
function
(){
this
.
_ctx
.
pause
(),
this
.
setData
({
playing
:
!
1
}),
this
.
triggerEvent
(
"
pause
"
)},
stop
:
function
(){
this
.
_ctx
.
stop
(),
this
.
setData
({
playing
:
!
1
,
time
:
"
00:00
"
}),
this
.
triggerEvent
(
"
stop
"
)},
seek
:
function
(
t
){
this
.
_ctx
.
seek
(
t
)},
_seeking
:
function
(
t
){
if
(
!
(
t
.
timeStamp
-
this
.
lastTime
<
200
)){
var
i
=
Math
.
round
(
t
.
detail
.
value
/
100
*
this
.
_ctx
.
duration
),
e
=
parseInt
(
i
/
60
),
s
=
i
%
60
;
this
.
setData
({
time
:(
e
>
9
?
e
:
"
0
"
+
e
)
+
"
:
"
+
(
s
>
9
?
s
:
"
0
"
+
s
)}),
this
.
lastTime
=
t
.
timeStamp
}},
_seeked
:
function
(
t
){
this
.
_ctx
.
seek
(
t
.
detail
.
value
/
100
*
this
.
_ctx
.
duration
),
this
.
lastTime
=
void
0
}}});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录