Commit bb6a3fd4 authored by 李维's avatar 李维

添加视频背景

parent fccce5a8
This diff is collapsed.
...@@ -512,7 +512,7 @@ cc.Class({ ...@@ -512,7 +512,7 @@ cc.Class({
console.log(" in addServerListener"); console.log(" in addServerListener");
const c = window.courseware; const c = window.courseware;
// this.loadEnd(); this.loadEnd();
if (!c) { if (!c) {
return; return;
} }
...@@ -782,10 +782,11 @@ cc.Class({ ...@@ -782,10 +782,11 @@ cc.Class({
}, },
// 设置视频背景 // 设置视频背景
initVideoBg(width, height) { initVideoBg(width, height, scale) {
const maskNode = cc.find('Canvas/video_bg').getComponent(cc.Mask); console.log("视频尺寸", width, height,scale);
maskNode.width = width; const bgNode = cc.find('Canvas/video_bg')
maskNode.height = height; bgNode.width = width*scale;
bgNode.height = height*scale;
}, },
getVideoUrl(callback) { getVideoUrl(callback) {
...@@ -1054,14 +1055,16 @@ cc.Class({ ...@@ -1054,14 +1055,16 @@ cc.Class({
console.log(" in initVideoRemote url: ", url); console.log(" in initVideoRemote url: ", url);
const videoConfigSize = this.data.videoType.solit('_'); const videoConfigSize = this.data.videoType.split('_');
let videoSizeW = 1920; let videoSizeW = 1920;
let videoSizeH = 1080; let videoSizeH = 1080;
if(videoConfigSize.length ==2 && !isNaN(Number(videoConfigSize[0])) && !isNaN(Number(videoConfigSize[1]))) { if(videoConfigSize.length ==2 && !isNaN(Number(videoConfigSize[0])) && !isNaN(Number(videoConfigSize[1]))) {
videoSizeW = Number(videoConfigSize[0]); videoSizeW = Number(videoConfigSize[0]);
videoSizeH = Number(videoConfigSize[1]); videoSizeH = Number(videoConfigSize[1]);
} }
this.initVideoBg(videoSizeW, videoSizeH);
const scale = this.canvas.height / videoSizeH;
this.initVideoBg(videoSizeW, videoSizeH, scale);
const videoRemoteNode = new cc.Node(); const videoRemoteNode = new cc.Node();
videoRemoteNode.width = videoSizeW; videoRemoteNode.width = videoSizeW;
...@@ -1069,7 +1072,7 @@ cc.Class({ ...@@ -1069,7 +1072,7 @@ cc.Class({
videoRemoteNode.parent = this.canvas; videoRemoteNode.parent = this.canvas;
// videoRemoteNode.y = -this.canvas.height * 1.5; // videoRemoteNode.y = -this.canvas.height * 1.5;
videoRemoteNode.scale = this.canvas.height / videoSizeH; videoRemoteNode.scale = scale;
const video = videoRemoteNode.addComponent(cc.VideoPlayer); const video = videoRemoteNode.addComponent(cc.VideoPlayer);
video.resourceType = cc.VideoPlayer.ResourceType.REMOTE; video.resourceType = cc.VideoPlayer.ResourceType.REMOTE;
......
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