Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dg29_museum
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
dg29_museum
Commits
d38b7c43
Commit
d38b7c43
authored
Dec 31, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拖拽组件完成
parent
734492a0
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
563 additions
and
184 deletions
+563
-184
dg29_museum.fire
assets/dg29_museum/scene/dg29_museum.fire
+500
-181
videoCtrl_DG16.ts
assets/dg29_museum/script/ui/videoCtrl_DG16.ts
+63
-3
No files found.
assets/dg29_museum/scene/dg29_museum.fire
View file @
d38b7c43
This diff is collapsed.
Click to expand it.
assets/dg29_museum/script/ui/videoCtrl_DG16.ts
View file @
d38b7c43
...
...
@@ -16,8 +16,10 @@ export default class videoCtrl extends cc.Component {
@
property
(
cc
.
Node
)
vidoStateIcon
:
cc
.
Node
=
null
;
@
property
(
cc
.
Slider
)
vidoSlider
:
cc
.
Slider
=
null
;
@
property
(
cc
.
ProgressBar
)
vidoSlider
:
cc
.
ProgressBar
=
null
;
@
property
(
cc
.
Node
)
ProgressBar
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
playbar
:
cc
.
Node
=
null
;
...
...
@@ -39,6 +41,7 @@ export default class videoCtrl extends cc.Component {
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
touchVideoLayer
,
this
)
this
.
initDrag
();
}
touchVideoLayer
()
{
...
...
@@ -121,8 +124,17 @@ export default class videoCtrl extends cc.Component {
let
total
=
Math
.
ceil
(
this
.
_videoCom
.
getDuration
());
this
.
nowTime
.
string
=
this
.
makeTimeStr
(
now
)
this
.
totalTime
.
string
=
this
.
makeTimeStr
(
total
)
this
.
vidoSlider
.
progress
=
now
/
total
;
this
.
updateSlider
(
now
,
total
)
}
}
updateSlider
(
now
,
total
)
{
let
percent
=
now
/
total
this
.
vidoSlider
.
progress
=
now
/
total
;
const
maxX
=
this
.
ProgressBar
.
width
;
const
minX
=
0
;
let
newX
=
percent
*
maxX
;
newX
=
Math
.
min
(
maxX
,
Math
.
max
(
newX
,
minX
));
this
.
barTag
.
x
=
newX
;
}
makeTimeStr
(
time
)
{
...
...
@@ -132,4 +144,52 @@ export default class videoCtrl extends cc.Component {
return
`
${
min
<
10
?
"
0
"
+
min
:
min
}
:
${
sec
<
10
?
"
0
"
+
sec
:
sec
}
`
}
@
property
(
cc
.
Node
)
barTag
:
cc
.
Node
=
null
;
initDrag
()
{
const
maxX
=
this
.
vidoSlider
.
node
.
width
;
const
minX
=
0
;
this
.
barTag
.
off
(
cc
.
Node
.
EventType
.
TOUCH_START
);
this
.
barTag
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
(
e
)
=>
{
console
.
log
(
"
TOUCH_START
"
);
});
this
.
barTag
.
off
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
);
this
.
barTag
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
(
e
)
=>
{
const
worldPos
=
e
.
getLocation
();
const
localPos
=
this
.
barTag
.
parent
.
convertToNodeSpaceAR
(
worldPos
);
let
newX
=
localPos
.
x
;
newX
=
Math
.
min
(
maxX
,
Math
.
max
(
newX
,
minX
));
this
.
barTag
.
x
=
newX
;
const
percent
=
newX
/
maxX
;
const
dur
=
this
.
_videoCom
.
getDuration
();
let
now
=
Math
.
ceil
(
this
.
_videoCom
?.
currentTime
)
let
total
=
Math
.
ceil
(
this
.
_videoCom
.
getDuration
());
this
.
nowTime
.
string
=
this
.
makeTimeStr
(
now
)
this
.
_videoCom
.
currentTime
=
percent
*
dur
;
});
this
.
barTag
.
off
(
cc
.
Node
.
EventType
.
TOUCH_END
);
this
.
barTag
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
(
e
)
=>
{
console
.
log
(
"
TOUCH_ENDED
"
);
this
.
updateBarByPos
(
this
.
barTag
.
x
);
});
this
.
barTag
.
off
(
cc
.
Node
.
EventType
.
MOUSE_UP
);
this
.
barTag
.
on
(
cc
.
Node
.
EventType
.
MOUSE_UP
,
(
e
)
=>
{
console
.
log
(
"
MOUSE_UP
"
);
this
.
updateBarByPos
(
this
.
barTag
.
x
);
});
}
updateBarByPos
(
newX
)
{
const
maxX
=
this
.
vidoSlider
.
node
.
width
;
const
minX
=
0
;
let
percent
=
newX
/
maxX
;
if
(
percent
>
1
)
{
percent
=
1
}
const
dur
=
this
.
_videoCom
.
getDuration
();
this
.
_videoCom
.
currentTime
=
percent
*
dur
}
}
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