瀏覽代碼

Merge branch 'dev-5.0' of http://192.168.32.253:3000/Software/android-cloud-H5 into dev-5.0

heyang 3 年之前
父節點
當前提交
799281cf85
共有 3 個文件被更改,包括 107 次插入105 次删除
  1. 56 54
      screenAndroid/WXdraw.js
  2. 49 47
      screenIos/WXdraw.js
  3. 2 4
      screenIos/WXtrialInterface.html

+ 56 - 54
screenAndroid/WXdraw.js

@@ -32,8 +32,8 @@ form.ip = parameters["ip"];
 form.domainName = parameters["domainName"];
 var isWSS = true;
 var cUrl = isWSS ? "wss://" + form.domainName + "?cardIp=" + form.ip + "&token=" + cardToken : "ws://" + form.domainName + "?cardIp=" + form.ip + "&token=" + cardToken;
-var videoWidth = 720
-var videoHeight = 1280
+var videoWidth = parameters['mealType'] === "STARPRO" || parameters['mealType'] === "STAR" ? 1080 : 720
+var videoHeight = parameters['mealType'] === "STARPRO" || parameters['mealType'] === "STAR" ? 1920 : 1280
 
 var wsss, errorTime = 0;
 var first = true;
@@ -75,25 +75,20 @@ function doConnect() {
       }
     }
     wsss.send(JSON.stringify(screenPic));
-    // 获取分辨率
-    var phoneSize = {
-      "type": "getPhoneSize"
-    }
-    wsss.send(JSON.stringify(phoneSize));
   };
   wsss.onerror = function (evt) {
     wsss.close();
     throttle(doConnect, 100);
     if (errorTime > 1000) {
-		if(navigator.userAgent.toLowerCase().includes('toutiaomicroapp')){
-			tt.miniProgram.switchTab({
-				url: '/pages/home/home'
-			})
-		}else{
-			wx.miniProgram.switchTab({
-				url: '/pages/home/home'
-			})
-		}
+      if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
+        tt.miniProgram.switchTab({
+          url: '/pages/home/home'
+        })
+      } else {
+        wx.miniProgram.switchTab({
+          url: '/pages/home/home'
+        })
+      }
     }
   };
   wsss.onmessage = function (res) {
@@ -106,13 +101,6 @@ function doConnect() {
       }
       return
     }
-    if (result.type === 'getPhoneSize') {
-      if (result.data.status === 0) {
-        videoWidth = result.data.width
-        videoHeight = result.data.height
-      }
-      return
-    }
     var unit8Arr = new Uint8Array(result);
     if (unit8Arr[0] == 0x68 && unit8Arr[1] == 0x09 && first) {
       first = false;
@@ -163,7 +151,6 @@ $(".PictureQuality").on("click", function () {
   }
   wsss.send(JSON.stringify(bitRate))
 })
-var ongoingTouches = [];
 //画图形
 var draw_graph = function (graphType, obj) {
   //把蒙版放于画板上面
@@ -171,6 +158,7 @@ var draw_graph = function (graphType, obj) {
   $("#dedit").css("z-index", 20);
   var canDraw = false;
   //鼠标按下获取 开始xy开始画图
+  var ongoingTouches = [];
   var touchstart = function (e) {
     $('.control-right-img').attr({
       "data-id": "2"
@@ -178,33 +166,46 @@ var draw_graph = function (graphType, obj) {
     $(".leftmains").css({
       "right": "-4rem"
     })
-    var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
-    ongoingTouches.push(touchfor);
-    var acrossWidthX = touchfor.pageY * (videoHeight / voheight);
-    var acrossHeightY = videoWidth - touchfor.pageX * (videoWidth / vowidth);
-    var verticalWidthX = touchfor.pageX * (videoWidth / vowidth);
-    var verticalHeightY = touchfor.pageY * (videoHeight / voheight);
+    var touchfor = e.originalEvent.changedTouches; //for 的手指数组
     //是否横屏
-    var ping = resolving == 0 ?
-      { "data": { "action": 0, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
-      { "data": { "action": 0, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
-    wsss.send(JSON.stringify(ping));
+    for (var i = 0; i < touchfor.length; i++) {
+      var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
+      var acrossHeightY = videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
+      var idx = ongoingTouches.findIndex(function (ele) {
+        return ele.identifier === touchfor[i].identifier
+      })
+      if (idx < 0) {
+        ongoingTouches.push(touchfor[i]);
+      }
+      var ping = resolving == 0 ?
+        { "data": { "action": 0, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
+        { "data": { "action": 0, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
+      wsss.send(JSON.stringify(ping));
+    }
     canDraw = true;
   };
 
   //鼠标离开 把蒙版canvas的图片生成到canvas中
   var touchend = function (e) {
-    var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
-    var acrossWidthX = touchfor.pageY * (videoHeight / voheight);
-    var acrossHeightY = videoWidth - touchfor.pageX * (videoWidth / vowidth);
-    var verticalWidthX = touchfor.pageX * (videoWidth / vowidth);
-    var verticalHeightY = touchfor.pageY * (videoHeight / voheight);
+    var touchfor = e.originalEvent.changedTouches; //for 的手指数组
     //是否横屏
-    var ping = resolving == 0 ?
-      { "data": { "action": 1, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
-      { "data": { "action": 1, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
-    wsss.send(JSON.stringify(ping));
-    ongoingTouches.splice(touchfor.identifier, 1);
+    for (var i = 0; i < touchfor.length; i++) {
+      var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
+      var acrossHeightY = videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
+      var ping = resolving == 0 ?
+        { "data": { "action": 1, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
+        { "data": { "action": 1, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
+      wsss.send(JSON.stringify(ping));
+      ongoingTouches.forEach(function (item, index) {
+        if (item.identifier === touchfor[i].identifier) {
+          ongoingTouches.splice(index, 1)
+        }
+      })
+    }
     canDraw = false;
   };
 
@@ -215,16 +216,17 @@ var draw_graph = function (graphType, obj) {
 
   // 鼠标移动
   var touchmove = function (e) {
-    e = e || window.event;
-    var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
-    var acrossWidthX = touchfor.pageY * (videoHeight / voheight);
-    var acrossHeightY = videoWidth - touchfor.pageX * (videoWidth / vowidth);
-    var verticalWidthX = touchfor.pageX * (videoWidth / vowidth);
-    var verticalHeightY = touchfor.pageY * (videoHeight / voheight);
-    var ping = resolving == 0 ?
-      { "data": { "action": 2, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
-      { "data": { "action": 2, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
-    wsss.send(JSON.stringify(ping));
+    var touchfor = e.originalEvent.targetTouches; //for 的手指数组
+    for (var i = 0; i < touchfor.length; i++) {
+      var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
+      var acrossHeightY = videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
+      var ping = resolving == 0 ?
+        { "data": { "action": 2, "count": touchfor.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
+        { "data": { "action": 2, "count": touchfor.length, "pointerId": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
+      wsss.send(JSON.stringify(ping));
+    }
   };
 
   //鼠标离开区域以外 除了涂鸦 都清空

+ 49 - 47
screenIos/WXdraw.js

@@ -31,8 +31,8 @@ form.ip = parameters['ip'];
 form.domainName = parameters["domainName"];
 var isWSS = true;
 var cUrl = isWSS ? "wss://" + form.domainName + "?cardIp=" + form.ip + "&token=" + cardToken : "ws://" + form.domainName + "?cardIp=" + form.ip + "&token=" + cardToken;
-var videoWidth = 720
-var videoHeight = 1280
+var videoWidth = parameters['mealType'] === "STARPRO" || parameters['mealType'] === "STAR" ? 1080 : 720
+var videoHeight = parameters['mealType'] === "STARPRO" || parameters['mealType'] === "STAR" ? 1920 : 1280
 var wsss;
 var errorTime = 0;
 var first = true;
@@ -75,21 +75,16 @@ function doConnect() {
       }
     }
     wsss.send(JSON.stringify(screenPic));
-    // 获取分辨率
-    var phoneSize = {
-      "type": "getPhoneSize"
-    }
-    wsss.send(JSON.stringify(phoneSize));
   };
   wsss.onerror = function () {
     wsss.close();
     throttle(doConnect, 100);
     if (errorTime > 1000) {
-      if(navigator.userAgent.toLowerCase().includes('toutiaomicroapp')){
+      if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
         tt.miniProgram.switchTab({
           url: '/pages/home/home'
         })
-      }else{
+      } else {
         wx.miniProgram.switchTab({
           url: '/pages/home/home'
         })
@@ -106,13 +101,6 @@ function doConnect() {
       }
       return
     }
-    if (result.type === 'getPhoneSize') {
-      if (result.data.status === 0) {
-        videoWidth = result.data.width
-        videoHeight = result.data.height
-      }
-      return
-    }
     var unit8Arr = new Uint8Array(result);
     if (unit8Arr[0] == 0x68 && unit8Arr[1] == 0x09 && first) {
       first = false;
@@ -162,7 +150,6 @@ $(".PictureQuality").on("click", function () {
   wsss.send(JSON.stringify(bitRate))
 })
 var canDraw = false;
-var ongoingTouches = [];
 //画图形
 var draw_graph = function (graphType) {
   //把蒙版放于画板上面
@@ -170,6 +157,7 @@ var draw_graph = function (graphType) {
   $("#dedit").css("z-index", 20);
   // 先画在蒙版上 再复制到画布上
   //鼠标按下获取 开始xy开始画图
+  var ongoingTouches = [];
   var touchstart = function (e) {
     $('.control-right-img').attr({
       "data-id": "2"
@@ -177,33 +165,46 @@ var draw_graph = function (graphType) {
     $(".leftmains").css({
       "right": "-4rem"
     })
-    var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
-    ongoingTouches.push(touchfor);
-    var acrossWidthX = touchfor.pageY * (videoHeight / voheight);
-    var acrossHeightY = videoWidth - touchfor.pageX * (videoWidth / vowidth);
-    var verticalWidthX = touchfor.pageX * (videoWidth / vowidth);
-    var verticalHeightY = touchfor.pageY * (videoHeight / voheight);
+    var touchfor = e.originalEvent.changedTouches; //for 的手指数组
     //是否横屏
-    var ping = resolving == 0 ?
-      { "data": { "action": 0, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
-      { "data": { "action": 0, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
-    wsss.send(JSON.stringify(ping));
+    for (var i = 0; i < touchfor.length; i++) {
+      var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
+      var acrossHeightY = videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
+      var idx = ongoingTouches.findIndex(function (ele) {
+        return ele.identifier === touchfor[i].identifier
+      })
+      if (idx < 0) {
+        ongoingTouches.push(touchfor[i]);
+      }
+      var ping = resolving == 0 ?
+        { "data": { "action": 0, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
+        { "data": { "action": 0, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
+      wsss.send(JSON.stringify(ping));
+    }
     canDraw = true;
   };
 
   //鼠标离开 把蒙版canvas的图片生成到canvas中
   var touchend = function (e) {
-    var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
-    var acrossWidthX = touchfor.pageY * (videoHeight / voheight);
-    var acrossHeightY = videoWidth - touchfor.pageX * (videoWidth / vowidth);
-    var verticalWidthX = touchfor.pageX * (videoWidth / vowidth);
-    var verticalHeightY = touchfor.pageY * (videoHeight / voheight);
+    var touchfor = e.originalEvent.changedTouches; //for 的手指数组
     //是否横屏
-    var ping = resolving == 0 ?
-      { "data": { "action": 1, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
-      { "data": { "action": 1, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
-    wsss.send(JSON.stringify(ping));
-    ongoingTouches.splice(touchfor.identifier, 1);
+    for (var i = 0; i < touchfor.length; i++) {
+      var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
+      var acrossHeightY = videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
+      var ping = resolving == 0 ?
+        { "data": { "action": 1, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
+        { "data": { "action": 1, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
+      wsss.send(JSON.stringify(ping));
+      ongoingTouches.forEach(function (item, index) {
+        if (item.identifier === touchfor[i].identifier) {
+          ongoingTouches.splice(index, 1)
+        }
+      })
+    }
     canDraw = false;
   };
 
@@ -214,16 +215,17 @@ var draw_graph = function (graphType) {
 
   // 鼠标移动
   var touchmove = function (e) {
-    e = e || window.event;
-    var touchfor = e.originalEvent.changedTouches[0]; //for 的手指数组
-    var acrossWidthX = touchfor.pageY * (videoHeight / voheight);
-    var acrossHeightY = videoWidth - touchfor.pageX * (videoWidth / vowidth);
-    var verticalWidthX = touchfor.pageX * (videoWidth / vowidth);
-    var verticalHeightY = touchfor.pageY * (videoHeight / voheight);
-    var ping = resolving == 0 ?
-      { "data": { "action": 2, "count": ongoingTouches.length, "id": touchfor.identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
-      { "data": { "action": 2, "count": ongoingTouches.length, "id": touchfor.identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
-    wsss.send(JSON.stringify(ping));
+    var touchfor = e.originalEvent.targetTouches; //for 的手指数组
+    for (var i = 0; i < touchfor.length; i++) {
+      var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
+      var acrossHeightY = videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
+      var ping = resolving == 0 ?
+        { "data": { "action": 2, "count": touchfor.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
+        { "data": { "action": 2, "count": touchfor.length, "pointerId": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
+      wsss.send(JSON.stringify(ping));
+    }
   };
 
   //鼠标离开区域以外 除了涂鸦 都清空

+ 2 - 4
screenIos/WXtrialInterface.html

@@ -636,9 +636,7 @@
       Module._free(inputPtr);
       Module._free(retPtr);
     }
-    var vWidth = Number(parameters['width']) ? Number(parameters['width']) : videoWidth;
-    var vHeight = Number(parameters['height']) ? Number(parameters['height']) : videoHeight;
-    var decodeWoker = new Worker('decoder.js?width=' + vWidth + '&height=' + vHeight);
+    var decodeWoker = new Worker('decoder.js?width=' + videoWidth + '&height=' + videoHeight);
     var myVideo = document.getElementById("playCanvas");
     decodeWoker.onmessage = function (event) {
       var objData = event.data;
@@ -650,7 +648,7 @@
           if (renderCount++ < 4 || !isAudioPlay) {
             return
           }
-          webglPlayer.renderFrame(objData.data, vWidth, vHeight, vWidth * vHeight, (vWidth / 2) * (vHeight / 2));
+          webglPlayer.renderFrame(objData.data, videoWidth, videoHeight, videoWidth * videoHeight, (videoWidth / 2) * (videoHeight / 2));
           $('.weui-mask_transparent').hide()
           $('.weui-toast').hide()
           $('.loading').hide()