Commit c48ab451 authored by limingzhe's avatar limingzhe

feat: 视频进度条

parent 4cc43555
{
"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
{
"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
// 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) {},
});
{
"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
[
{
"__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
{
"ver": "1.2.9",
"uuid": "3d356c4d-cb23-4239-aa5f-8a913f420fa4",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"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
{
"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
{
"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
...@@ -81,19 +81,22 @@ ...@@ -81,19 +81,22 @@
"__id__": 14 "__id__": 14
}, },
{ {
"__id__": 16 "__id__": 21
},
{
"__id__": 23
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 25 "__id__": 32
}, },
{ {
"__id__": 26 "__id__": 33
}, },
{ {
"__id__": 27 "__id__": 34
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -221,7 +224,7 @@ ...@@ -221,7 +224,7 @@
"r": 0, "r": 0,
"g": 0, "g": 0,
"b": 0, "b": 0,
"a": 255 "a": 0
}, },
"_depth": -1, "_depth": -1,
"_zoomRatio": 1, "_zoomRatio": 1,
...@@ -549,7 +552,7 @@ ...@@ -549,7 +552,7 @@
"_mute": false, "_mute": false,
"_isFullscreen": false, "_isFullscreen": false,
"_N$isFullscreen": false, "_N$isFullscreen": false,
"_stayOnBottom": false, "_stayOnBottom": true,
"videoPlayerEvent": [], "videoPlayerEvent": [],
"_N$keepAspectRatio": true, "_N$keepAspectRatio": true,
"_id": "0255cviSdDeJCrRG6RjufJ" "_id": "0255cviSdDeJCrRG6RjufJ"
...@@ -608,6 +611,237 @@ ...@@ -608,6 +611,237 @@
"_originalHeight": 0, "_originalHeight": 0,
"_id": "a23aWB9GtG4LDLOLKjwL1m" "_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", "__type__": "cc.Node",
"_name": "btn_skip", "_name": "btn_skip",
...@@ -619,7 +853,7 @@ ...@@ -619,7 +853,7 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 15 "__id__": 22
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -645,8 +879,8 @@ ...@@ -645,8 +879,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 446.742,
-275.804, -301.61,
0, 0,
0, 0,
0, 0,
...@@ -675,7 +909,7 @@ ...@@ -675,7 +909,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 14 "__id__": 21
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -711,10 +945,10 @@ ...@@ -711,10 +945,10 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 17 "__id__": 24
}, },
{ {
"__id__": 20 "__id__": 27
} }
], ],
"_active": false, "_active": false,
...@@ -772,11 +1006,11 @@ ...@@ -772,11 +1006,11 @@
"_name": "font", "_name": "font",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 16 "__id__": 23
}, },
"_children": [ "_children": [
{ {
"__id__": 18 "__id__": 25
} }
], ],
"_active": true, "_active": true,
...@@ -834,13 +1068,13 @@ ...@@ -834,13 +1068,13 @@
"_name": "BRLNSDB", "_name": "BRLNSDB",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 17 "__id__": 24
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 19 "__id__": 26
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -896,7 +1130,7 @@ ...@@ -896,7 +1130,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 18 "__id__": 25
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [],
...@@ -927,14 +1161,14 @@ ...@@ -927,14 +1161,14 @@
"_name": "img", "_name": "img",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 16 "__id__": 23
}, },
"_children": [ "_children": [
{ {
"__id__": 21 "__id__": 28
}, },
{ {
"__id__": 23 "__id__": 30
} }
], ],
"_active": true, "_active": true,
...@@ -992,13 +1226,13 @@ ...@@ -992,13 +1226,13 @@
"_name": "btn_right", "_name": "btn_right",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 20 "__id__": 27
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 22 "__id__": 29
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1054,7 +1288,7 @@ ...@@ -1054,7 +1288,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 21 "__id__": 28
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [],
...@@ -1082,13 +1316,13 @@ ...@@ -1082,13 +1316,13 @@
"_name": "icon", "_name": "icon",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 20 "__id__": 27
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 24 "__id__": 31
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1144,7 +1378,7 @@ ...@@ -1144,7 +1378,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 23 "__id__": 30
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [],
......
import { asyncDelay, onHomeworkFinish } from "../script/util"; import { asyncDelay, delayCall, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
...@@ -40,6 +41,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -40,6 +41,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.setTransparentCanvas(); this.setTransparentCanvas();
this.initVideo(); this.initVideo();
this.initBtn(); this.initBtn();
this.initProgress();
// this.initBg(); // this.initBg();
// this.initPic(); // this.initPic();
// this.initBtn(); // this.initBtn();
...@@ -51,8 +53,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -51,8 +53,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
const canvas = cc.find("Canvas"); const canvas = cc.find("Canvas");
const jumpBtn = cc.find("Canvas/btn_skip"); //this.getSprNode('btn_right'); const jumpBtn = cc.find("Canvas/btn_skip"); //this.getSprNode('btn_right');
canvas.on('touchstart', () => { jumpBtn.on('touchstart', () => {
this.videoPlayEnd(); this.videoPlayEnd();
}) })
...@@ -80,11 +82,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -80,11 +82,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
video = null video = null
initVideo() { initVideo() {
// if (this.data.video_url) { if (this.data.video_url) {
// this.initVideoRemote(); this.initVideoRemote();
// } else { } else {
this.initVideoLocal(); this.initVideoLocal();
// } }
this.video.node.on('completed', () => { this.video.node.on('completed', () => {
...@@ -96,25 +98,83 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -96,25 +98,83 @@ export default class SceneComponent extends MyCocosSceneComponent {
isPlayEnd = null isPlayEnd = null
videoPlayEnd() { videoPlayEnd() {
console.log(' in videoPlayEnd')
if (this.isPlayEnd) { if (this.isPlayEnd) {
return return
} }
this.isPlayEnd = true; this.isPlayEnd = true;
if (this.video) {
this.video.pause();
}
onHomeworkFinish(); onHomeworkFinish();
} }
initVideoLocal() { initVideoLocal() {
console.log(' in initVideoLocal') console.log(' in initVideoLocal')
const videoLocalNode = cc.find("Canvas/videoBase/videoLocal"); const videoLocalNode = cc.find("Canvas/videoBase/videoLocal");
const video = videoLocalNode.getComponent(cc.VideoPlayer); const video = videoLocalNode.getComponent(cc.VideoPlayer);
video.isFullscreen = true; 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); // videoLocalNode.on("ready-to-play", () => {
video.play(); // console.log('in ready-to-play ');
// playVideo();
// })
// console.log("video: ", video);
// video.play();
this.video = video; 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() { initVideoRemote() {
...@@ -129,25 +189,25 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -129,25 +189,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
videoRemoteNode.parent = videoLocalNode.parent; videoRemoteNode.parent = videoLocalNode.parent;
const video = videoRemoteNode.addComponent(cc.VideoPlayer); const video = videoRemoteNode.addComponent(cc.VideoPlayer);
let isCanPlay = false; // let isCanPlay = false;
const playVideo = ()=> { // const playVideo = ()=> {
if (isCanPlay) { // if (isCanPlay) {
return; // return;
} // }
isCanPlay = true; // isCanPlay = true;
video.play(); // video.play();
} // }
videoRemoteNode.on("meta-loaded", () => { // videoRemoteNode.on("meta-loaded", () => {
console.log('in meta-loaded') // console.log('in meta-loaded')
playVideo(); // playVideo();
}) // })
videoRemoteNode.on("ready-to-play", () => { // videoRemoteNode.on("ready-to-play", () => {
console.log('in ready-to-play '); // console.log('in ready-to-play ');
playVideo(); // playVideo();
}) // })
video.resourceType = cc.VideoPlayer.ResourceType.REMOTE; video.resourceType = cc.VideoPlayer.ResourceType.REMOTE;
video.remoteURL = this.data.video_url; video.remoteURL = this.data.video_url;
...@@ -156,6 +216,41 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -156,6 +216,41 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.video = video; 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 { ...@@ -305,6 +400,34 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
// update (dt) {}, // 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() { initListener() {
...@@ -319,4 +442,18 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -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);
}
}
} }
import { tweenChange } from "../../../form/src/app/play/Unit";
export function getPosByAngle(angle, len) { export function getPosByAngle(angle, len) {
const radian = angle * Math.PI / 180; const radian = angle * Math.PI / 180;
...@@ -174,6 +176,15 @@ export function playAudio(audioClip, cb = null) { ...@@ -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) { export async function asyncDelay(time) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment