Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
op_09
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
op_09
Commits
a037c3f2
Commit
a037c3f2
authored
Sep 24, 2021
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 播放音频时暂停其他音频
parent
55b633b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
op_09.js
play/assets/op_09/scene/op_09.js
+12
-2
No files found.
play/assets/op_09/scene/op_09.js
View file @
a037c3f2
...
...
@@ -440,15 +440,23 @@ cc.Class({
});
},
currentPlayedAudioId
:
null
,
stopCurrentPlayedAudio
()
{
if
(
this
.
currentPlayedAudioId
!==
null
)
{
cc
.
audioEngine
.
stop
(
this
.
currentPlayedAudioId
);
this
.
currentPlayedAudioId
=
null
;
}
},
playEffect
(
name
,
cb
)
{
this
.
stopCurrentPlayedAudio
();
const
audioNode
=
cc
.
find
(
`audios/
${
name
}
`
);
const
audioClip
=
audioNode
.
getComponent
(
cc
.
AudioSource
).
clip
;
const
audioId
=
cc
.
audioEngine
.
playEffect
(
audioClip
,
false
,
0.8
);
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
this
.
currentPlayedAudioId
=
audioId
;
if
(
cb
)
{
cc
.
audioEngine
.
setFinishCallback
(
audioId
,
cb
);
}
},
playAudioByUrl
(
audio_url
,
cb
=
null
)
{
if
(
!
audio_url
)
{
if
(
cb
)
{
...
...
@@ -456,8 +464,10 @@ cc.Class({
}
return
;
}
this
.
stopCurrentPlayedAudio
();
cc
.
assetManager
.
loadRemote
(
audio_url
.
toLowerCase
(),
(
err
,
audioClip
)
=>
{
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
this
.
currentPlayedAudioId
=
audioId
;
if
(
cb
)
{
cc
.
audioEngine
.
setFinishCallback
(
audioId
,
cb
);
}
...
...
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