Commit acccaca8 authored by liujiangnan's avatar liujiangnan

feat

parent fb2dcfa5
...@@ -143,8 +143,8 @@ cc.Class({ ...@@ -143,8 +143,8 @@ cc.Class({
}, },
// use this for initialization // use this for initialization
_isPlayComplated: null,
onLoad () { onLoad () {
cc.debug.setDisplayStats(false); cc.debug.setDisplayStats(false);
this.initSize(); this.initSize();
...@@ -197,6 +197,7 @@ cc.Class({ ...@@ -197,6 +197,7 @@ cc.Class({
this.videoPlayer.node.on('completed', async () => { this.videoPlayer.node.on('completed', async () => {
console.log('completed'); console.log('completed');
// this.videoPlayer.currentTime = 0; // this.videoPlayer.currentTime = 0;
this._isPlayComplated = true;
this.playButton.node.active = false; this.playButton.node.active = false;
this.pauseButton.node.active = false; this.pauseButton.node.active = false;
this.restartButton.node.active = true; this.restartButton.node.active = true;
...@@ -226,15 +227,12 @@ cc.Class({ ...@@ -226,15 +227,12 @@ cc.Class({
this.barTag.off(cc.Node.EventType.TOUCH_MOVE); this.barTag.off(cc.Node.EventType.TOUCH_MOVE);
this.barTag.on(cc.Node.EventType.TOUCH_MOVE,(e) => { this.barTag.on(cc.Node.EventType.TOUCH_MOVE,(e) => {
var delta = e.getDelta(); var delta = e.getDelta();
let newX = this.barTag.x+delta.x; let newX = this.barTag.x+delta.x*2;
newX = Math.min(maxX, Math.max(newX, minX)); newX = Math.min(maxX, Math.max(newX, minX));
this.barTag.x = newX; this.barTag.x = newX;
const percent = newX / maxX; const percent = newX / maxX;
// console.log(newX, percent);
const dur = this.videoPlayer.getDuration(); const dur = this.videoPlayer.getDuration();
// this.videoPlayer.currentTime = percent * dur
// this.updateBarByPos(this.barTag.x);
this.currentTimeLabel.string = this.formatTime(percent * dur ); this.currentTimeLabel.string = this.formatTime(percent * dur );
this.triggerInteractive() this.triggerInteractive()
}); });
...@@ -378,6 +376,9 @@ cc.Class({ ...@@ -378,6 +376,9 @@ cc.Class({
this.videoPlayer.currentTime = percent * dur this.videoPlayer.currentTime = percent * dur
}, },
updateBarByTime(ct){ updateBarByTime(ct){
if (this._isPlayComplated) {
return;
}
this.currentTimeLabel.string = this.formatTime(ct); this.currentTimeLabel.string = this.formatTime(ct);
const dur = this.videoPlayer.getDuration(); const dur = this.videoPlayer.getDuration();
const percent = ct / dur; const percent = ct / dur;
...@@ -449,6 +450,7 @@ cc.Class({ ...@@ -449,6 +450,7 @@ cc.Class({
}, },
replay(){ replay(){
this._isPlayComplated = false;
this.videoPlayer.currentTime = 0; this.videoPlayer.currentTime = 0;
this.videoPlayer.play(); this.videoPlayer.play();
this.triggerInteractive(); this.triggerInteractive();
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 1280, "width": 1920,
"height": 720, "height": 1080,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"bg": { "bg": {
......
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