Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
ns_video_map
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
ns_video_map
Commits
c48ab451
Commit
c48ab451
authored
Apr 19, 2022
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 视频进度条
parent
4cc43555
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
872 additions
and
52 deletions
+872
-52
prefab.meta
assets/ns_video_map/prefab.meta
+12
-0
js.meta
assets/ns_video_map/prefab/js.meta
+12
-0
progressScript.js
assets/ns_video_map/prefab/js/progressScript.js
+70
-0
progressScript.js.meta
assets/ns_video_map/prefab/js/progressScript.js.meta
+9
-0
progress.prefab
assets/ns_video_map/prefab/progress.prefab
+243
-0
progress.prefab.meta
assets/ns_video_map/prefab/progress.prefab.meta
+8
-0
res.meta
assets/ns_video_map/prefab/res.meta
+12
-0
record_progress_bar.png
assets/ns_video_map/prefab/res/record_progress_bar.png
+0
-0
record_progress_bar.png.meta
assets/ns_video_map/prefab/res/record_progress_bar.png.meta
+36
-0
record_progress_bg.png
assets/ns_video_map/prefab/res/record_progress_bg.png
+0
-0
record_progress_bg.png.meta
assets/ns_video_map/prefab/res/record_progress_bg.png.meta
+36
-0
ns_video_map.fire
assets/ns_video_map/scene/ns_video_map.fire
+260
-26
ns_video_map.ts
assets/ns_video_map/scene/ns_video_map.ts
+163
-26
util.ts
assets/ns_video_map/script/util.ts
+11
-0
No files found.
assets/ns_video_map/prefab.meta
0 → 100644
View file @
c48ab451
{
"ver": "1.1.2",
"uuid": "d2b0cbe4-4308-4ae5-bb5b-8e672a862d1d",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
assets/ns_video_map/prefab/js.meta
0 → 100644
View file @
c48ab451
{
"ver": "1.1.2",
"uuid": "af87b1e7-7883-407b-af6f-0520bab48641",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
assets/ns_video_map/prefab/js/progressScript.js
0 → 100644
View file @
c48ab451
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
cc
.
Class
({
extends
:
cc
.
Component
,
properties
:
{
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// type: cc.Node,
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start
()
{
this
.
init
();
},
barBaseW
:
null
,
barSpr
:
null
,
barSf
:
null
,
init
()
{
this
.
bar
=
cc
.
find
(
'
bar
'
,
this
.
node
);
this
.
barBaseW
=
this
.
bar
.
width
;
this
.
barSpr
=
this
.
bar
.
getComponent
(
cc
.
Sprite
);
this
.
barSf
=
this
.
barSpr
.
spriteFrame
;
this
.
setProgress
(
0
);
},
setProgress
(
progress
)
{
setTimeout
(()
=>
{
if
(
!
this
.
barSf
)
{
return
;
}
const
w
=
this
.
barBaseW
*
progress
;
const
rect
=
this
.
barSf
.
getRect
();
rect
.
width
=
w
;
this
.
bar
.
width
=
w
;
this
.
barSpr
.
spriteFrame
.
setRect
(
rect
);
},
1
);
},
// update (dt) {},
});
assets/ns_video_map/prefab/js/progressScript.js.meta
0 → 100644
View file @
c48ab451
{
"ver": "1.0.8",
"uuid": "ff03bff6-e911-4b26-8e28-803cdc16c50f",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
assets/ns_video_map/prefab/progress.prefab
0 → 100644
View file @
c48ab451
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "progress",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_components": [
{
"__id__": 5
},
{
"__id__": 6
}
],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 269,
"height": 16
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "bar",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 269,
"height": 16
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "c43f093f-a7c5-42d5-bf56-778a3548a7c3"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "7dOjkMYWpFQaM6/QbKkBy/",
"sync": false
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "82ee3fa0-26e3-43e8-afca-8bbc978d88e4"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "ff03b/26RFLJo4ogDzcFsUP",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
assets/ns_video_map/prefab/progress.prefab.meta
0 → 100644
View file @
c48ab451
{
"ver": "1.2.9",
"uuid": "3d356c4d-cb23-4239-aa5f-8a913f420fa4",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
assets/ns_video_map/prefab/res.meta
0 → 100644
View file @
c48ab451
{
"ver": "1.1.2",
"uuid": "b002a2d7-8ab2-4eb7-abf7-62e778ae59b9",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
assets/ns_video_map/prefab/res/record_progress_bar.png
0 → 100644
View file @
c48ab451
1.85 KB
assets/ns_video_map/prefab/res/record_progress_bar.png.meta
0 → 100644
View file @
c48ab451
{
"ver": "2.3.5",
"uuid": "344dc346-7299-44ae-8693-0ac57ec21aca",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 269,
"height": 16,
"platformSettings": {},
"subMetas": {
"record_progress_bar": {
"ver": "1.0.4",
"uuid": "c43f093f-a7c5-42d5-bf56-778a3548a7c3",
"rawTextureUuid": "344dc346-7299-44ae-8693-0ac57ec21aca",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 807,
"height": 16,
"rawWidth": 807,
"rawHeight": 16,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
assets/ns_video_map/prefab/res/record_progress_bg.png
0 → 100644
View file @
c48ab451
1.87 KB
assets/ns_video_map/prefab/res/record_progress_bg.png.meta
0 → 100644
View file @
c48ab451
{
"ver": "2.3.5",
"uuid": "cb4c174a-628f-41b0-b661-f98961162196",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 807,
"height": 16,
"platformSettings": {},
"subMetas": {
"record_progress_bg": {
"ver": "1.0.4",
"uuid": "82ee3fa0-26e3-43e8-afca-8bbc978d88e4",
"rawTextureUuid": "cb4c174a-628f-41b0-b661-f98961162196",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 807,
"height": 16,
"rawWidth": 807,
"rawHeight": 16,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
assets/ns_video_map/scene/ns_video_map.fire
View file @
c48ab451
...
...
@@ -81,19 +81,22 @@
"__id__": 14
},
{
"__id__": 16
"__id__": 21
},
{
"__id__": 23
}
],
"_active": true,
"_components": [
{
"__id__":
25
"__id__":
32
},
{
"__id__":
26
"__id__":
33
},
{
"__id__":
27
"__id__":
34
}
],
"_prefab": null,
...
...
@@ -221,7 +224,7 @@
"r": 0,
"g": 0,
"b": 0,
"a":
255
"a":
0
},
"_depth": -1,
"_zoomRatio": 1,
...
...
@@ -549,7 +552,7 @@
"_mute": false,
"_isFullscreen": false,
"_N$isFullscreen": false,
"_stayOnBottom":
fals
e,
"_stayOnBottom":
tru
e,
"videoPlayerEvent": [],
"_N$keepAspectRatio": true,
"_id": "0255cviSdDeJCrRG6RjufJ"
...
...
@@ -608,6 +611,237 @@
"_originalHeight": 0,
"_id": "a23aWB9GtG4LDLOLKjwL1m"
},
{
"__type__": "cc.Node",
"_name": "progress",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [
{
"__id__": 15
}
],
"_active": true,
"_components": [
{
"__id__": 18
},
{
"__id__": 19
}
],
"_prefab": {
"__id__": 20
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 807,
"height": 16
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-491.647,
-302.463,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "43EX0Z3i1CFqzLZukR7r+F"
},
{
"__type__": "cc.Node",
"_name": "bar",
"_objFlags": 0,
"_parent": {
"__id__": 14
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 16
}
],
"_prefab": {
"__id__": 17
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 807,
"height": 16
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "b0g49meHZDMZtXXKUG/Tpt"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "c43f093f-a7c5-42d5-bf56-778a3548a7c3"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "09WBTNbvFAs50Y1p5LY4q4"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 14
},
"asset": {
"__uuid__": "3d356c4d-cb23-4239-aa5f-8a913f420fa4"
},
"fileId": "7dOjkMYWpFQaM6/QbKkBy/",
"sync": false
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 14
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "82ee3fa0-26e3-43e8-afca-8bbc978d88e4"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "20gWdpn05LGJ/xI7wBJhSa"
},
{
"__type__": "ff03b/26RFLJo4ogDzcFsUP",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 14
},
"_enabled": true,
"_id": "67uc0iwNhHaoWKCfHQhOGz"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 14
},
"asset": {
"__uuid__": "3d356c4d-cb23-4239-aa5f-8a913f420fa4"
},
"fileId": "",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "btn_skip",
...
...
@@ -619,7 +853,7 @@
"_active": true,
"_components": [
{
"__id__":
15
"__id__":
22
}
],
"_prefab": null,
...
...
@@ -645,8 +879,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0
,
-
275.804
,
446.742
,
-
301.61
,
0,
0,
0,
...
...
@@ -675,7 +909,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__":
14
"__id__":
21
},
"_enabled": true,
"_materials": [
...
...
@@ -711,10 +945,10 @@
},
"_children": [
{
"__id__":
17
"__id__":
24
},
{
"__id__": 2
0
"__id__": 2
7
}
],
"_active": false,
...
...
@@ -772,11 +1006,11 @@
"_name": "font",
"_objFlags": 0,
"_parent": {
"__id__":
16
"__id__":
23
},
"_children": [
{
"__id__":
18
"__id__":
25
}
],
"_active": true,
...
...
@@ -834,13 +1068,13 @@
"_name": "BRLNSDB",
"_objFlags": 0,
"_parent": {
"__id__":
17
"__id__":
24
},
"_children": [],
"_active": true,
"_components": [
{
"__id__":
19
"__id__":
26
}
],
"_prefab": null,
...
...
@@ -896,7 +1130,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__":
18
"__id__":
25
},
"_enabled": true,
"_materials": [],
...
...
@@ -927,14 +1161,14 @@
"_name": "img",
"_objFlags": 0,
"_parent": {
"__id__":
16
"__id__":
23
},
"_children": [
{
"__id__": 2
1
"__id__": 2
8
},
{
"__id__":
23
"__id__":
30
}
],
"_active": true,
...
...
@@ -992,13 +1226,13 @@
"_name": "btn_right",
"_objFlags": 0,
"_parent": {
"__id__": 2
0
"__id__": 2
7
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
2
"__id__": 2
9
}
],
"_prefab": null,
...
...
@@ -1054,7 +1288,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
1
"__id__": 2
8
},
"_enabled": true,
"_materials": [],
...
...
@@ -1082,13 +1316,13 @@
"_name": "icon",
"_objFlags": 0,
"_parent": {
"__id__": 2
0
"__id__": 2
7
},
"_children": [],
"_active": true,
"_components": [
{
"__id__":
24
"__id__":
31
}
],
"_prefab": null,
...
...
@@ -1144,7 +1378,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__":
23
"__id__":
30
},
"_enabled": true,
"_materials": [],
...
...
assets/ns_video_map/scene/ns_video_map.ts
View file @
c48ab451
import
{
asyncDelay
,
onHomeworkFinish
}
from
"
../script/util
"
;
import
{
asyncDelay
,
delayCall
,
onHomeworkFinish
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
...
...
@@ -40,6 +41,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
setTransparentCanvas
();
this
.
initVideo
();
this
.
initBtn
();
this
.
initProgress
();
// this.initBg();
// this.initPic();
// this.initBtn();
...
...
@@ -51,8 +53,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
canvas
=
cc
.
find
(
"
Canvas
"
);
const
jumpBtn
=
cc
.
find
(
"
Canvas/btn_skip
"
);
//this.getSprNode('btn_right');
canvas
.
on
(
'
touchstart
'
,
()
=>
{
jumpBtn
.
on
(
'
touchstart
'
,
()
=>
{
this
.
videoPlayEnd
();
})
...
...
@@ -80,11 +82,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
video
=
null
initVideo
()
{
//
if (this.data.video_url) {
//
this.initVideoRemote();
//
} else {
if
(
this
.
data
.
video_url
)
{
this
.
initVideoRemote
();
}
else
{
this
.
initVideoLocal
();
//
}
}
this
.
video
.
node
.
on
(
'
completed
'
,
()
=>
{
...
...
@@ -96,25 +98,83 @@ export default class SceneComponent extends MyCocosSceneComponent {
isPlayEnd
=
null
videoPlayEnd
()
{
console
.
log
(
'
in videoPlayEnd
'
)
if
(
this
.
isPlayEnd
)
{
return
}
this
.
isPlayEnd
=
true
;
if
(
this
.
video
)
{
this
.
video
.
pause
();
}
onHomeworkFinish
();
}
initVideoLocal
()
{
console
.
log
(
'
in initVideoLocal
'
)
const
videoLocalNode
=
cc
.
find
(
"
Canvas/videoBase/videoLocal
"
);
const
video
=
videoLocalNode
.
getComponent
(
cc
.
VideoPlayer
);
video
.
isFullscreen
=
true
;
// video.stayOnBottom = true;
video
.
stayOnBottom
=
true
;
// let playCount = 0;
// const playVideo = ()=> {
// playCount ++;
// if (playCount < 2) {
// return;
// }
// video.play();
// }
// videoLocalNode.on("meta-loaded", () => {
// console.log('in meta-loaded')
// playVideo();
// })
console
.
log
(
"
video:
"
,
video
);
video
.
play
();
// videoLocalNode.on("ready-to-play", () => {
// console.log('in ready-to-play ');
// playVideo();
// })
// console.log("video: ", video);
// video.play();
this
.
video
=
video
;
video
.
node
.
on
(
'
ready-to-play
'
,
()
=>
{
// console.log(' in ready-to-play')
// if (this.isDestroy) {
// return;
// }
video
.
play
();
checkIsPlaying
();
})
const
checkIsPlaying
=
()
=>
{
delayCall
(
0.001
,
()
=>
{
console
.
log
(
'
in checkIsPlaying 1
'
)
// if (this.isDestroy) {
// return;
// }
if
(
video
.
currentTime
)
{
video
.
pause
();
// this.isVideoPlayerReady = true;
// this.checkCanShowRecordList();
}
else
{
checkIsPlaying
();
}
})
}
}
initVideoRemote
()
{
...
...
@@ -129,25 +189,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
videoRemoteNode
.
parent
=
videoLocalNode
.
parent
;
const
video
=
videoRemoteNode
.
addComponent
(
cc
.
VideoPlayer
);
let
isCanPlay
=
false
;
const
playVideo
=
()
=>
{
if
(
isCanPlay
)
{
return
;
}
isCanPlay
=
true
;
video
.
play
();
}
//
let isCanPlay = false;
//
const playVideo = ()=> {
//
if (isCanPlay) {
//
return;
//
}
//
isCanPlay = true;
//
video.play();
//
}
videoRemoteNode
.
on
(
"
meta-loaded
"
,
()
=>
{
//
videoRemoteNode.on("meta-loaded", () => {
console
.
log
(
'
in meta-loaded
'
)
playVideo
();
})
//
console.log('in meta-loaded')
//
playVideo();
//
})
videoRemoteNode
.
on
(
"
ready-to-play
"
,
()
=>
{
console
.
log
(
'
in ready-to-play
'
);
playVideo
();
})
//
videoRemoteNode.on("ready-to-play", () => {
//
console.log('in ready-to-play ');
//
playVideo();
//
})
video
.
resourceType
=
cc
.
VideoPlayer
.
ResourceType
.
REMOTE
;
video
.
remoteURL
=
this
.
data
.
video_url
;
...
...
@@ -156,6 +216,41 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
video
=
video
;
video
.
node
.
on
(
'
ready-to-play
'
,
()
=>
{
// console.log(' in ready-to-play')
// if (this.isDestroy) {
// return;
// }
video
.
play
();
checkIsPlaying
();
})
const
checkIsPlaying
=
()
=>
{
delayCall
(
0.001
,
()
=>
{
console
.
log
(
'
in checkIsPlaying 1
'
)
// if (this.isDestroy) {
// return;
// }
if
(
video
.
currentTime
)
{
video
.
pause
();
// this.isVideoPlayerReady = true;
// this.checkCanShowRecordList();
}
else
{
checkIsPlaying
();
}
})
}
}
...
...
@@ -305,6 +400,34 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
// update (dt) {},
progressJs
=
null
initProgress
()
{
const
progress
=
cc
.
find
(
"
Canvas/progress
"
)
const
progressJs
=
progress
.
getComponent
(
'
progressScript
'
);
this
.
progressJs
=
progressJs
;
// const timeLabel = this.getLabel();
// timeLabel.fontSize = 20;
// timeLabel.string = Number(formatTime('s.S', new Date(item.duration * 1000))) + 's';
// item.progressLabel = timeLabel;
// const timeLabelNode = timeLabel.node;
// timeLabelNode.anchorX = 0;
// timeLabelNode.color = cc.Color.BLACK;
// timeLabelNode.x = progress.x + progress.width + 10;
// timeLabelNode.y = progress.y;
// item.addChild(timeLabelNode);
}
getPrefab
(
resName
)
{
const
prefab
=
cc
.
find
(
'
Canvas/res/prefab/
'
+
resName
)
const
newPrefab
=
cc
.
instantiate
(
prefab
);
newPrefab
.
parent
=
null
;
return
newPrefab
;
}
initListener
()
{
...
...
@@ -319,4 +442,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
})
}
update
()
{
if
(
this
.
progressJs
&&
this
.
video
&&
!
this
.
isPlayEnd
)
{
let
percent
=
this
.
video
.
currentTime
/
this
.
video
.
getDuration
();
percent
=
percent
<
0
?
0
:
percent
;
percent
=
percent
>
1
?
1
:
percent
;
console
.
log
(
'
this.video.currentTime:
'
,
this
.
video
.
currentTime
);
console
.
log
(
'
this.video.getDuration():
'
,
this
.
video
.
getDuration
());
console
.
log
(
'
percent:
'
,
percent
);
this
.
progressJs
.
setProgress
(
percent
);
}
}
}
assets/ns_video_map/script/util.ts
View file @
c48ab451
import
{
tweenChange
}
from
"
../../../form/src/app/play/Unit
"
;
export
function
getPosByAngle
(
angle
,
len
)
{
const
radian
=
angle
*
Math
.
PI
/
180
;
...
...
@@ -174,6 +176,15 @@ export function playAudio(audioClip, cb = null) {
}
}
export
function
delayCall
(
callback
,
second
)
{
cc
.
tween
({})
.
delay
(
second
)
.
call
(()
=>
{
callback
&&
callback
();
})
}
export
async
function
asyncDelay
(
time
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
try
{
...
...
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