Commit 37e0ebd3 authored by 李维's avatar 李维

添加视频控制组件

parent f11c96a8
{
"ver": "1.1.2",
"uuid": "a4f2cc1e-0615-4e43-a6e0-96bb0f7abc4d",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "c02d26a4-e435-4a3f-abcf-72cef3fec835",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "7f522e96-a4f7-436c-87b1-5adb2db280d4",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "b6cd9543-0d28-4cb5-a9a0-65aae0fee661",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "98bc55c6-f5ad-449d-94df-df41b6e6f5ed",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "090bea8b-1ee6-4ddf-a3c5-2cf52146b643",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 789,
"height": 9,
"platformSettings": {},
"subMetas": {
"bg_progress": {
"ver": "1.0.4",
"uuid": "4d6c112d-8b3d-4c32-be3f-b45783e0c6de",
"rawTextureUuid": "090bea8b-1ee6-4ddf-a3c5-2cf52146b643",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 789,
"height": 9,
"rawWidth": 789,
"rawHeight": 9,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "d66261d8-7f7d-462f-a04d-f58446c8e536",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 789,
"height": 9,
"platformSettings": {},
"subMetas": {
"bg_progress_fill": {
"ver": "1.0.4",
"uuid": "9ab3d4fd-4a35-42c9-8765-cd10d11cdbdc",
"rawTextureUuid": "d66261d8-7f7d-462f-a04d-f58446c8e536",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 789,
"height": 9,
"rawWidth": 789,
"rawHeight": 9,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 5,
"borderRight": 5,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "d5936b8a-3f6c-4b7f-acc4-09ebf221bdf1",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 68,
"height": 68,
"platformSettings": {},
"subMetas": {
"btn_drag": {
"ver": "1.0.4",
"uuid": "d589b6f2-f2c0-49b9-ac49-148906639984",
"rawTextureUuid": "d5936b8a-3f6c-4b7f-acc4-09ebf221bdf1",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 68,
"height": 68,
"rawWidth": 68,
"rawHeight": 68,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "5ea2c60d-ccd2-4a7d-b76b-da4e22c384dd",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 157,
"height": 157,
"platformSettings": {},
"subMetas": {
"btn_pause": {
"ver": "1.0.4",
"uuid": "09115af6-4543-42ff-ba71-33c861f0eb9b",
"rawTextureUuid": "5ea2c60d-ccd2-4a7d-b76b-da4e22c384dd",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 91,
"height": 91,
"rawWidth": 91,
"rawHeight": 91,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "715dda82-c69c-47b6-9475-96a2581b021b",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 91,
"height": 91,
"platformSettings": {},
"subMetas": {
"btn_play": {
"ver": "1.0.4",
"uuid": "215ed382-746a-4e37-9f7b-6ff19c33b914",
"rawTextureUuid": "715dda82-c69c-47b6-9475-96a2581b021b",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 91,
"height": 91,
"rawWidth": 91,
"rawHeight": 91,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "caa80193-87d9-41b7-b0a9-eaccfa13b253",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 91,
"height": 91,
"platformSettings": {},
"subMetas": {
"btn_replay": {
"ver": "1.0.4",
"uuid": "74dc7db0-2bad-4bb8-8bbc-f19767669a6f",
"rawTextureUuid": "caa80193-87d9-41b7-b0a9-eaccfa13b253",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 91,
"height": 91,
"rawWidth": 91,
"rawHeight": 91,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "088edbf5-7a2d-4a85-bc93-300a6a0aef30",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 15,
"height": 15,
"platformSettings": {},
"subMetas": {
"icon_key_point": {
"ver": "1.0.4",
"uuid": "1d902da0-5593-4de3-892a-b955ebaeae03",
"rawTextureUuid": "088edbf5-7a2d-4a85-bc93-300a6a0aef30",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 15,
"height": 15,
"rawWidth": 15,
"rawHeight": 15,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -4,7 +4,8 @@ import {
loadImageByUrl,
asyncLoadRemote,
getSprNode,
playLocalAudio
playLocalAudio,
asyncGetVideoDuration
} from "../script/util_DG_FAF";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_DG_FAF";
import { getUUID } from "../script/util_DG_FAF";
......@@ -64,6 +65,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
@property({type: cc.Node, displayName: "语音评测"})
pronunciationAssessmentModal: cc.Node = null;
@property({type: cc.Node, displayName: "视频进度控制条"})
videoControlBar: cc.Node = null;
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
if(this.data.bgItem.url) {
......@@ -384,6 +388,57 @@ export default class SceneComponent extends MyCocosSceneComponent {
closeBtn.on("click", ()=>{
this.hideVideoLayer();
})
// 隐藏视频控制组件
this.videoControlBar.emit("hide_bar", true);
// 监听组件发来的拖动开始和结束消息
this.videoControlBar.on("on_drag_button", (isDragStart)=>{
// if(isDragStart) {
// this.hideWaitingVideo();
// this.isDragProgressBar = true;
// this.video.pause();
// this.videoControlBar.emit("update_video_status", 0);
// this.cleanProgressBarTimer();
// } else {
// this.restQuesData(this.video.currentTime);
// this.isDragProgressBar = false;
// this.video.play();
// this.videoControlBar.emit("update_video_status", 1);
// this.setProgressBarTimer();
// }
})
// 监听组件发来的拖动百分比
this.videoControlBar.on("on_drag_percent", (percent)=>{
this.currentVideoPlay.currentTime = percent * this.videoDuration;
// this.showProgressBar();
})
// 监听组件发来视频播放、暂停事件
this.videoControlBar.on("video_btn_click", (isPlay)=>{
if(isPlay) {
this.currentVideoPlay.play();
} else {
this.currentVideoPlay.pause();
}
// this.cleanProgressBarTimer();
// this.setProgressBarTimer();
// if(isPlay) {
// if(this.isWaitingUserAction) {
// this.hideWaitingVideo();
// this.restQuesData(this.video.currentTime);
// }
// this.video.play();
// } else {
// this.video.pause();
// }
})
this.videoControlBar.on("on_touch_progressbar", (e)=>{
// console.log("Click bar")
// this.showProgressBar();
})
}
scoreShowContainer = null;
......@@ -2456,6 +2511,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
};
// 视频播放题型
currentVideoPlay = null;
videoDuration = 0;
setOneVideoBtn(contentData, hotZoneItemData, debugMode=false) {
const rect = this.newRectNode(hotZoneItemData, layer_4, debugMode);
const aniAudio = cc.instantiate(this.aniVideoTips)
......@@ -2473,11 +2530,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
this.showVideoLayer();
const videoplayer = cc.find("Canvas/VideoPlayerContainer/videoPlayer").getComponent(cc.VideoPlayer)
videoplayer.stayOnBottom = true;
videoplayer.remoteURL = contentData.video_url;
this.videoDuration = await asyncGetVideoDuration(videoplayer);
// 设置进度条的起始和结束标签
this.videoControlBar.emit("set_duration", this.videoDuration)
// 显示视频控制组件
this.videoControlBar.emit("show_bar", true);
this.currentVideoPlay = videoplayer;
videoplayer.play();
this.videoControlBar.emit("update_video_status", 1);
})
};
// 画图题
setDrawingArea(contentData, hotZoneItemData, debugMode=false) {
const rect = this.newRectNode(hotZoneItemData, layer_4, debugMode);
......@@ -3040,6 +3108,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
hideVideoLayer() {
const canvas = cc.find("Canvas");
const hideNodeNames = ["MainContent", "Header", "Footer", "ActionBtnMaskBg", "ActionBtn", "backBtn"];
this.currentVideoPlay.stop();
this.videoControlBar.emit("update_video_status", 0);
this.currentVideoPlay = null;
this.videoDuration = null;
// 隐藏视频控制组件
this.videoControlBar.emit("hide_bar", true);
canvas.children.forEach(nodeItem => {
if(hideNodeNames.indexOf(nodeItem.name) != -1) {
nodeItem.x = this.hideLayerPosSaved[nodeItem.name].x;
......@@ -3560,5 +3636,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
onDestroy() {
cc.audioEngine.stop(this.currentAudioPlay);
}
// update (dt) {},
update() {
// if (this.isDestroy) {
// return;
// }
if(this.currentVideoPlay != null) {
// 更新当前进度条
if(this.videoDuration== null) {
this.videoControlBar.emit("update_video_progress", 0)
} else {
this.videoControlBar.emit("update_video_progress", this.currentVideoPlay.currentTime)
}
}
// 如果没有正在拖动中 检查是否为题目停止
// if(!this.isDragProgressBar) {
// this.updateCheckStop();
// }
}
}
This diff is collapsed.
......@@ -518,6 +518,19 @@ export function getUUID() {
});
}
// 获取视频时长
export function asyncGetVideoDuration(video) {
return new Promise(async (resovle, reject) => {
let dur = null
let maxCount = 0;
do {
dur = video.getDuration();
maxCount ++;
await asyncDelay(0.1)
} while(maxCount <= 200 && (dur == null || isNaN(dur)));
resovle(dur)
})
}
// 获取视频地址
// export function getVideoUrl(callback) {
// const url1 = this.data.video_url;
......
{
"ver": "2.3.5",
"uuid": "6a023e5e-7b5f-4734-8786-76551410aa1c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 100,
"height": 100,
"platformSettings": {},
"subMetas": {
"btn_close_2": {
"ver": "1.0.4",
"uuid": "03b2015f-82e8-497f-a89f-ab015cfa6720",
"rawTextureUuid": "6a023e5e-7b5f-4734-8786-76551410aa1c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0.5,
"offsetY": -0.5,
"trimX": 20,
"trimY": 20,
"width": 61,
"height": 61,
"rawWidth": 100,
"rawHeight": 100,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
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