Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
PU21
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
PU21
Commits
4df8c6a9
Commit
4df8c6a9
authored
May 21, 2021
by
jeff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改音乐组件播放模式
parent
77bc0c82
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
35 deletions
+17
-35
audioItem.js
play/assets/scene/scene/audioItem.js
+17
-35
No files found.
play/assets/scene/scene/audioItem.js
View file @
4df8c6a9
...
...
@@ -36,7 +36,7 @@ cc.Class({
init
(
url
)
{
this
.
stopAudio
()
this
.
onEvent
()
this
.
playBtn
.
active
=
true
this
.
pauseBtn
.
active
=
false
cc
.
assetManager
.
loadRemote
(
url
,
(
err
,
audioClip
)
=>
{
...
...
@@ -46,21 +46,31 @@ cc.Class({
this
.
label
.
string
=
'
0:00/
'
+
this
.
transTime
(
this
.
_totoalTime
)
this
.
tiao
.
children
[
0
].
getComponent
(
cc
.
Sprite
).
fillRange
=
0
this
.
tiao
.
children
[
1
].
x
=
12
this
.
onAudioFinish
()
})
},
onAudioFinish
()
{
if
(
this
.
_audioId
!=
null
)
{
this
.
pauseBtn
.
active
=
false
this
.
playBtn
.
active
=
true
}
this
.
_play
=
false
this
.
_nowTime
=
0
this
.
_audioId
=
cc
.
audioEngine
.
play
(
this
.
clip
)
cc
.
audioEngine
.
pause
(
this
.
_audioId
)
cc
.
audioEngine
.
setFinishCallback
(
this
.
_audioId
,
this
.
onAudioFinish
.
bind
(
this
))
},
onTouchStart
()
{
if
(
this
.
_audioId
==
null
)
return
if
(
this
.
_play
)
{
this
.
_pause
=
true
this
.
_play
=
false
cc
.
audioEngine
.
pause
(
this
.
_audioId
)
}
},
/** 触摸移动 */
onTouchMove
(
e
)
{
if
(
this
.
_audioId
==
null
)
return
let
dis
=
e
.
getPreviousLocation
().
sub
(
e
.
getLocation
())
dis
=
this
.
moveBtn
.
x
-
dis
.
x
if
(
dis
<
12
)
dis
=
12
...
...
@@ -86,21 +96,15 @@ cc.Class({
this
.
pauseBtn
.
active
=
true
this
.
playBtn
.
active
=
false
this
.
_play
=
true
if
(
this
.
_audioId
!=
null
)
{
cc
.
audioEngine
.
resume
(
this
.
_audioId
)
}
else
{
this
.
_audioId
=
cc
.
audioEngine
.
play
(
this
.
clip
)
cc
.
audioEngine
.
setFinishCallback
(
this
.
_audioId
,
this
.
stopAudio
.
bind
(
this
));
this
.
_nowTime
=
0
}
cc
.
systemEvent
.
emit
(
'
stopWordsMusic
'
)
},
onPause
()
{
this
.
pauseBtn
.
active
=
false
this
.
playBtn
.
active
=
true
this
.
_play
=
false
this
.
_pause
=
true
cc
.
audioEngine
.
pause
(
this
.
_audioId
)
},
...
...
@@ -117,29 +121,7 @@ cc.Class({
onEvent
()
{
if
(
!
this
.
_play
)
return
this
.
onStopAudio
()
},
onStopAudio
()
{
if
(
this
.
_nowTime
<
this
.
_totoalTime
)
{
this
.
onPause
()
}
else
{
this
.
stopAudio
()
}
},
stopAudio
()
{
if
(
this
.
_audioId
!=
null
)
{
this
.
_audioId
=
null
cc
.
audioEngine
.
stop
(
this
.
_audioId
)
this
.
_play
=
false
this
.
pauseBtn
.
active
=
false
this
.
playBtn
.
active
=
true
// this._nowTime = 0
// this.label.string = this.transTime(this._nowTime) + '/' + this.transTime(this._totoalTime)
// this.tiao.children[0].getComponent(cc.Sprite).fillRange = 0
// this.tiao.children[1].x = 12
}
},
/** 秒转分钟 */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment