Commit fda2e532 authored by Tt's avatar Tt

处理完成

parent d38b7c43
......@@ -5325,9 +5325,6 @@
"ProgressBar": {
"__id__": 115
},
"videoPlayer": {
"__id__": 14
},
"currentTimeLabel": {
"__id__": 129
},
......
......@@ -18,7 +18,7 @@ export default class dg29_museum_game extends cc.Component {
this.initData();
this.initView();
this.initEvent();
this.initVideoPlayer();
// this.initVideoPlayer();
this.initGame();
}
......@@ -262,6 +262,10 @@ export default class dg29_museum_game extends cc.Component {
}
onTouchNext() {
console.log('next')
if(this.gameEnd){
this.onTouchExit();
return
}
if (this.recording) return;
if (!this.nextQuestion) {
pg.view.find(this, 'layout_game/layout_record/img_question').active = false;
......@@ -286,7 +290,7 @@ export default class dg29_museum_game extends cc.Component {
//-----------------------------------------Video------------------------------
@property(cc.Node) barTag: cc.Node = null;
@property(cc.Node) ProgressBar: cc.Node = null;
@property(cc.VideoPlayer) videoPlayer: cc.VideoPlayer = null;
// @property(cc.VideoPlayer) videoPlayer: cc.VideoPlayer = null;
@property(cc.Label) currentTimeLabel: cc.Label = null;
......@@ -311,61 +315,61 @@ export default class dg29_museum_game extends cc.Component {
}
@property(cc.Node) video_canvas: cc.Node = null;
hideVideoPlayer() {
if (!this.node) return;
if (!this.videoPlayer) return;
if (!this.layout_video) return;
this.layout_video.active = true;
this.videoPlayer.stayOnBottom = true;
this.videoPlayer.node.x = 0;
this.videoPlayer.node.y = 0;
this.videoPlayer.node.width = 100;
this.videoPlayer.node.height = 100;
}
showVideoPlayer() {
if (!this.node) return;
if (!this.videoPlayer) return;
if (!this.layout_video) return;
this.hideUI();
this.scheduleOnce(() => {
this.layout_video.active = true;
this.videoPlayer.stayOnBottom = true;
this.videoPlayer.node.x = this.video_canvas.x;
this.videoPlayer.node.y = this.video_canvas.y;
this.videoPlayer.node.width = this.video_canvas.width;
this.videoPlayer.node.height = this.video_canvas.height;
if (!this._isReadyToPlay) {
//首次播放
this._isReadyToPlay = false;
// this.videoPlayer.remoteURL = this.data.video;
pg.view.touchOn(this.playButton, this.play, this);
pg.view.touchOn(this.pauseButton, this.pause, this);
}
//重复播放
this.videoPlayer.currentTime = 0;
this._isPlayComplated = false;
this.play();
this.scheduleOnce(() => {
if (!this.node) return;
if (!this.videoPlayer) return;
if (!this.layout_video) return;
this.videoPlayer.stayOnBottom = false;
this.videoControls.active = false;
}, 3);
}, 0.1)
}
// hideVideoPlayer() {
// if (!this.node) return;
// if (!this.videoPlayer) return;
// if (!this.layout_video) return;
// this.layout_video.active = true;
// this.videoPlayer.stayOnBottom = true;
// this.videoPlayer.node.x = 0;
// this.videoPlayer.node.y = 0;
// this.videoPlayer.node.width = 100;
// this.videoPlayer.node.height = 100;
// }
// showVideoPlayer() {
// if (!this.node) return;
// if (!this.videoPlayer) return;
// if (!this.layout_video) return;
// this.hideUI();
// this.scheduleOnce(() => {
// this.layout_video.active = true;
// this.videoPlayer.stayOnBottom = true;
// this.videoPlayer.node.x = this.video_canvas.x;
// this.videoPlayer.node.y = this.video_canvas.y;
// this.videoPlayer.node.width = this.video_canvas.width;
// this.videoPlayer.node.height = this.video_canvas.height;
// if (!this._isReadyToPlay) {
// //首次播放
// this._isReadyToPlay = false;
// // this.videoPlayer.remoteURL = this.data.video;
// pg.view.touchOn(this.playButton, this.play, this);
// pg.view.touchOn(this.pauseButton, this.pause, this);
// }
// //重复播放
// this.videoPlayer.currentTime = 0;
// this._isPlayComplated = false;
// this.play();
// this.scheduleOnce(() => {
// if (!this.node) return;
// if (!this.videoPlayer) return;
// if (!this.layout_video) return;
// this.videoPlayer.stayOnBottom = false;
// this.videoControls.active = false;
// }, 3);
// }, 0.1)
// }
private timeCtrl: TimeCtrl;
showVideo() {
return new Promise(async (reslove) => {
this.hideUI();
pg.event.emit("play_video")
if (1) return;
this.showVideoPlayer();
// if (1) return;
// this.showVideoPlayer();
this.timeCtrl = pg.time.delayCtrl()
this.timeCtrl.fillTime(99999);
await this.timeCtrl.wait();
......@@ -374,155 +378,155 @@ export default class dg29_museum_game extends cc.Component {
}
hideVideo() {
this.timeCtrl.reset();
this.videoPlayer.node.x = -10000;
this.videoPlayer.node.y = -10000;
// this.videoPlayer.node.x = -10000;
// this.videoPlayer.node.y = -10000;
this.layout_video.active = false;
this.showUI();
}
initVideoUrl() {
this.prepared = true;
this.touchlayer.on(cc.Node.EventType.TOUCH_START, this.tryPlayVideo, this)
this.touchlayer._touchListener.setSwallowTouches(false)
this.videoPlayer.node.active = true;
this.videoPlayer.remoteURL = this.data.video;
this.videoPlayer.resourceType = cc.VideoPlayer.ResourceType.REMOTE;
}
private prepared: boolean;
tryPlayVideo() {
cc.log("touch layer--")
if (this.prepared) {
this.prepared = false;
this.videoPlayer.volume = 0;
this.videoPlayer.play();
this.scheduleOnce(() => {
this.videoPlayer.volume = 1;
this.videoPlayer.pause();
}, 1)
}
}
initVideoPlayer() {
if (1) return;
this.initVideoUrl();
this.videoPlayer.node.x = -10000;
this.videoPlayer.node.y = -10000;
this.layout_video.active = false;
// this.videoPlayer.node.on('ready-to-play', () => {
// console.log('ready-to-play');
// this._isReadyToPlay = true;
// this._isPlayComplated = false;
// this.videoPlayer.currentTime = 0;
// });
// this.videoPlayer.node.on('meta-loaded', () => {
// console.log('meta-loaded');
// });
// this.videoPlayer.node.on('clicked', () => {
// if (!this.node) return;
// if (!this.videoPlayer) return;
// if (!this.layout_video) return;
// this.videoPlayer.stayOnBottom = true;
// this.videoControls.active = true;
// if (this.time1) {
// clearTimeout(this.time1);
// }
// this.time1 = setTimeout(() => {
// if (!this.node) return;
// if (!this.videoPlayer) return;
// if (!this.layout_video) return;
// this.videoPlayer.stayOnBottom = false;
// this.videoControls.active = false;
// }, 6000);
// });
// this.videoPlayer.node.on('touchstart', () => {
// if (!this.node) return;
// if (!this.videoPlayer) return;
// if (!this.layout_video) return;
// this.videoPlayer.stayOnBottom = true;
// this.videoControls.active = true;
// if (this.time1) {
// clearTimeout(this.time1);
// }
// this.time1 = setTimeout(() => {
// if (!this.node) return;
// if (!this.videoPlayer) return;
// if (!this.layout_video) return;
// this.videoPlayer.stayOnBottom = false;
// this.videoControls.active = false;
// }, 6000);
// });
// this.videoPlayer.node.on('playing', () => {
// this.playButton.active = false;
// this.pauseButton.active = true;
// });
// this.videoPlayer.node.on('paused', () => {
// console.log('paused');
// this.playButton.active = true;
// this.pauseButton.active = false;
// });
// this.videoPlayer.node.on('stopped', () => {
// console.log('stopped');
// this.playButton.active = true;
// this.pauseButton.active = false;
// });
// this.videoPlayer.node.on('completed', async () => {
// console.log('completed');
// this._isPlayComplated = true;
// this.playButton.active = false;
// this.pauseButton.active = false;
// // 循环播放下一个
// this.hideVideo();
// });
// cc.view.setResizeCallback((params) => {
// console.log('Resize', params);
// this.initdDrag()
// });
// this.initdDrag();
}
initdDrag() {
const maxX = this.ProgressBar.width;
const minX = 0;
this.barTag.off(cc.Node.EventType.TOUCH_START);
this.barTag.on(cc.Node.EventType.TOUCH_START, (e) => {
if (!this._isReadyToPlay) {
return;
}
console.log("TOUCH_START");
});
this.barTag.off(cc.Node.EventType.TOUCH_MOVE);
this.barTag.on(cc.Node.EventType.TOUCH_MOVE, (e) => {
if (!this._isReadyToPlay) {
return;
}
const worldPos = e.getLocation();
const localPos = this.barTag.parent.convertToNodeSpaceAR(worldPos);
let newX = localPos.x;
newX = Math.min(maxX, Math.max(newX, minX));
this.barTag.x = newX;
const percent = newX / maxX;
const dur = this.videoPlayer.getDuration();
this.currentTimeLabel.string = this.formatTime(percent * dur);
this.videoPlayer.currentTime = percent * dur;
});
this.barTag.off(cc.Node.EventType.TOUCH_END);
this.barTag.on(cc.Node.EventType.TOUCH_END, (e) => {
if (!this._isReadyToPlay) {
return;
}
console.log("TOUCH_ENDED");
this.updateBarByPos(this.barTag.x);
});
this.barTag.off(cc.Node.EventType.MOUSE_UP);
this.barTag.on(cc.Node.EventType.MOUSE_UP, (e) => {
if (!this._isReadyToPlay) {
return;
}
console.log("MOUSE_UP");
this.updateBarByPos(this.barTag.x);
});
}
// initVideoUrl() {
// this.prepared = true;
// this.touchlayer.on(cc.Node.EventType.TOUCH_START, this.tryPlayVideo, this)
// this.touchlayer._touchListener.setSwallowTouches(false)
// this.videoPlayer.node.active = true;
// this.videoPlayer.remoteURL = this.data.video;
// this.videoPlayer.resourceType = cc.VideoPlayer.ResourceType.REMOTE;
// }
// private prepared: boolean;
// tryPlayVideo() {
// cc.log("touch layer--")
// if (this.prepared) {
// this.prepared = false;
// this.videoPlayer.volume = 0;
// this.videoPlayer.play();
// this.scheduleOnce(() => {
// this.videoPlayer.volume = 1;
// this.videoPlayer.pause();
// }, 1)
// }
// }
// initVideoPlayer() {
// if (1) return;
// this.initVideoUrl();
// this.videoPlayer.node.x = -10000;
// this.videoPlayer.node.y = -10000;
// this.layout_video.active = false;
// // this.videoPlayer.node.on('ready-to-play', () => {
// // console.log('ready-to-play');
// // this._isReadyToPlay = true;
// // this._isPlayComplated = false;
// // this.videoPlayer.currentTime = 0;
// // });
// // this.videoPlayer.node.on('meta-loaded', () => {
// // console.log('meta-loaded');
// // });
// // this.videoPlayer.node.on('clicked', () => {
// // if (!this.node) return;
// // if (!this.videoPlayer) return;
// // if (!this.layout_video) return;
// // this.videoPlayer.stayOnBottom = true;
// // this.videoControls.active = true;
// // if (this.time1) {
// // clearTimeout(this.time1);
// // }
// // this.time1 = setTimeout(() => {
// // if (!this.node) return;
// // if (!this.videoPlayer) return;
// // if (!this.layout_video) return;
// // this.videoPlayer.stayOnBottom = false;
// // this.videoControls.active = false;
// // }, 6000);
// // });
// // this.videoPlayer.node.on('touchstart', () => {
// // if (!this.node) return;
// // if (!this.videoPlayer) return;
// // if (!this.layout_video) return;
// // this.videoPlayer.stayOnBottom = true;
// // this.videoControls.active = true;
// // if (this.time1) {
// // clearTimeout(this.time1);
// // }
// // this.time1 = setTimeout(() => {
// // if (!this.node) return;
// // if (!this.videoPlayer) return;
// // if (!this.layout_video) return;
// // this.videoPlayer.stayOnBottom = false;
// // this.videoControls.active = false;
// // }, 6000);
// // });
// // this.videoPlayer.node.on('playing', () => {
// // this.playButton.active = false;
// // this.pauseButton.active = true;
// // });
// // this.videoPlayer.node.on('paused', () => {
// // console.log('paused');
// // this.playButton.active = true;
// // this.pauseButton.active = false;
// // });
// // this.videoPlayer.node.on('stopped', () => {
// // console.log('stopped');
// // this.playButton.active = true;
// // this.pauseButton.active = false;
// // });
// // this.videoPlayer.node.on('completed', async () => {
// // console.log('completed');
// // this._isPlayComplated = true;
// // this.playButton.active = false;
// // this.pauseButton.active = false;
// // // 循环播放下一个
// // this.hideVideo();
// // });
// // cc.view.setResizeCallback((params) => {
// // console.log('Resize', params);
// // this.initdDrag()
// // });
// // this.initdDrag();
// }
// initdDrag() {
// const maxX = this.ProgressBar.width;
// const minX = 0;
// this.barTag.off(cc.Node.EventType.TOUCH_START);
// this.barTag.on(cc.Node.EventType.TOUCH_START, (e) => {
// if (!this._isReadyToPlay) {
// return;
// }
// console.log("TOUCH_START");
// });
// this.barTag.off(cc.Node.EventType.TOUCH_MOVE);
// this.barTag.on(cc.Node.EventType.TOUCH_MOVE, (e) => {
// if (!this._isReadyToPlay) {
// return;
// }
// const worldPos = e.getLocation();
// const localPos = this.barTag.parent.convertToNodeSpaceAR(worldPos);
// let newX = localPos.x;
// newX = Math.min(maxX, Math.max(newX, minX));
// this.barTag.x = newX;
// const percent = newX / maxX;
// const dur = this.videoPlayer.getDuration();
// this.currentTimeLabel.string = this.formatTime(percent * dur);
// this.videoPlayer.currentTime = percent * dur;
// });
// this.barTag.off(cc.Node.EventType.TOUCH_END);
// this.barTag.on(cc.Node.EventType.TOUCH_END, (e) => {
// if (!this._isReadyToPlay) {
// return;
// }
// console.log("TOUCH_ENDED");
// this.updateBarByPos(this.barTag.x);
// });
// this.barTag.off(cc.Node.EventType.MOUSE_UP);
// this.barTag.on(cc.Node.EventType.MOUSE_UP, (e) => {
// if (!this._isReadyToPlay) {
// return;
// }
// console.log("MOUSE_UP");
// this.updateBarByPos(this.barTag.x);
// });
// }
playVideoEnd() {
this.hideVideo();
......@@ -552,7 +556,7 @@ export default class dg29_museum_game extends cc.Component {
}
else if (event === cc.VideoPlayer.EventType.COMPLETED) {
this._isPlayComplated = true;
// this._isPlayComplated = true;
this.playButton.active = false;
this.pauseButton.active = false;
// 循环播放下一个
......@@ -580,108 +584,108 @@ export default class dg29_museum_game extends cc.Component {
}
}
updateBarByPos(newX) {
const maxX = this.ProgressBar.width;
const minX = 0;
let percent = newX / maxX;
if (percent > 1) {
percent = 1
}
const dur = this.videoPlayer.getDuration();
this.videoPlayer.currentTime = percent * dur
}
private _isPlayComplated: boolean
updateBarByTime(ct) {
if (this._isPlayComplated) {
return;
}
this.currentTimeLabel.string = this.formatTime(ct);
const dur = this.videoPlayer.getDuration();
let percent = ct / dur;
if (percent > 1) {
percent = 1
}
this.ProgressBar.getComponent(cc.ProgressBar).progress = percent;
const maxX = this.ProgressBar.width;
const minX = 0;
let newX = percent * maxX;
newX = Math.min(maxX, Math.max(newX, minX));
this.barTag.x = newX;
}
formatTime(time) {
if (time === undefined) {
return '';
}
let hh = "" + Math.floor(time / 60 / 60);
if (Number(hh) > 0) {
hh = `${hh.toString().padStart(2, '0')}:`;
} else {
hh = '';
}
const mm = Math.floor(time / 60).toString().padStart(2, '0');
const ss = Math.round(time % 60).toString().padStart(2, '0');
return `${hh}${mm}:${ss}`;
}
play() {
if (!this._isReadyToPlay) return;
this.videoPlayer.play();
}
pause() {
this.videoPlayer.pause();
}
forward() {
}
backward() {
}
replay() {
this._isPlayComplated = false;
this.videoPlayer.currentTime = 0;
this.videoPlayer.play();
}
private time1: any;
private isVideoFull: boolean;//false,
private tempPos: any;
fullScreen() {
// setTimeout(() => {
// // IOS下视频的全屏适配比例有问题,所以做一个计算
// this.videoPlayer.node.width = Math.min(this.node.width, this.node.height * 16 / 9);
// }, 100);
}
updateVideo() {
if (!this._isReadyToPlay) {
return;
}
if (this.videoPlayer) {
const ct = this.videoPlayer.currentTime;
if (ct) {
this.updateBarByTime(ct);
}
if (this.videoPlayer.isPlaying()) {
if (this.playButton.active) {
this.playButton.active = false;
}
if (!this.pauseButton.active) {
this.pauseButton.active = true;
}
} else {
if (!this.playButton.active) {
this.playButton.active = true;
}
if (this.pauseButton.active) {
this.pauseButton.active = false;
}
}
}
}
// updateBarByPos(newX) {
// const maxX = this.ProgressBar.width;
// const minX = 0;
// let percent = newX / maxX;
// if (percent > 1) {
// percent = 1
// }
// const dur = this.videoPlayer.getDuration();
// this.videoPlayer.currentTime = percent * dur
// }
// private _isPlayComplated: boolean
// updateBarByTime(ct) {
// if (this._isPlayComplated) {
// return;
// }
// this.currentTimeLabel.string = this.formatTime(ct);
// const dur = this.videoPlayer.getDuration();
// let percent = ct / dur;
// if (percent > 1) {
// percent = 1
// }
// this.ProgressBar.getComponent(cc.ProgressBar).progress = percent;
// const maxX = this.ProgressBar.width;
// const minX = 0;
// let newX = percent * maxX;
// newX = Math.min(maxX, Math.max(newX, minX));
// this.barTag.x = newX;
// }
// formatTime(time) {
// if (time === undefined) {
// return '';
// }
// let hh = "" + Math.floor(time / 60 / 60);
// if (Number(hh) > 0) {
// hh = `${hh.toString().padStart(2, '0')}:`;
// } else {
// hh = '';
// }
// const mm = Math.floor(time / 60).toString().padStart(2, '0');
// const ss = Math.round(time % 60).toString().padStart(2, '0');
// return `${hh}${mm}:${ss}`;
// }
// play() {
// if (!this._isReadyToPlay) return;
// this.videoPlayer.play();
// }
// pause() {
// this.videoPlayer.pause();
// }
// forward() {
// }
// backward() {
// }
// replay() {
// this._isPlayComplated = false;
// this.videoPlayer.currentTime = 0;
// this.videoPlayer.play();
// }
// private time1: any;
// private isVideoFull: boolean;//false,
// private tempPos: any;
// fullScreen() {
// // setTimeout(() => {
// // // IOS下视频的全屏适配比例有问题,所以做一个计算
// // this.videoPlayer.node.width = Math.min(this.node.width, this.node.height * 16 / 9);
// // }, 100);
// }
// updateVideo() {
// if (!this._isReadyToPlay) {
// return;
// }
// if (this.videoPlayer) {
// const ct = this.videoPlayer.currentTime;
// if (ct) {
// this.updateBarByTime(ct);
// }
// if (this.videoPlayer.isPlaying()) {
// if (this.playButton.active) {
// this.playButton.active = false;
// }
// if (!this.pauseButton.active) {
// this.pauseButton.active = true;
// }
// } else {
// if (!this.playButton.active) {
// this.playButton.active = true;
// }
// if (this.pauseButton.active) {
// this.pauseButton.active = false;
// }
// }
// }
// }
//----------------------------------------VideoEND-------------------------
showData(data) {
......@@ -708,7 +712,7 @@ export default class dg29_museum_game extends cc.Component {
private waitTime: number;
update(dt) {
this.showTimeUpdate();
this.updateVideo();
// this.updateVideo();
if (!this.waitTime) this.waitTime = 8;
this.waitTime -= dt;
if (this.waitTime < 0) {
......@@ -724,7 +728,7 @@ export default class dg29_museum_game extends cc.Component {
pg.view.find(this, 'layout_xiaodi/btn_go').active = true;
}, 0.5)
}
pg.view.touchOn(pg.view.find(this, 'layout_xiaodi/btn_go'), this.onTouchExit, this);
// pg.view.touchOn(pg.view.find(this, 'layout_xiaodi/btn_go'), this.onTouchExit, this);
pg.view.setString(pg.view.find(this, 'layout_xiaodi/btn_go/text'), this.data.npcAudioText)
pg.view.find(this, 'layout_xiaodi').active = true;
pg.view.find(this, 'layout_xiaodi').getComponent(dg_xiaodi).playOver(this.data.npcAudioEnd)
......@@ -734,7 +738,9 @@ export default class dg29_museum_game extends cc.Component {
pg.view.find(this, 'layout_xiaodi').active = false;
pg.view.find(this, 'layout_xiaodi').getComponent(dg_xiaodi).playOverEnd()
}
private gameEnd : boolean;
private gameOver() {
this.gameEnd = true;
this.rich_content.active = false;
// 按钮显示未下一题的显示内容
this.showXiaodi();
......
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