Commit dd07eea8 authored by Tt's avatar Tt

视频播放完成

parent 4e0035fe
This diff is collapsed.
import macro from '../script/A_Macro_dg18_tianci'
import { asyncDelay, onHomeworkFinish } from "../script/util_dg18_tianci";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_dg18_tianci";
import pg from "./pg_dg18_tianci";
import pg, { TimeCtrl } from "./pg_dg18_tianci";
import dg_xiaodi from "./dg18_tianci_xiaodi";
let win: any = window;
......@@ -28,15 +28,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
@property(dg_xiaodi) xiaodi: dg_xiaodi = null;
async onLoadEnd() {
this.initVideoPlayer();
this.showVideoPlayer();
return;
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData();
this.initView();
this.initEvent();
this.showVideoPlayer();
this.initVideoPlayer();
this.xiaodi.playEnter(this.data.npcAudio).then(() => {
this.initGame();
......@@ -80,6 +76,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.label_tip_wait.active = false;
this.label_tip_ing.active = false;
this.rich_content.active = false;
this.layout_video.active = false;
}
// 事件监听
initEvent() {
......@@ -244,11 +241,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
showNextBtn() {
}
showVideo() {
return new Promise(reslove => {
reslove('')
})
}
onTouchRestart() {
// 处理展示视频内容
......@@ -262,6 +254,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
onTouchNext() {
if (this.recording) return;
if (!this.nextQuestion) {
pg.view.find(this, 'layout_game/img_question').active = false;
this.btn_vioce.active = false;
this.label_tip_wait.active = false;
this.label_tip_ing.active = false;
// 处理展示视频内容
this.showVideo().then(() => {
// 底部显示为重新查看
......@@ -283,6 +280,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
@property(cc.Label) currentTimeLabel: cc.Label = null;
@property(cc.Node) layout_video: cc.Node = null;
@property(cc.Node) videoControls: cc.Node = null;
@property(cc.Node) pauseButton: cc.Node = null;
@property(cc.Node) playButton: cc.Node = null;
......@@ -290,41 +288,59 @@ export default class SceneComponent extends MyCocosSceneComponent {
showUI() {
pg.view.visible(pg.view.find(this, 'bg'), true)
pg.view.visible(pg.view.find(this, 'question_img'), true)
pg.view.visible(pg.view.find(this, 'img_kuang'), true)
pg.view.visible(pg.view.find(this, 'label_title'), true)
pg.view.visible(pg.view.find(this, 'layout_record'), true)
pg.view.visible(pg.view.find(this, 'layout_game'), true)
pg.view.visible(pg.view.find(this, 'layout_xiaodi'), true)
this.xiaodi.showAll();
}
hideUI() {
pg.view.visible(pg.view.find(this, 'bg'), false)
pg.view.visible(pg.view.find(this, 'question_img'), false)
pg.view.visible(pg.view.find(this, 'img_kuang'), false)
pg.view.visible(pg.view.find(this, 'label_title'), false)
pg.view.visible(pg.view.find(this, 'layout_record'), false)
pg.view.visible(pg.view.find(this, 'layout_game'), false)
pg.view.visible(pg.view.find(this, 'layout_xiaodi'), false)
}
playVideoEnd() {
this.xiaodi.hideAll();
}
showVideoPlayer() {
this.layout_video.active = true;
this.videoPlayer.stayOnBottom = true;
this._isReadyToPlay = false;
this.videoPlayer.node.x = 0;
this.videoPlayer.node.y = 0;
if (!this._isReadyToPlay) {
//首次播放
this._isReadyToPlay = false;
this.videoPlayer.remoteURL = this.data.video;
this.hideUI();
pg.view.touchOn(this.playButton, this.play, this);
pg.view.touchOn(this.pauseButton, this.pause, this);
} else {
//重复播放
this.videoPlayer.currentTime = 0;
this._isPlayComplated = false;
this.play();
}
this.hideUI();
setTimeout(() => {
this.videoPlayer.stayOnBottom = true;
}, 2000);
this.videoPlayer.stayOnBottom = false;
this.videoControls.active = false;
}, 3000);
}
private timeCtrl: TimeCtrl;
showVideo() {
return new Promise(async (reslove) => {
this.showVideoPlayer();
this.timeCtrl = pg.time.delayCtrl()
this.timeCtrl.fillTime(99999);
await this.timeCtrl.wait();
reslove('')
})
}
hideVideo() {
this.timeCtrl.reset();
this.videoPlayer.node.x = -10000;
this.videoPlayer.node.y = -10000;
this.layout_video.active = false;
this.showUI();
}
initVideoPlayer() {
this.videoPlayer.node.on('ready-to-play', () => {
console.log('ready-to-play');
......@@ -378,7 +394,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.playButton.active = false;
this.pauseButton.active = false;
// 循环播放下一个
this.playVideoEnd();
this.hideVideo();
});
cc.view.setResizeCallback((params) => {
console.log('Resize', params);
......@@ -578,7 +594,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}, 0.5)
}
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/txt'), this.data.npcTitle)
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)
}
......
......@@ -10,6 +10,14 @@ export default class dg_xiaodi extends cc.Component {
onLoad() {
}
hideAll() {
this.playEnterEnd();
this.playQuestionVoiceEnd();
this.node.active = false;
}
showAll() {
this.node.active = true;
}
private audioIdEnter: any;
playEnter(audioUrl) {
return new Promise((resolve, reject) => {
......
......@@ -102,7 +102,7 @@ class Signal<T = void> {
}
}
class TimeCtrl {
export class TimeCtrl {
private current: number;
constructor() {
this.current = 0;
......
......@@ -85,8 +85,6 @@
<div style="padding: 10px;background-color: #fff;">
<div class="border-dashed" style="margin: 20px;width: 1300px;">
<span style="font-size: 20px;">小迪标题: </span>
<input type="text" nz-input [(ngModel)]="item.npcTitle" (blur)="save()">
<span style="font-size: 20px;">小迪开始音频: </span>
<div style="display:flex ;">
<div>
......@@ -98,6 +96,8 @@
<span>{{ item.npcAudioName}}</span>
</div>
</div>
<span style="font-size: 20px;">小迪结束按钮文字: </span>
<input type="text" nz-input [(ngModel)]="item.npcAudioText" (blur)="save()">
<span style="font-size: 20px;">小迪结束音频: </span>
<div style="display:flex ;">
<div>
......
......@@ -15,7 +15,7 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
// 储存数据用
saveKey = "dg29_museum_1";
item = {
npcTitle: "",
npcAudioText: "",
npcAudio: "",
npcAudioName: "",
npcAudioEnd: "",
......
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