Commit 35ac3460 authored by 李维's avatar 李维

调整进度条自动隐藏

parent d215459d
...@@ -23,8 +23,14 @@ cc.Class({ ...@@ -23,8 +23,14 @@ cc.Class({
playBtn: null, // 播放按钮 playBtn: null, // 播放按钮
pauseBtn: null, // 暂停按钮 pauseBtn: null, // 暂停按钮
replayBtn: null, // 重播按钮 replayBtn: null, // 重播按钮
properties: {
setTimeoutIDs: [],
setIntervalIDs: [],
},
init() { init() {
console.log("Init video control component.") // console.log("Init video control component.")
this.bgProgress = cc.find('progress', this.node); this.bgProgress = cc.find('progress', this.node);
this.bar = cc.find('progress/bar', this.node); this.bar = cc.find('progress/bar', this.node);
this.dragBtn = cc.find('dragButton', this.node); this.dragBtn = cc.find('dragButton', this.node);
...@@ -80,9 +86,8 @@ cc.Class({ ...@@ -80,9 +86,8 @@ cc.Class({
this.node.emit('on_drag_percent', percent) this.node.emit('on_drag_percent', percent)
}); });
this.dragBtn.off(cc.Node.EventType.TOUCH_ENDED); this.dragBtn.off(cc.Node.EventType.TOUCH_END);
this.dragBtn.on(cc.Node.EventType.TOUCH_ENDED, (e) => { this.dragBtn.on(cc.Node.EventType.TOUCH_END, (e) => {
// console.log("用户抬手-1");
if(this.userDragStart) { if(this.userDragStart) {
this.userDragStart = false; this.userDragStart = false;
this.node.emit('on_drag_button', false); this.node.emit('on_drag_button', false);
...@@ -91,7 +96,6 @@ cc.Class({ ...@@ -91,7 +96,6 @@ cc.Class({
this.dragBtn.off(cc.Node.EventType.MOUSE_UP); this.dragBtn.off(cc.Node.EventType.MOUSE_UP);
this.dragBtn.on(cc.Node.EventType.MOUSE_UP, (e) => { this.dragBtn.on(cc.Node.EventType.MOUSE_UP, (e) => {
// console.log("用户抬手-2");
if(this.userDragStart) { if(this.userDragStart) {
this.userDragStart = false; this.userDragStart = false;
this.node.emit('on_drag_button', false); this.node.emit('on_drag_button', false);
...@@ -100,7 +104,6 @@ cc.Class({ ...@@ -100,7 +104,6 @@ cc.Class({
this.dragBtn.off(cc.Node.EventType.TOUCH_CANCEL); this.dragBtn.off(cc.Node.EventType.TOUCH_CANCEL);
this.dragBtn.on(cc.Node.EventType.TOUCH_CANCEL, (e) => { this.dragBtn.on(cc.Node.EventType.TOUCH_CANCEL, (e) => {
// console.log("用户抬手-3");
if(this.userDragStart) { if(this.userDragStart) {
this.userDragStart = false; this.userDragStart = false;
this.node.emit('on_drag_button', false); this.node.emit('on_drag_button', false);
...@@ -108,7 +111,6 @@ cc.Class({ ...@@ -108,7 +111,6 @@ cc.Class({
}); });
}, },
// 0:暂停 1:播放中 2:重播 // 0:暂停 1:播放中 2:重播
videoStatus: null, videoStatus: null,
refreshVideoBtnState(status) { refreshVideoBtnState(status) {
...@@ -139,7 +141,7 @@ cc.Class({ ...@@ -139,7 +141,7 @@ cc.Class({
addListener() { addListener() {
this.node.on('video_play_end', () => { this.node.on('video_play_end', () => {
console.log("video_play_end"); // console.log("video_play_end");
this.refreshVideoBtnState(); this.refreshVideoBtnState();
}) })
...@@ -153,12 +155,20 @@ cc.Class({ ...@@ -153,12 +155,20 @@ cc.Class({
}) })
this.node.on('update_video_status', (status)=>{ this.node.on('update_video_status', (status)=>{
console.log("update_video_status", status); // console.log("update_video_status", status);
this.refreshVideoBtnState(status); this.refreshVideoBtnState(status);
}) })
this.node.on('hide_bar', (withAnimation)=>{
this.hideBar(withAnimation);
})
this.node.on('show_bar', (withAnimation)=>{
this.showBar(withAnimation);
})
this.node.on("set_mark_points", (data)=>{ this.node.on("set_mark_points", (data)=>{
console.log("set_mark_points") // console.log("set_mark_points")
const markPoint = cc.find("markPoint", this.node); const markPoint = cc.find("markPoint", this.node);
const markPointsContainer = cc.find("markNode", this.node); const markPointsContainer = cc.find("markNode", this.node);
for(let i=0; i<data.length; i++) { for(let i=0; i<data.length; i++) {
...@@ -170,6 +180,49 @@ cc.Class({ ...@@ -170,6 +180,49 @@ cc.Class({
}) })
}, },
// 显示进度条
showBar(withAnimation) {
const widget = this.node.getComponent(cc.Widget);
if(withAnimation) {
widget.bottom = -100;
let count = 10;
let step = 200 / count;
const _intervalId = setInterval(()=>{
widget.bottom+=step;
count--;
if(count <=0) {
widget.bottom = 100;
clearInterval(_intervalId)
}
},30)
this.setIntervalIDs.push(_intervalId);
} else {
widget.bottom = 100;
}
},
// 隐藏进度条
hideBar(withAnimation) {
const widget = this.node.getComponent(cc.Widget);
if(withAnimation) {
widget.bottom = 100;
let count = 10;
let step = 200 / count;
const _intervalId = setInterval(()=>{
widget.bottom-=step;
count--;
if(count <=0) {
widget.bottom = -100;
clearInterval(_intervalId)
}
},30)
this.setIntervalIDs.push(_intervalId);
} else {
widget.bottom = -100;
}
},
setProgress(progress) { setProgress(progress) {
const dragStartX = -520; const dragStartX = -520;
setTimeout(() => { setTimeout(() => {
...@@ -180,4 +233,10 @@ cc.Class({ ...@@ -180,4 +233,10 @@ cc.Class({
} }
}, 1); }, 1);
}, },
onDestroy() {
for(let i=0; i<this.setIntervalIDs.length; i++) {
clearInterval(this.setIntervalIDs[i]);
}
}
}); });
...@@ -749,8 +749,8 @@ ...@@ -749,8 +749,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 100,
-320, -370,
0, 0,
0, 0,
0, 0,
...@@ -1697,15 +1697,15 @@ ...@@ -1697,15 +1697,15 @@
"__id__": 15 "__id__": 15
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 2,
"_target": null, "_target": null,
"_alignFlags": 20, "_alignFlags": 20,
"_left": 0, "_left": 0,
"_right": 0, "_right": 0,
"_top": 100, "_top": 100,
"_bottom": 150, "_bottom": 100,
"_verticalCenter": 0, "_verticalCenter": 0,
"_horizontalCenter": 0, "_horizontalCenter": 100,
"_isAbsLeft": true, "_isAbsLeft": true,
"_isAbsRight": true, "_isAbsRight": true,
"_isAbsTop": true, "_isAbsTop": true,
......
This diff is collapsed.
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