Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
NJ_usercenter
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
NJ_usercenter
Commits
4882ef2e
Commit
4882ef2e
authored
Jun 21, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 配音合成
parent
82a36f98
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
2 deletions
+44
-2
videoHandler.ts
assets/NJ_usercenter/script/videoHandler.ts
+44
-2
No files found.
assets/NJ_usercenter/script/videoHandler.ts
View file @
4882ef2e
import
{
getVideoUrl
,
buttonOnClick
,
getVideoUrl
,
buttonOnClick
,
playAudioByUrl
,
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
./MyCocosSceneComponent
"
;
...
...
@@ -37,15 +37,24 @@ export default class NewClass extends MyCocosSceneComponent {
}
onEnable
()
{
// this.videoplayer.remoteURL = "";
this
.
rowData
=
this
.
node
[
"
rowData
"
];
this
.
dot
.
x
=
this
.
dotX
;
this
.
process
.
width
=
0
;
this
.
preloadRecorder
();
this
.
prePlayIndex
=
0
;
getVideoUrl
(
this
.
rowData
.
video_url
,
(
url
)
=>
{
this
.
videoplayer
.
remoteURL
=
url
+
`?t=
${
Date
.
now
()}
`
;
})
}
preloadRecorder
()
{
const
preloadArr
=
this
.
rowData
.
item_arr
.
map
((
item
)
=>
{
return
{
url
:
item
.
audio_url
};
});
cc
.
assetManager
.
loadAny
(
preloadArr
);
}
updateVideoStrip
()
{
if
(
!
this
.
videoplayer
?.
isPlaying
())
{
return
;
...
...
@@ -70,6 +79,9 @@ export default class NewClass extends MyCocosSceneComponent {
closeVideo
()
{
this
.
videoplayer
.
stop
();
if
(
this
.
playAudioId
)
{
cc
.
audioEngine
.
stop
(
this
.
playAudioId
);
}
this
.
dot
.
x
=
this
.
dotX
;
this
.
process
.
width
=
0
;
cc
.
find
(
`Canvas/videoContainer`
).
active
=
false
;
...
...
@@ -85,11 +97,17 @@ export default class NewClass extends MyCocosSceneComponent {
buttonOnClick
(
this
.
playBtn
,
()
=>
{
this
.
videoplayer
.
play
();
if
(
this
.
playAudioId
)
{
cc
.
audioEngine
.
resume
(
this
.
playAudioId
);
}
});
this
.
videoplayer
.
node
.
on
(
'
clicked
'
,
()
=>
{
if
(
this
.
videoplayer
.
isPlaying
())
{
this
.
videoplayer
.
pause
();
if
(
this
.
playAudioId
)
{
cc
.
audioEngine
.
pause
(
this
.
playAudioId
);
}
this
.
playBtn
.
active
=
true
;
}
});
...
...
@@ -105,7 +123,31 @@ export default class NewClass extends MyCocosSceneComponent {
});
}
prePlayIndex
=
0
;
playAudioId
=
null
;
listenTimePlayRecorder
()
{
const
item
=
this
.
rowData
.
item_arr
[
this
.
prePlayIndex
];
if
(
!
item
)
{
return
;
}
const
startTime
=
item
.
startTime
;
const
audio_url
=
item
.
audio_url
;
if
(
this
.
videoplayer
.
currentTime
>=
startTime
)
{
this
.
prePlayIndex
++
;
cc
.
assetManager
.
loadRemote
(
audio_url
,
(
err
,
audioClip
)
=>
{
if
(
err
)
{
console
.
error
(
err
);
return
;
}
this
.
playAudioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
1
);
});
}
}
update
(
dt
)
{
this
.
updateVideoStrip
();
this
.
listenTimePlayRecorder
();
}
}
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