Commit 458fb94c authored by 李维's avatar 李维

添加进度条的起始结束时间

parent 8d8ddfb6
......@@ -31,19 +31,22 @@
},
{
"__id__": 24
},
{
"__id__": 27
}
],
"_active": true,
"_components": [
{
"__id__": 27
"__id__": 35
},
{
"__id__": 28
"__id__": 36
}
],
"_prefab": {
"__id__": 29
"__id__": 37
},
"_opacity": 255,
"_color": {
......@@ -997,6 +1000,300 @@
"fileId": "359axb3wRFnpR16d4pl6Xc",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "time_label",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 28
},
{
"__id__": 31
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 34
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-40,
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": "start",
"_objFlags": 0,
"_parent": {
"__id__": 27
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 29
}
],
"_prefab": {
"__id__": 30
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 80.08,
"height": 40.32
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-420,
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.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 28
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "00:00",
"_N$string": "00:00",
"_fontSize": 32,
"_lineHeight": 32,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "ccNtS6tAREr6Sy5ZaTAO9J",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "end",
"_objFlags": 0,
"_parent": {
"__id__": 27
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 32
}
],
"_prefab": {
"__id__": 33
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 80.08,
"height": 40.32
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
600,
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.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 31
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "59:59",
"_N$string": "59:59",
"_fontSize": 32,
"_lineHeight": 32,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "c84DQy/K9PAYM9A6xIjUsz",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "0fp0R7vBRMBo86syd5lDDT",
"sync": false
},
{
"__type__": "28e11HTXPtGa7wWg93PflND",
"_name": "",
......
......@@ -5,6 +5,25 @@
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
/**
* 视频进度条控制组件
* 发送消息的方式
* video_play_end - 视频播放完成后发送,可以将播放按钮调整为结束状态
* update_video_progress - 视频进度更新时调用,传入一个0-1之间的数值
* update_video_status - 更新按钮状态,需要一个参数 0:播放状态 1:暂停状态 2:停止状态
* hide_bar - 隐藏进度条
* show_bar - 显示进度条
* set_mark_points - 设置关键点标记 传入一个数组 [0.2, 0.25, 0.6, 1]
* set_start_end_label - 设置起始和结束,接受两个字符串类型的参数,如果不传参数或者传了空字符串就不显示标签, 第一个参数是起始时间,第二个是结束时间
*
* 直接script调用
* refreshVideoBtnState - 更新按钮状态,需要一个参数 0:播放状态 1:暂停状态 2:停止状态
* showBar - 显示进度条
* hideBar - 隐藏进度条
* setProgress - 设置进度,参数为0-1之间的一个数字
* setMarkPoints - 设置关键点标记 传入一个数组 [0.2, 0.25, 0.6, 1]
* setStartEndTimeLabel - 设置起始和结束,接受两个字符串类型的参数,如果不传参数或者传了空字符串就不显示标签, 第一个参数是起始时间,第二个是结束时间
*/
cc.Class({
extends: cc.Component,
......@@ -179,15 +198,11 @@ cc.Class({
})
this.node.on("set_mark_points", (data)=>{
// console.log("set_mark_points")
const markPoint = cc.find("markPoint", this.node);
const markPointsContainer = cc.find("markNode", this.node);
for(let i=0; i<data.length; i++) {
const newPoint = cc.instantiate(markPoint);
newPoint.x = -420 + this.bgProgress.width * data[i];
newPoint.active = true;
markPointsContainer.addChild(newPoint);
}
this.setMarkPoints(data);
})
this.node.on("set_start_end_label", (start, end)=>{
this.setStartEndTimeLabel(start, end);
})
this.node.off(cc.Node.EventType.TOUCH_START);
......@@ -270,6 +285,38 @@ cc.Class({
}, 1);
},
// 设置标记点
setMarkPoints(pArr) {
// console.log("set_mark_points")
const markPoint = cc.find("markPoint", this.node);
const markPointsContainer = cc.find("markNode", this.node);
for(let i=0; i<pArr.length; i++) {
const newPoint = cc.instantiate(markPoint);
newPoint.x = -420 + this.bgProgress.width * pArr[i];
newPoint.active = true;
markPointsContainer.addChild(newPoint);
}
},
// 设置开始和结束标签
setStartEndTimeLabel(start, end) {
const startLabel = cc.find("time_label/start", this.node).getComponent(cc.Label);
const endLabel = cc.find("time_label/end", this.node).getComponent(cc.Label);
if(start != null && start != undefined && startLabel != "") {
startLabel.active = true;
startLabel.string = start;
} else {
startLabel.active = false;
}
if(end != null && end != undefined && endLabel != "") {
endLabel.active = true;
endLabel.string = end;
} else {
endLabel.active = false;
}
},
onDestroy() {
for(let i=0; i<this.setIntervalIDs.length; i++) {
clearInterval(this.setIntervalIDs[i]);
......
This diff is collapsed.
......@@ -1365,6 +1365,10 @@ cc.Class({
// 时长获取到以后 可以计算题目点
this.setProgressBarMarkPoints();
// 设置进度条的起始和结束标签
this.videoControlBar.emit("set_start_end_label", "00:00", this.getEndTimeLabel(this.videoDuration))
if (this.jumpTime) {
this.resetQuesIndex(this.jumpTime);
this.initCurQues();
......@@ -1400,6 +1404,36 @@ cc.Class({
}
},
//秒数转化为时分秒
getEndTimeLabel(value) {
var secondTime = parseInt(value);// 秒
var minuteTime = 0;// 分
var hourTime = 0;// 小时
if(secondTime > 60) {//如果秒数大于60,将秒数转换成整数
//获取分钟,除以60取整数,得到整数分钟
minuteTime = parseInt(secondTime / 60);
//获取秒数,秒数取余,得到整数秒数
secondTime = parseInt(secondTime % 60);
//如果分钟大于60,将分钟转换成小时
if(minuteTime > 60) {
//获取小时,获取分钟除以60,得到整数小时
hourTime = parseInt(minuteTime / 60);
//获取小时后取余的分,获取分钟除以60取余的分
minuteTime = parseInt(minuteTime % 60);
}
}
var result = "" + parseInt(secondTime);
if(minuteTime > 0) {
result = "" + parseInt(minuteTime) + ":" + result;
}
if(hourTime > 0) {
result = "" + parseInt(hourTime) + ":" + result;
}
return result;
},
curVideoPlayEnd() {
if (this.playTimes == 0) {
return;
......
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